mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 15:20:56 -06:00
VERIFY_INTERFACE_HEADER_SETS: Fall back to global languages
If a target doesn't have any source files, fall back to the global list of enabled languages to determine the language of the header file to verify. Fixes: #23774
This commit is contained in:
@@ -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`.
|
||||
|
||||
@@ -8662,6 +8662,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")) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -59,6 +59,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)
|
||||
|
||||
Reference in New Issue
Block a user