1 # - Test CXX compiler for a flag
2 # Check if the CXX compiler accepts a flag
4 # Macro CHECK_CXX_ACCEPTS_FLAG(FLAGS VARIABLE) -
5 # checks if the function exists
6 # FLAGS - the flags to try
7 # VARIABLE - variable to store the result
10 MACRO(CHECK_CXX_ACCEPTS_FLAG FLAGS VARIABLE)
11 IF(NOT DEFINED ${VARIABLE})
12 MESSAGE(STATUS "Checking to see if CXX compiler accepts flag ${FLAGS}")
13 TRY_COMPILE(${VARIABLE}
15 ${CMAKE_ROOT}/Modules/DummyCXXFile.cxx
16 CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${FLAGS}
17 OUTPUT_VARIABLE OUTPUT)
19 MESSAGE(STATUS "Checking to see if CXX compiler accepts flag ${FLAGS} - yes")
20 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
21 "Determining if the CXX compiler accepts the flag ${FLAGS} passed with "
22 "the following output:\n${OUTPUT}\n\n")
24 MESSAGE(STATUS "Checking to see if CXX compiler accepts flag ${FLAGS} - no")
25 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
26 "Determining if the CXX compiler accepts the flag ${FLAGS} failed with "
27 "the following output:\n${OUTPUT}\n\n")
29 ENDIF(NOT DEFINED ${VARIABLE})
30 ENDMACRO(CHECK_CXX_ACCEPTS_FLAG)