From 88b14c5cf4e88bddef11ed035d6d53ae1435d990 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 2 Nov 2022 15:34:47 -0400 Subject: 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. --- Tests/GeneratorExpression/CMakeLists.txt | 15 +++++++++++++-- Tests/GeneratorExpression/check-part4.cmake | 9 +++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index ebbe288..6187966 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 "$") +set(test_shell_path2_genex "$") +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 "$") +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}$ - "-Dtest_shell_path2=$" + "-Dtest_shell_path=${test_shell_path_genex}" + "-Dtest_shell_path2=${test_shell_path2_genex}" -Dif_1=$ -Dif_2=$ -Dif_3=$,a,b> diff --git a/Tests/GeneratorExpression/check-part4.cmake b/Tests/GeneratorExpression/check-part4.cmake index a7e0944..28f3699 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() -- cgit v0.12