TestCXXAcceptsFlag.cmake 884 B

12345678910111213141516171819202122
  1. #
  2. # Check if the CXX compiler accepts a flag
  3. #
  4. # CHECK_FUNCTION_EXISTS - macro which checks if the function exists
  5. # FLAG - the flags to try
  6. # VARIABLE - variable to store the result
  7. #
  8. MACRO(CHECK_CXX_ACCEPTS_FLAG FLAGS VARIABLE)
  9. MESSAGE(STATUS "Checking to see if CXX compiler acepts flag ${FLAGS}")
  10. TRY_COMPILE(${VARIABLE}
  11. ${CMAKE_BINARY_DIR}
  12. ${CMAKE_ROOT}/Modules/DummyCXXFile.cxx
  13. CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${FLAGS}
  14. OUTPUT_VARIABLE OUTPUT)
  15. IF(${VARIABLE})
  16. MESSAGE(STATUS "Checking to see if CXX compiler acepts flag ${FLAGS} - yes")
  17. ELSE(${VARIABLE})
  18. WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log
  19. "Determining if the CXX compiler accepts the flag ${FLAGS} failed with the following output:\n" "${OUTPUT}\n" APPEND)
  20. ENDIF(${VARIABLE})
  21. ENDMACRO(CHECK_CXX_ACCEPTS_FLAG)