cmake: improve setting up runtests in Windows cross-builds

Closes #20479
This commit is contained in:
Viktor Szakats 2026-01-29 20:55:27 +01:00
parent b619952b82
commit 1acf0c45f4
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201

View file

@ -64,9 +64,17 @@ function(curl_add_runtests _targetname _test_flags)
endif()
list(APPEND _depends "testdeps")
endif()
set(_setenv "")
set(_setenvs "")
if(CMAKE_CONFIGURATION_TYPES)
set(_setenv "${CMAKE_COMMAND}" -E env "CURL_DIRSUFFIX=$<CONFIG>")
list(APPEND _setenvs "CURL_DIRSUFFIX=$<CONFIG>")
endif()
if(WIN32 AND NOT CMAKE_HOST_WIN32)
list(APPEND _setenvs "CURL_TEST_EXE_EXT_SRV=${CMAKE_EXECUTABLE_SUFFIX}") # .exe
list(APPEND _setenvs "CURL_TEST_EXE_EXT_TOOL=${CMAKE_EXECUTABLE_SUFFIX}") # .exe
list(APPEND _setenvs "CURL_TEST_EXE_RUNNER=wine")
endif()
if(_setenvs)
set(_setenvs "${CMAKE_COMMAND}" -E env ${_setenvs})
endif()
# Use a special '$TFLAGS' placeholder as last argument which will be
# replaced by the contents of the environment variable in runtests.pl.
@ -75,7 +83,7 @@ function(curl_add_runtests _targetname _test_flags)
string(REPLACE " " ";" _test_flags_list "${_test_flags}")
add_custom_target(${_targetname}
COMMAND
${_setenv}
${_setenvs}
"${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runtests.pl"
${_test_flags_list}
"\$TFLAGS"