mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-09 00:29:55 -06:00
Implements the generator expression $<PATH:MATIVE_PATH> which convert path(s) into a native format with platform-specific slashes (``\`` on Windows hosts and ``/`` elsewhere). Fixes: #26515
49 lines
1.5 KiB
CMake
49 lines
1.5 KiB
CMake
|
|
include ("${RunCMake_SOURCE_DIR}/check_errors.cmake")
|
|
unset (errors)
|
|
|
|
cmake_path(SET test_path "/x/y/z/../../a/d")
|
|
cmake_path(NATIVE_PATH test_path reference)
|
|
set(output [=[$<PATH:NATIVE_PATH,/x/y/z/../../a/d>]=])
|
|
if (NOT output STREQUAL reference)
|
|
list (APPEND errors "'${output}' instead of '${reference}'")
|
|
endif()
|
|
cmake_path(SET test_path "/x/y/z/../../a/d")
|
|
cmake_path(NATIVE_PATH test_path NORMALIZE reference)
|
|
set(output [=[$<PATH:NATIVE_PATH,NORMALIZE,/x/y/z/../../a/d>]=])
|
|
if (NOT output STREQUAL reference)
|
|
list (APPEND errors "'${output}' instead of '${reference}'")
|
|
endif()
|
|
|
|
|
|
######################################
|
|
## tests with list of paths
|
|
######################################
|
|
unset(reference)
|
|
foreach(path IN ITEMS "/x/y/z/../../a/d" "/x/y/z/../../b/e")
|
|
cmake_path(SET test_path "${path}")
|
|
cmake_path(NATIVE_PATH test_path result)
|
|
list(APPEND reference "${result}")
|
|
endforeach()
|
|
|
|
set(output [=[$<PATH:NATIVE_PATH,/x/y/z/../../a/d;/x/y/z/../../b/e>]=])
|
|
if (NOT output STREQUAL reference)
|
|
list (APPEND errors "'${output}' instead of '${reference}'")
|
|
endif()
|
|
|
|
unset(reference)
|
|
foreach(path IN ITEMS "/x/y/z/../../a/d" "/x/y/z/../../b/e")
|
|
cmake_path(SET test_path "${path}")
|
|
cmake_path(NATIVE_PATH test_path NORMALIZE result)
|
|
list(APPEND reference "${result}")
|
|
endforeach()
|
|
set(output [=[$<PATH:NATIVE_PATH,NORMALIZE,/x/y/z/../../a/d;/x/y/z/../../b/e>]=])
|
|
if (NOT output STREQUAL reference)
|
|
list (APPEND errors "'${output}' instead of '${reference}'")
|
|
endif()
|
|
|
|
|
|
|
|
|
|
check_errors("PATH:NATIVE_PATH" ${errors})
|