VERIFY_INTERFACE_HEADER_SETS: Skip header files that have SKIP_LINTING

Fixes: #24972
This commit is contained in:
Kyle Edwards
2023-06-05 16:42:12 -04:00
parent 3760ac9845
commit 36ec89639a
6 changed files with 19 additions and 2 deletions

View File

@@ -7,8 +7,9 @@ This property allows you to exclude a specific source file
from the linting process. The linting process involves running
tools such as :prop_tgt:`<LANG>_CPPLINT`, :prop_tgt:`<LANG>_CLANG_TIDY`,
:prop_tgt:`<LANG>_CPPCHECK`, and :prop_tgt:`<LANG>_INCLUDE_WHAT_YOU_USE`
on the source files. By setting ``SKIP_LINTING`` on a source file,
the mentioned linting tools will not be executed for that
on the source files, as well as compiling header files as part of
:prop_tgt:`VERIFY_INTERFACE_HEADER_SETS`. By setting ``SKIP_LINTING`` on a
source file, the mentioned linting tools will not be executed for that
particular file.
Example

View File

@@ -26,6 +26,9 @@ 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 header's :prop_sf:`SKIP_LINTING` property is set to true, the file is
not compiled.
If any verification targets are created, a top-level target called
``all_verify_interface_header_sets`` is created which depends on all
verification targets.

View File

@@ -8796,6 +8796,10 @@ std::string cmGeneratorTarget::GenerateHeaderSetVerificationFile(
std::string extension;
std::string language = source.GetOrDetermineLanguage();
if (source.GetPropertyAsBool("SKIP_LINTING")) {
return std::string{};
}
if (language.empty()) {
if (!languages) {
languages.emplace();

View File

@@ -42,6 +42,7 @@ 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)
run_cmake_build(VerifyHeaderSets skip_linting_verify_interface_header_sets)
set(RunCMake_TEST_OPTIONS -DCMAKE_VERIFY_INTERFACE_HEADER_SETS=ON)
run_cmake(AllVerifyInterfaceHeaderSets)

View File

@@ -74,3 +74,8 @@ target_sources(list INTERFACE
FILE_SET error TYPE HEADERS FILES error.h
)
set_property(TARGET list PROPERTY INTERFACE_HEADER_SETS_TO_VERIFY "a;c")
add_library(skip_linting STATIC lib.c)
target_sources(skip_linting INTERFACE FILE_SET HEADERS FILES lang_test.h skip_linting.h)
set_property(SOURCE skip_linting.h PROPERTY LANGUAGE C)
set_property(SOURCE skip_linting.h PROPERTY SKIP_LINTING TRUE)

View File

@@ -0,0 +1,3 @@
#error "This file should not be included"
extern void skip_linting_h(void);