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.
This commit is contained in:
Brad King
2022-11-02 15:34:47 -04:00
parent 82c990e9be
commit 88b14c5cf4
2 changed files with 20 additions and 4 deletions

View File

@@ -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>

View File

@@ -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()