diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2024-04-17 15:09:08 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2024-04-18 13:53:21 (GMT) |
commit | 678717f3e432ba80c2018ee2a3d7c2d20005667f (patch) | |
tree | 472466955ece76cd96d3229da6db258e707e0a69 /Tests | |
parent | 9bf79a7964d18cc32678d10305f948bb72f978d6 (diff) | |
download | CMake-678717f3e432ba80c2018ee2a3d7c2d20005667f.zip CMake-678717f3e432ba80c2018ee2a3d7c2d20005667f.tar.gz CMake-678717f3e432ba80c2018ee2a3d7c2d20005667f.tar.bz2 |
cxxmodules: provide a detection variable for `import std`
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 "\ |