Files
Timo Röhling e746ac28fb Tests/RunCMake/CommandLine: Check tilde shell expansion more precisely
Revise the test from commit 01f92efeb0 (Restore expansion of leading '~'
as home directory in input paths, 2025-04-02, v4.0.1~12^2) to tolerate
`~` in the path to CMake's source or build tree.  If tilde `~` shell
expansion fails it can only occur at the beginning of a path component.
2026-03-14 07:15:23 -04:00

22 lines
833 B
CMake

if(NOT "$ENV{HOME}" STREQUAL "")
if(TILDE_PATH MATCHES "(^|/)~" OR NOT IS_ABSOLUTE "${TILDE_PATH}")
message(SEND_ERROR "~ not expanded as expected:\n ${TILDE_PATH}")
endif()
if(TILDE_SLASH_PATH MATCHES "(^|/)~/" OR NOT IS_ABSOLUTE "${TILDE_SLASH_PATH}" OR NOT TILDE_SLASH_PATH MATCHES "/InHome$")
message(SEND_ERROR "~/ not expanded as expected:\n ${TILDE_SLASH_PATH}")
endif()
else()
set(ENV{HOME} "${CMAKE_CURRENT_LIST_DIR}")
endif()
set(TILDE "" CACHE PATH "")
if(TILDE MATCHES "(^|/)~" OR NOT IS_ABSOLUTE "${TILDE}")
message(SEND_ERROR "~ not expanded as expected:\n ${TILDE}")
endif()
set(TILDE_SLASH "" CACHE PATH "")
if(TILDE_SLASH MATCHES "(^|/)~/" OR NOT IS_ABSOLUTE "${TILDE_SLASH}" OR NOT TILDE_SLASH MATCHES "/InHome$")
message(SEND_ERROR "~/ not expanded as expected:\n ${TILDE_SLASH}")
endif()