mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-01 11:50:11 -05:00
VERIFY_INTERFACE_HEADER_SETS: Skip header files that have SKIP_LINTING
Fixes: #24972
This commit is contained in:
@@ -7,8 +7,9 @@ This property allows you to exclude a specific source file
|
|||||||
from the linting process. The linting process involves running
|
from the linting process. The linting process involves running
|
||||||
tools such as :prop_tgt:`<LANG>_CPPLINT`, :prop_tgt:`<LANG>_CLANG_TIDY`,
|
tools such as :prop_tgt:`<LANG>_CPPLINT`, :prop_tgt:`<LANG>_CLANG_TIDY`,
|
||||||
:prop_tgt:`<LANG>_CPPCHECK`, and :prop_tgt:`<LANG>_INCLUDE_WHAT_YOU_USE`
|
:prop_tgt:`<LANG>_CPPCHECK`, and :prop_tgt:`<LANG>_INCLUDE_WHAT_YOU_USE`
|
||||||
on the source files. By setting ``SKIP_LINTING`` on a source file,
|
on the source files, as well as compiling header files as part of
|
||||||
the mentioned linting tools will not be executed for that
|
: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.
|
particular file.
|
||||||
|
|
||||||
Example
|
Example
|
||||||
|
|||||||
@@ -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,
|
Otherwise, if C is enabled globally, the header is compiled as C. Otherwise,
|
||||||
the header file is not compiled.
|
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
|
If any verification targets are created, a top-level target called
|
||||||
``all_verify_interface_header_sets`` is created which depends on all
|
``all_verify_interface_header_sets`` is created which depends on all
|
||||||
verification targets.
|
verification targets.
|
||||||
|
|||||||
@@ -8796,6 +8796,10 @@ std::string cmGeneratorTarget::GenerateHeaderSetVerificationFile(
|
|||||||
std::string extension;
|
std::string extension;
|
||||||
std::string language = source.GetOrDetermineLanguage();
|
std::string language = source.GetOrDetermineLanguage();
|
||||||
|
|
||||||
|
if (source.GetPropertyAsBool("SKIP_LINTING")) {
|
||||||
|
return std::string{};
|
||||||
|
}
|
||||||
|
|
||||||
if (language.empty()) {
|
if (language.empty()) {
|
||||||
if (!languages) {
|
if (!languages) {
|
||||||
languages.emplace();
|
languages.emplace();
|
||||||
|
|||||||
@@ -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 lang_test_cxx_verify_interface_header_sets)
|
||||||
run_cmake_build(VerifyHeaderSets interface_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 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)
|
set(RunCMake_TEST_OPTIONS -DCMAKE_VERIFY_INTERFACE_HEADER_SETS=ON)
|
||||||
run_cmake(AllVerifyInterfaceHeaderSets)
|
run_cmake(AllVerifyInterfaceHeaderSets)
|
||||||
|
|||||||
@@ -74,3 +74,8 @@ target_sources(list INTERFACE
|
|||||||
FILE_SET error TYPE HEADERS FILES error.h
|
FILE_SET error TYPE HEADERS FILES error.h
|
||||||
)
|
)
|
||||||
set_property(TARGET list PROPERTY INTERFACE_HEADER_SETS_TO_VERIFY "a;c")
|
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)
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#error "This file should not be included"
|
||||||
|
|
||||||
|
extern void skip_linting_h(void);
|
||||||
Reference in New Issue
Block a user