CMP0128-common.cmake 730 B

12345678910111213141516171819202122232425262728293031
  1. cmake_policy(SET CMP0067 NEW)
  2. enable_language(CXX)
  3. # Isolate the one try_compile below in the error log.
  4. set(CMakeError_log "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log")
  5. file(REMOVE "${CMakeError_log}")
  6. # Add our own -std= flag to the try_compile check.
  7. set(CMAKE_REQUIRED_FLAGS -std=c++11)
  8. # Tell CMP0128 NEW behavior to append a -std= flag (after ours).
  9. if(CMAKE_CXX_EXTENSIONS_DEFAULT)
  10. set(CMAKE_CXX_EXTENSIONS OFF)
  11. else()
  12. set(CMAKE_CXX_EXTENSIONS ON)
  13. endif()
  14. include(CheckSourceCompiles)
  15. check_source_compiles(CXX "
  16. ${check_cxx_std}
  17. int main()
  18. {
  19. return 0;
  20. }
  21. " SRC_COMPILED)
  22. if(NOT SRC_COMPILED)
  23. if(EXISTS "${CMakeError_log}")
  24. file(READ "${CMakeError_log}" err_log)
  25. endif()
  26. message("${err_log}")
  27. endif()