CheckCXXCompilerFlag.cmake 515 B

1234567891011121314151617
  1. enable_language (CXX)
  2. include(CheckCompilerFlag)
  3. set(CXX 1) # test that this is tolerated
  4. check_compiler_flag(CXX "-_this_is_not_a_flag_" SHOULD_FAIL)
  5. if(SHOULD_FAIL)
  6. message(SEND_ERROR "invalid CXX compile flag didn't fail.")
  7. endif()
  8. if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
  9. check_compiler_flag(CXX "-x c++" SHOULD_WORK)
  10. if(NOT SHOULD_WORK)
  11. message(SEND_ERROR "${CMAKE_CXX_COMPILER_ID} compiler flag '-x c++' check failed")
  12. endif()
  13. endif()