summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/GenEx-PATH/GET_ITEM.cmake.in
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2023-02-14 14:48:31 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2023-02-21 18:34:43 (GMT)
commite395310a215503a0cc21771fc73a35bc0afa59c0 (patch)
tree5fbddce8e48b5480fc989ca506a07173ded95f10 /Tests/RunCMake/GenEx-PATH/GET_ITEM.cmake.in
parentd3ea15e80152511946c719404466dfa199532005 (diff)
downloadCMake-e395310a215503a0cc21771fc73a35bc0afa59c0.zip
CMake-e395310a215503a0cc21771fc73a35bc0afa59c0.tar.gz
CMake-e395310a215503a0cc21771fc73a35bc0afa59c0.tar.bz2
PATH-genex: handle lists for path decomposition and transformations
Fixes: #24371
Diffstat (limited to 'Tests/RunCMake/GenEx-PATH/GET_ITEM.cmake.in')
-rw-r--r--Tests/RunCMake/GenEx-PATH/GET_ITEM.cmake.in123
1 files changed, 123 insertions, 0 deletions
diff --git a/Tests/RunCMake/GenEx-PATH/GET_ITEM.cmake.in b/Tests/RunCMake/GenEx-PATH/GET_ITEM.cmake.in
index b58998c..e2acde4 100644
--- a/Tests/RunCMake/GenEx-PATH/GET_ITEM.cmake.in
+++ b/Tests/RunCMake/GenEx-PATH/GET_ITEM.cmake.in
@@ -1,3 +1,4 @@
+cmake_policy(SET CMP0140 NEW)
include ("${RunCMake_SOURCE_DIR}/check_errors.cmake")
unset (errors)
@@ -308,4 +309,126 @@ if (NOT output STREQUAL reference)
endif()
+######################################
+## third, tests with list of paths
+######################################
+if (WIN32)
+ set (paths "C:/aa/bb/cc.ext1.ext2" "D:/xx/yy/zz.ext3.ext4")
+else()
+ set (paths "/aa/bb/cc.ext1.ext2" "/xx/yy/zz.ext3.ext4")
+endif()
+
+function (compute_reference action)
+ unset(reference)
+ foreach (path IN LISTS paths)
+ cmake_path(GET path ${ARGV} result)
+ list(APPEND reference "${result}")
+ endforeach()
+ if (reference STREQUAL "")
+ # define the list as 2 empty elements
+ set(reference ";")
+ endif()
+
+ return(PROPAGATE reference)
+endfunction()
+
+compute_reference(ROOT_NAME)
+if (WIN32)
+ set(output "$<PATH:GET_ROOT_NAME,C:/aa/bb/cc.ext1.ext2;D:/xx/yy/zz.ext3.ext4>")
+else()
+ set (output "$<PATH:GET_ROOT_NAME,/aa/bb/cc.ext1.ext2;/xx/yy/zz.ext3.ext4>")
+endif()
+if (NOT output STREQUAL reference)
+ list (APPEND errors "ROOT_NAME returns bad data: ${output}")
+endif()
+
+compute_reference(ROOT_DIRECTORY)
+if (WIN32)
+ set(output "$<PATH:GET_ROOT_DIRECTORY,C:/aa/bb/cc.ext1.ext2;D:/xx/yy/zz.ext3.ext4>")
+else()
+ set (output "$<PATH:GET_ROOT_DIRECTORY,/aa/bb/cc.ext1.ext2;/xx/yy/zz.ext3.ext4>")
+endif()
+if (NOT output STREQUAL reference)
+ list (APPEND errors "ROOT_DIRECTORY returns bad data: ${output}")
+endif()
+
+compute_reference(ROOT_PATH)
+if (WIN32)
+ set(output "$<PATH:GET_ROOT_PATH,C:/aa/bb/cc.ext1.ext2;D:/xx/yy/zz.ext3.ext4>")
+else()
+ set (output "$<PATH:GET_ROOT_PATH,/aa/bb/cc.ext1.ext2;/xx/yy/zz.ext3.ext4>")
+endif()
+if (NOT output STREQUAL reference)
+ list (APPEND errors "ROOT_PATH returns bad data: ${output}")
+endif()
+
+compute_reference(FILENAME)
+if (WIN32)
+ set(output "$<PATH:GET_FILENAME,C:/aa/bb/cc.ext1.ext2;D:/xx/yy/zz.ext3.ext4>")
+else()
+ set (output "$<PATH:GET_FILENAME,/aa/bb/cc.ext1.ext2;/xx/yy/zz.ext3.ext4>")
+endif()
+if (NOT output STREQUAL reference)
+ list (APPEND errors "FILENAME returns bad data: ${output}")
+endif()
+
+compute_reference(EXTENSION)
+if (WIN32)
+ set(output "$<PATH:GET_EXTENSION,C:/aa/bb/cc.ext1.ext2;D:/xx/yy/zz.ext3.ext4>")
+else()
+ set (output "$<PATH:GET_EXTENSION,/aa/bb/cc.ext1.ext2;/xx/yy/zz.ext3.ext4>")
+endif()
+if (NOT output STREQUAL reference)
+ list (APPEND errors "EXTENSION returns bad data: ${output}")
+endif()
+compute_reference(EXTENSION LAST_ONLY)
+if (WIN32)
+ set(output "$<PATH:GET_EXTENSION,LAST_ONLY,C:/aa/bb/cc.ext1.ext2;D:/xx/yy/zz.ext3.ext4>")
+else()
+ set (output "$<PATH:GET_EXTENSION,LAST_ONLY,/aa/bb/cc.ext1.ext2;/xx/yy/zz.ext3.ext4>")
+endif()
+if (NOT output STREQUAL reference)
+ list (APPEND errors "EXTENSION LAST_ONLY returns bad data: ${output}")
+endif()
+
+compute_reference(STEM)
+if (WIN32)
+ set(output "$<PATH:GET_STEM,C:/aa/bb/cc.ext1.ext2;D:/xx/yy/zz.ext3.ext4>")
+else()
+ set (output "$<PATH:GET_STEM,/aa/bb/cc.ext1.ext2;/xx/yy/zz.ext3.ext4>")
+endif()
+if (NOT output STREQUAL reference)
+ list (APPEND errors "STEM returns bad data: ${output}")
+endif()
+compute_reference(STEM LAST_ONLY)
+if (WIN32)
+ set(output "$<PATH:GET_STEM,LAST_ONLY,C:/aa/bb/cc.ext1.ext2;D:/xx/yy/zz.ext3.ext4>")
+else()
+ set (output "$<PATH:GET_STEM,LAST_ONLY,/aa/bb/cc.ext1.ext2;/xx/yy/zz.ext3.ext4>")
+endif()
+if (NOT output STREQUAL reference)
+ list (APPEND errors "STEM LAST_ONLY returns bad data: ${reference}")
+endif()
+
+compute_reference(RELATIVE_PART)
+if (WIN32)
+ set(output "$<PATH:GET_RELATIVE_PART,C:/aa/bb/cc.ext1.ext2;D:/xx/yy/zz.ext3.ext4>")
+else()
+ set (output "$<PATH:GET_RELATIVE_PART,/aa/bb/cc.ext1.ext2;/xx/yy/zz.ext3.ext4>")
+endif()
+if (NOT output STREQUAL reference)
+ list (APPEND errors "RELATIVE_PART returns bad data: ${output}")
+endif()
+
+compute_reference(PARENT_PATH)
+if (WIN32)
+ set(output "$<PATH:GET_PARENT_PATH,C:/aa/bb/cc.ext1.ext2;D:/xx/yy/zz.ext3.ext4>")
+else()
+ set (output "$<PATH:GET_PARENT_PATH,/aa/bb/cc.ext1.ext2;/xx/yy/zz.ext3.ext4>")
+endif()
+if (NOT output STREQUAL reference)
+ list (APPEND errors "PARENT_PATH returns bad data: ${output}")
+endif()
+
+
check_errors("PATH:GET..." ${errors})