diff options
author | Brad King <brad.king@kitware.com> | 2024-12-09 17:27:44 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-12-09 19:57:35 (GMT) |
commit | 30139913e99db6cc23ae3dd002cdc9f07d2b891b (patch) | |
tree | 89de25bcc09c9d701326297ea8778b6887fef001 /Tests | |
parent | 57da8712c1527fa697e65dc823b09fb9de570d89 (diff) | |
download | CMake-30139913e99db6cc23ae3dd002cdc9f07d2b891b.zip CMake-30139913e99db6cc23ae3dd002cdc9f07d2b891b.tar.gz CMake-30139913e99db6cc23ae3dd002cdc9f07d2b891b.tar.bz2 |
VS: Restore support for mixing C++23 and C in one target with clang-cl
Since commit 474eafe28c (clang-cl: Add support for C++23, 2024-09-13,
v3.31.0-rc1~97^2) we use a Clang-specific flag to enable C++23 since
`clang-cl` has no `-std:c++23` flag, and `-std:c++latest` may enable an
even newer version of C++. However, in `.vcxproj` files there is no way
to express a target-wide `-clang:-std=c++23` flag for only C++ sources
when the target also has C sources. Add a special case to map back to
`-std:c++latest` for targets with C++23 and C together.
Fixes: #26508
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CompileFeatures/CMakeLists.txt | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 7fc5e85..29174e5 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -32,6 +32,12 @@ foreach(lang C CXX CUDA HIP) endforeach() endforeach() +if(("23" IN_LIST CMake_TEST_CXX_STANDARDS OR CMAKE_CXX23_STANDARD_COMPILE_OPTION) + AND ("11" IN_LIST CMake_TEST_C_STANDARDS OR CMAKE_C11_STANDARD_COMPILE_OPTION)) + add_library(test_cxx_std_23_with_c_std_11 OBJECT cxx_std_23.cpp c_std_11.c) + target_compile_features(test_cxx_std_23_with_c_std_11 PRIVATE cxx_std_23 c_std_11) +endif() + macro(run_test feature lang) if (${feature} IN_LIST CMAKE_${lang}_COMPILE_FEATURES) add_library(test_${feature} OBJECT ${feature}.${ext_${lang}}) |