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