CMakeLists.txt 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile" AND
  2. NOT CMake_TEST_NO_FindPackageModeMakefileTest)
  3. # Test whether the make is GNU make, and only add the test in this case,
  4. # since the configured makefile in this test uses $(shell ...), which
  5. # is AFAIK a GNU make extension. Alex
  6. execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} -v
  7. OUTPUT_VARIABLE makeVersionOutput
  8. ERROR_QUIET
  9. TIMEOUT 10)
  10. string(TOUPPER "${makeVersionOutput}" MAKE_VERSION_OUTPUT)
  11. if("${MAKE_VERSION_OUTPUT}" MATCHES "GNU MAKE")
  12. # build a library which we can search during the test
  13. add_library(foo STATIC foo.cpp)
  14. # configure a FindFoo.cmake so it knows where the library can be found
  15. configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY)
  16. # now set up the test:
  17. file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk"
  18. CONTENT "CMAKE = \"$<TARGET_FILE:cmake>\"\n"
  19. )
  20. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY)
  21. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY)
  22. add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile )
  23. endif()
  24. endif()