Files
CMake/Tests/RunCMake/CommandLine/D-tilde.cmake
Brad King 01f92efeb0 Restore expansion of leading '~' as home directory in input paths
This was accidentally dropped by commit 622596c6b2 (cmSystemTools:
Re-implement ToNormalizedPathOnDisk without translation map, 2024-10-30,
v4.0.0-rc1~528^2~5).  Previously it was done by `CollapseFullPath`.
`cm::PathResolver` intentionally does not expand `~` because it makes
sense only for transforming input paths.  Teach `ToNormalizedPathOnDisk`
to handle it directly.

Fixes: #26827
2025-04-02 14:41:48 -04:00

22 lines
811 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()