CheckCCompilerFlag.cmake 741 B

123456789101112131415161718192021
  1. # - Check whether the C compiler supports a given flag.
  2. # CHECK_C_COMPILER_FLAG(FLAG VARIABLE)
  3. #
  4. # FLAG - the compiler flag
  5. # VARIABLE - variable to store the result
  6. # Copyright (c) 2006, Alexander Neundorf, <[email protected]>
  7. #
  8. # Redistribution and use is allowed according to the terms of the BSD license.
  9. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  10. INCLUDE(CheckCSourceCompiles)
  11. MACRO (CHECK_C_COMPILER_FLAG _FLAG _RESULT)
  12. SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
  13. SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
  14. CHECK_C_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT})
  15. SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
  16. ENDMACRO (CHECK_C_COMPILER_FLAG)