summaryrefslogtreecommitdiffstats
path: root/Tests/GeneratorExpression
diff options
context:
space:
mode:
authorStefan Kislinskiy <s.kislinskiy@dkfz-heidelberg.de>2015-09-24 10:33:01 (GMT)
committerBrad King <brad.king@kitware.com>2015-09-28 14:37:33 (GMT)
commitca6ba3fee544997b72579e97f9c64eb1a24a7fc9 (patch)
tree25bf04ef772fdbaeb1eb13f14454384873e3e968 /Tests/GeneratorExpression
parent7de868c4d7c8bfe35d201ed480328f3177a1325b (diff)
downloadCMake-ca6ba3fee544997b72579e97f9c64eb1a24a7fc9.zip
CMake-ca6ba3fee544997b72579e97f9c64eb1a24a7fc9.tar.gz
CMake-ca6ba3fee544997b72579e97f9c64eb1a24a7fc9.tar.bz2
Genex: Add a SHELL_PATH expression
Some commands on Windows do not understand forward slash paths and require backslashes. In order to help projects generate shell invocations of such commands, provide a generator expression to convert paths to the shell-preferred path format for the current generator. This will allow custom commands to generate paths the same way CMake does for compiler command invocations.
Diffstat (limited to 'Tests/GeneratorExpression')
-rw-r--r--Tests/GeneratorExpression/CMakeLists.txt26
-rw-r--r--Tests/GeneratorExpression/check-part4.cmake15
2 files changed, 38 insertions, 3 deletions
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index 758165c..27f33a2 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -66,7 +66,7 @@ add_custom_target(check-part1 ALL
-Dtest_colons_4=$<1:C:\\CMake>
-Dtest_colons_5=$<1:C:/CMake>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part1.cmake
- COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 3)"
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 4)"
VERBATIM
)
@@ -137,7 +137,7 @@ add_custom_target(check-part2 ALL
-Dtest_arbitrary_content_comma_9=$<1:a,,b,,>
-Dtest_arbitrary_content_comma_10=$<1:,,a,,b,,>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part2.cmake
- COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 3)"
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 4)"
VERBATIM
)
@@ -221,7 +221,27 @@ add_custom_target(check-part3 ALL
-Dequal22=$<EQUAL:10,-012>
-Dequal23=$<EQUAL:-10,-012>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake
- COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)"
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 4)"
+ VERBATIM
+ )
+
+if(WIN32)
+ set(test_shell_path c:/shell/path)
+else()
+ set(test_shell_path /shell/path)
+endif()
+set(path_prefix BYPASS_FURTHER_CONVERSION)
+
+add_custom_target(check-part4 ALL
+ COMMAND ${CMAKE_COMMAND}
+ # Prefix path to bypass its further conversion when being processed by
+ # CMake as command-line argument
+ -Dtest_shell_path=${path_prefix}$<SHELL_PATH:${test_shell_path}>
+ -Dpath_prefix=${path_prefix}
+ -DWIN32=${WIN32}
+ -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part4.cmake
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 4 of 4)"
VERBATIM
)
diff --git a/Tests/GeneratorExpression/check-part4.cmake b/Tests/GeneratorExpression/check-part4.cmake
new file mode 100644
index 0000000..9e516d5
--- /dev/null
+++ b/Tests/GeneratorExpression/check-part4.cmake
@@ -0,0 +1,15 @@
+include(${CMAKE_CURRENT_LIST_DIR}/check-common.cmake)
+
+string(REPLACE ${path_prefix} "" test_shell_path ${test_shell_path})
+
+if(WIN32)
+ if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles")
+ check(test_shell_path [[/c/shell/path]])
+ elseif(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
+ check(test_shell_path [[c:/shell/path]])
+ else()
+ check(test_shell_path [[c:\shell\path]])
+ endif()
+else()
+ check(test_shell_path [[/shell/path]])
+endif()