46 lines
1.7 KiB
CMake
Raw Normal View History

2012-02-18 12:40:36 +02:00
2016-07-09 11:21:54 +02:00
if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile" AND
NOT CMake_TEST_NO_FindPackageModeMakefileTest)
2012-02-18 12:40:36 +02:00
# Test whether the make is GNU make, and only add the test in this case,
# since the configured makefile in this test uses $(shell ...), which
# is AFAIK a GNU make extension. Alex
execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} -v
OUTPUT_VARIABLE makeVersionOutput
ERROR_QUIET
TIMEOUT 10)
string(TOUPPER "${makeVersionOutput}" MAKE_VERSION_OUTPUT)
2015-04-27 22:25:09 +02:00
if("${MAKE_VERSION_OUTPUT}" MATCHES "GNU MAKE")
2012-02-18 12:40:36 +02:00
# build a library which we can search during the test
add_library(foo STATIC foo.cpp)
# configure a FindFoo.cmake so it knows where the library can be found
configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY)
2021-09-14 00:13:48 +02:00
set(EXTRA_FLAGS "")
if(APPLE)
# Need the -isysroot flag on recentish macOS after command line tools
# no longer provide headers in /usr/include
if(CMAKE_OSX_SYSROOT)
string(APPEND EXTRA_FLAGS " -isysroot ${CMAKE_OSX_SYSROOT}")
endif()
foreach(arch ${CMAKE_OSX_ARCHITECTURES})
string(APPEND EXTRA_FLAGS " -arch ${arch}")
endforeach()
2020-08-30 11:54:41 +02:00
endif()
2012-02-18 12:40:36 +02:00
# now set up the test:
2017-04-14 19:02:05 +02:00
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk"
CONTENT "CMAKE = \"$<TARGET_FILE:cmake>\"\n"
)
2012-02-18 12:40:36 +02:00
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY)
add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile )
endif()
endif()