diff options
author | Brad King <brad.king@kitware.com> | 2022-07-28 12:11:51 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-07-28 12:12:09 (GMT) |
commit | 12830cc2a9a62470bcca9e06ced3ee8b370a2bd5 (patch) | |
tree | 7eeb9e2b901c0e58e73cb62e4de6cd7c39db8414 | |
parent | 75647fc53dace97d4dd03f8d5a1abfb995b4558d (diff) | |
parent | 41f15193e5adfaaf9990b2d8d81bb0ec6c05572c (diff) | |
download | CMake-12830cc2a9a62470bcca9e06ced3ee8b370a2bd5.zip CMake-12830cc2a9a62470bcca9e06ced3ee8b370a2bd5.tar.gz CMake-12830cc2a9a62470bcca9e06ced3ee8b370a2bd5.tar.bz2 |
Merge topic 'verify-interface-header-sets-interface-library-source-language' into release-3.24
41f15193e5 VERIFY_INTERFACE_HEADER_SETS: Fall back to global languages
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7517
-rw-r--r-- | Help/prop_tgt/VERIFY_INTERFACE_HEADER_SETS.rst | 4 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 6 | ||||
-rw-r--r-- | Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets.cmake | 4 |
4 files changed, 14 insertions, 1 deletions
diff --git a/Help/prop_tgt/VERIFY_INTERFACE_HEADER_SETS.rst b/Help/prop_tgt/VERIFY_INTERFACE_HEADER_SETS.rst index 1cf4a69..1b3f878 100644 --- a/Help/prop_tgt/VERIFY_INTERFACE_HEADER_SETS.rst +++ b/Help/prop_tgt/VERIFY_INTERFACE_HEADER_SETS.rst @@ -22,7 +22,9 @@ If the header's :prop_sf:`LANGUAGE` property is set, the value of that property is used to determine the language with which to compile the header file. Otherwise, if the target has any C++ sources, the header is compiled as C++. Otherwise, if the target has any C sources, the header is compiled as C. -Otherwise, the header file is not compiled. +Otherwise, if C++ is enabled globally, the header is compiled as C++. +Otherwise, if C is enabled globally, the header is compiled as C. Otherwise, +the header file is not compiled. If the project wishes to control which header sets are verified by this property, you can set :prop_tgt:`INTERFACE_HEADER_SETS_TO_VERIFY`. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 729e534..3bb8671 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -8668,6 +8668,12 @@ std::string cmGeneratorTarget::GenerateHeaderSetVerificationFile( languages->insert("C"); } } + + if (languages->empty()) { + std::vector<std::string> languagesVector; + this->GlobalGenerator->GetEnabledLanguages(languagesVector); + languages->insert(languagesVector.begin(), languagesVector.end()); + } } if (languages->count("CXX")) { diff --git a/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake b/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake index f022a43..9f9a1e7 100644 --- a/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake +++ b/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake @@ -40,6 +40,7 @@ endif() run_cmake_build(VerifyHeaderSets lang_test_c_verify_interface_header_sets) run_cmake_build(VerifyHeaderSets lang_test_cxx_verify_interface_header_sets) +run_cmake_build(VerifyHeaderSets interface_lang_test_cxx_verify_interface_header_sets) run_cmake_build(VerifyHeaderSets list_verify_interface_header_sets) set(RunCMake_TEST_OPTIONS -DCMAKE_VERIFY_INTERFACE_HEADER_SETS=ON) diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets.cmake b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets.cmake index a601491..f260609 100644 --- a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets.cmake +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets.cmake @@ -61,6 +61,10 @@ add_library(lang_test_cxx STATIC lib.c lib.cxx) target_compile_definitions(lang_test_cxx INTERFACE EXPECT_CXX) target_sources(lang_test_cxx INTERFACE FILE_SET HEADERS FILES lang_test.h) +add_library(interface_lang_test_cxx INTERFACE) +target_compile_definitions(interface_lang_test_cxx INTERFACE EXPECT_CXX) +target_sources(interface_lang_test_cxx INTERFACE FILE_SET HEADERS FILES lang_test.h) + set_property(SOURCE error.h PROPERTY LANGUAGE C) add_library(list STATIC lib.c) |