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 efc2c5184d #14124
Cherry-picked from #14097
Closes #14129
This commit is contained in:
parent
d2ef6255f4
commit
c09db8b51b
@ -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")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user