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