summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-11-02 15:34:47 -0400
committerBrad King <brad.king@kitware.com>2022-11-02 15:47:25 -0400
commit88b14c5cf4e88bddef11ed035d6d53ae1435d990 (patch)
treee217d49084190452d921306d4408248ec835f6cf
parent82c990e9be75496e3d27203d4d092f971bf96179 (diff)
downloadcmake-88b14c5cf4e88bddef11ed035d6d53ae1435d990.tar.gz
Tests: Improve GeneratorExpression SHELL_PATH case robustness on MSYS 1.0
Since commit ca6ba3fee5 (Genex: Add a SHELL_PATH expression, 2015-09-24, v3.4.0-rc1~37^2) and commit 21da25d2a8 (Tests: Generalize GeneratorExpression MSYS path conversion workaround, 2019-03-11, v3.15.0-rc1~407^2~1) we use a prefix string to prevent the MSYS 1.0 shell from converting absolute paths of the form `/c/...` to windows-style paths. In the newer `mingw.osdn.io` distribution of MSYS 1.0, the `bash` shell now also converts paths that appear after `:`. We have no way to add a prefix string in that context, so perform the test's check of the `SHELL_PATH` genex value at generate time instead.
-rw-r--r--Tests/GeneratorExpression/CMakeLists.txt15
-rw-r--r--Tests/GeneratorExpression/check-part4.cmake9
2 files changed, 20 insertions, 4 deletions
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index ebbe28873b..61879669cb 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -261,13 +261,24 @@ else()
set(test_shell_path2 /shell/path /another/path)
endif()
+set(test_shell_path_genex "$<SHELL_PATH:${test_shell_path}>")
+set(test_shell_path2_genex "$<SHELL_PATH:${test_shell_path2}>")
+if(msys1_prefix)
+ # Add a prefix to the value produced by the genex so that the path does
+ # not look absolute, thus suppressing conversion by MSYS 1.0 bash.
+ set(test_shell_path_genex "${msys1_prefix}${test_shell_path_genex}")
+ # There is no way to suppress conversion of the second path in
+ # MSYS 1.0 bash, so do the comparison at generate time instead.
+ set(test_shell_path2_genex "$<STREQUAL:${test_shell_path2_genex},/c/shell/path:/d/another/path>")
+endif()
+
add_custom_target(check-part4 ALL
COMMAND ${msys2_no_conv} ${CMAKE_COMMAND}
# Prefix path to bypass its further conversion when being processed by
# CMake as command-line argument
-Dmsys1_prefix=${msys1_prefix}
- -Dtest_shell_path=${msys1_prefix}$<SHELL_PATH:${test_shell_path}>
- "-Dtest_shell_path2=$<SHELL_PATH:${test_shell_path2}>"
+ "-Dtest_shell_path=${test_shell_path_genex}"
+ "-Dtest_shell_path2=${test_shell_path2_genex}"
-Dif_1=$<IF:1,a,b>
-Dif_2=$<IF:0,a,b>
-Dif_3=$<IF:$<EQUAL:10,30>,a,b>
diff --git a/Tests/GeneratorExpression/check-part4.cmake b/Tests/GeneratorExpression/check-part4.cmake
index a7e09445ef..28f36996e3 100644
--- a/Tests/GeneratorExpression/check-part4.cmake
+++ b/Tests/GeneratorExpression/check-part4.cmake
@@ -16,8 +16,13 @@ else()
check(test_shell_path [[/shell/path]])
endif()
if(WIN32)
- if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles" AND NOT msys1_prefix)
- check(test_shell_path2 [[/c/shell/path:/d/another/path]])
+ if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles")
+ if(msys1_prefix)
+ # The comparison was done at generate time with the STREQUAL genex.
+ check(test_shell_path2 [[1]])
+ else()
+ check(test_shell_path2 [[/c/shell/path:/d/another/path]])
+ endif()
elseif(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
check(test_shell_path2 [[c:/shell/path;d:/another/path]])
else()