diff options
author | Brad King <brad.king@kitware.com> | 2024-04-19 12:51:57 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-04-19 12:52:16 (GMT) |
commit | b99bdf5a4fc1ad44cc9280a17487717bef102555 (patch) | |
tree | 51dbb4b597c1acde444860a26f8b151755707418 /Tests | |
parent | e8e1b01e194f238767ddb8a9d47154ecc38d8d44 (diff) | |
parent | 678717f3e432ba80c2018ee2a3d7c2d20005667f (diff) | |
download | CMake-b99bdf5a4fc1ad44cc9280a17487717bef102555.zip CMake-b99bdf5a4fc1ad44cc9280a17487717bef102555.tar.gz CMake-b99bdf5a4fc1ad44cc9280a17487717bef102555.tar.bz2 |
Merge topic 'cxxmodules-import-std-user-detect'
678717f3e4 cxxmodules: provide a detection variable for `import std`
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: huangqinjin <huangqinjin@gmail.com>
Merge-request: !9442
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/CXXModules/Inspect.cmake | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Tests/RunCMake/CXXModules/Inspect.cmake b/Tests/RunCMake/CXXModules/Inspect.cmake index 1597bd8..e648e8c 100644 --- a/Tests/RunCMake/CXXModules/Inspect.cmake +++ b/Tests/RunCMake/CXXModules/Inspect.cmake @@ -15,10 +15,21 @@ if (CMAKE_CXX_FLAGS MATCHES "-std=") set(forced_cxx_standard 1) endif () -set(have_cxx23_import_std 0) -if (TARGET "__CMAKE::CXX23") - set(have_cxx23_import_std 1) -endif () +macro (cxx_check_import_std version) + set(have_cxx${version}_import_std 0) + if ("${version}" IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD) + set(have_cxx${version}_import_std 1) + endif () + + if (TARGET "__CMAKE:CXX${version}" AND NOT have_cxx${version}_import_std) + message(FATAL_ERROR + "The toolchain's C++${version} target exists, but the user variable does " + "not indicate it.") + endif () +endmacro () + +cxx_check_import_std(23) +cxx_check_import_std(26) # Forward information about the C++ compile features. string(APPEND info "\ |