compiler_introspection.cmake 865 B

1234567891011121314151617181920212223242526
  1. enable_language(CXX)
  2. set(info "")
  3. # See `Modules/Compiler/MSVC-CXX.cmake` for this. If there is explicitly no
  4. # default, the feature list is populated to be everything.
  5. if (DEFINED CMAKE_CXX_STANDARD_DEFAULT AND
  6. CMAKE_CXX_STANDARD_DEFAULT STREQUAL "")
  7. set(CMAKE_CXX_COMPILE_FEATURES "")
  8. endif ()
  9. # Detect if the environment forces a C++ standard, let the test selection know.
  10. set(forced_cxx_standard 0)
  11. if (CMAKE_CXX_FLAGS MATCHES "-std=")
  12. set(forced_cxx_standard 1)
  13. endif ()
  14. # Forward information about the C++ compile features.
  15. string(APPEND info "\
  16. set(CMAKE_CXX_COMPILE_FEATURES \"${CMAKE_CXX_COMPILE_FEATURES}\")
  17. set(CMAKE_MAKE_PROGRAM \"${CMAKE_MAKE_PROGRAM}\")
  18. set(forced_cxx_standard \"${forced_cxx_standard}\")
  19. set(CMAKE_CXX_COMPILER_VERSION \"${CMAKE_CXX_COMPILER_VERSION}\")
  20. ")
  21. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}")