From: Viktor Szakats Date: Mon, 8 Jul 2024 16:32:34 +0000 (+0200) Subject: cmake: create `configurehelp.pm` like autotools does X-Git-Tag: curl-8_9_0~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c09db8b51b88ee6ad55bd637dcb4b47678e30906;p=thirdparty%2Fcurl.git cmake: create `configurehelp.pm` like autotools does Required by tests 1119 and 1167 to run a C preprocessor. Tested OK: https://github.com/curl/curl/actions/runs/9915343826 Besides Apple, it also supports any gcc and clang builds, and MSVC. For other platforms, it defaults to `cpp` (like autotools). Follow-up to efc2c5184d008fe2e5910fd03263e1ab0331d4e6 #14124 Cherry-picked from #14097 Closes #14129 --- diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 82c6511671..53e39e01b4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -45,6 +45,45 @@ function(add_runtests targetname test_flags) ) endfunction() +# Create configurehelp.pm, used by tests needing to run the C preprocessor. +if(MSVC OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") + set(_cpp_cmd "\"${CMAKE_C_COMPILER}\" -E") + if(APPLE AND NOT CMAKE_OSX_SYSROOT STREQUAL "") + set(_cpp_cmd "${_cpp_cmd} -isysroot ${CMAKE_OSX_SYSROOT}") + endif() + # Add header directories, like autotools builds do. + get_property(_include_dirs TARGET ${LIB_SELECTED} PROPERTY INCLUDE_DIRECTORIES) + foreach(_include_dir IN LISTS _include_dirs) + set(_cpp_cmd "${_cpp_cmd} -I${_include_dir}") + endforeach() +else() + set(_cpp_cmd "cpp") +endif() +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/configurehelp.pm" "# This is a generated file. Do not edit. + +package configurehelp; + +use strict; +use warnings; +use Exporter; + +use vars qw( + @ISA + @EXPORT_OK + \$Cpreprocessor + ); + +@ISA = qw(Exporter); + +@EXPORT_OK = qw( + \$Cpreprocessor + ); + +\$Cpreprocessor = '${_cpp_cmd}'; + +1; +") + add_runtests(test-quiet "-a -s") add_runtests(test-am "-a -am") add_runtests(test-full "-a -p -r")