From 21da25d2a878cfccf9496ef7b227de2c98601ef2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 11 Mar 2019 10:43:38 -0400 Subject: Tests: Generalize GeneratorExpression MSYS path conversion workaround Use MSYS2's `MSYS2_ARG_CONV_EXCL` environment variable to prevent path conversion where possible. --- Tests/GeneratorExpression/CMakeLists.txt | 28 +++++++++++++++++++++------- Tests/GeneratorExpression/check-part4.cmake | 4 +++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 3d08704..ab6016b 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -3,11 +3,26 @@ project(GeneratorExpression) include(CTest) +# Real projects normally want the MSYS shell path conversion, but for this test +# we need to verify that the command line is constructed with the proper string. +set(msys1_prefix "") +set(msys2_no_conv "") +if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles") + execute_process(COMMAND "uname" OUTPUT_VARIABLE uname) + if("${uname}" MATCHES "^MINGW32") + # MinGW.org MSYS 1.0 does not support generic path conversion suppression + set(msys1_prefix MSYS1_PREFIX) + else() + # msys2 supports generic path conversion suppression + set(msys2_no_conv env MSYS2_ARG_CONV_EXCL=-D) + endif() +endif() + # This test is split into multiple parts as needed to avoid NMake command # length limits. add_custom_target(check-part1 ALL - COMMAND ${CMAKE_COMMAND} + COMMAND ${msys2_no_conv} ${CMAKE_COMMAND} -Dtest_0=$<0:nothing> -Dtest_0_with_comma=$<0:-Wl,--no-undefined> -Dtest_1=$<1:content> @@ -97,7 +112,7 @@ add_library(empty5 empty.cpp) target_include_directories(empty5 PRIVATE /empty5/private1 /empty5/private2) add_custom_target(check-part2 ALL - COMMAND ${CMAKE_COMMAND} + COMMAND ${msys2_no_conv} ${CMAKE_COMMAND} -Dtest_incomplete_1=$< -Dtest_incomplete_2=$ -Dtest_version_greater_2=$ -Dtest_version_less_1=$ @@ -244,14 +259,13 @@ if(WIN32) else() set(test_shell_path /shell/path) endif() -set(path_prefix BYPASS_FURTHER_CONVERSION) add_custom_target(check-part4 ALL - COMMAND ${CMAKE_COMMAND} + COMMAND ${msys2_no_conv} ${CMAKE_COMMAND} # Prefix path to bypass its further conversion when being processed by # CMake as command-line argument - -Dtest_shell_path=${path_prefix}$ - -Dpath_prefix=${path_prefix} + -Dmsys1_prefix=${msys1_prefix} + -Dtest_shell_path=${msys1_prefix}$ -Dif_1=$ -Dif_2=$ -Dif_3=$,a,b> diff --git a/Tests/GeneratorExpression/check-part4.cmake b/Tests/GeneratorExpression/check-part4.cmake index f5d14dd..b6966de 100644 --- a/Tests/GeneratorExpression/check-part4.cmake +++ b/Tests/GeneratorExpression/check-part4.cmake @@ -1,6 +1,8 @@ include(${CMAKE_CURRENT_LIST_DIR}/check-common.cmake) -string(REPLACE ${path_prefix} "" test_shell_path ${test_shell_path}) +if(msys1_prefix) + string(REPLACE "${msys1_prefix}" "" test_shell_path ${test_shell_path}) +endif() if(WIN32) if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles") -- cgit v0.12