diff options
author | Orkun Tokdemir <ilhanorkuntokdemir@gmail.com> | 2023-05-12 14:49:03 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-05-16 14:47:56 (GMT) |
commit | b480315e0c229454c335290b19cc689930d7849f (patch) | |
tree | fd6c95e7d53d4a9c095947ba7cd718e0ce1ae60f /Source | |
parent | 993dde925f208d98c68edcd451b0d6979e0abdd4 (diff) | |
download | CMake-b480315e0c229454c335290b19cc689930d7849f.zip CMake-b480315e0c229454c335290b19cc689930d7849f.tar.gz CMake-b480315e0c229454c335290b19cc689930d7849f.tar.bz2 |
TargetGenerator: Add SKIP_LINTING source property
The `SKIP_LINTING` source property was added to disable code check for
desired source files. The `SKIP_LINTING`includes `cpplint`, `clang-tidy`, \
`cppcheck` and `include-what-you-use`. If `SKIP_LINTING` is set on a
source file, the tools mentioned above will not be run on that source file.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 11 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 18 |
2 files changed, 18 insertions, 11 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1cf3b8b..c915e26 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1057,10 +1057,13 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( compilerLauncher = GetCompilerLauncher(lang, config); } - std::string const codeCheck = this->GenerateCodeCheckRules( - source, compilerLauncher, "$(CMAKE_COMMAND)", config, nullptr); - if (!codeCheck.empty()) { - compileCommands.front().insert(0, codeCheck); + cmValue const skipCodeCheck = source.GetProperty("SKIP_LINTING"); + if (!skipCodeCheck.IsOn()) { + std::string const codeCheck = this->GenerateCodeCheckRules( + source, compilerLauncher, "$(CMAKE_COMMAND)", config, nullptr); + if (!codeCheck.empty()) { + compileCommands.front().insert(0, codeCheck); + } } // If compiler launcher was specified and not consumed above, it diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cad4bf4..25e00d3 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1219,15 +1219,19 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( vars["FLAGS"] = this->ComputeFlagsForObject(source, language, config); vars["DEFINES"] = this->ComputeDefines(source, language, config); vars["INCLUDES"] = this->ComputeIncludes(source, language, config); - auto const cmakeCmd = this->GetLocalGenerator()->ConvertToOutputFormat( - cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); auto compilerLauncher = this->GetCompilerLauncher(language, config); - vars["CODE_CHECK"] = - this->GenerateCodeCheckRules(*source, compilerLauncher, cmakeCmd, config, - [this](std::string const& path) { - return this->ConvertToNinjaPath(path); - }); + + cmValue const skipCodeCheck = source->GetProperty("SKIP_LINTING"); + if (!skipCodeCheck.IsOn()) { + auto const cmakeCmd = this->GetLocalGenerator()->ConvertToOutputFormat( + cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); + vars["CODE_CHECK"] = + this->GenerateCodeCheckRules(*source, compilerLauncher, cmakeCmd, config, + [this](const std::string& path) { + return this->ConvertToNinjaPath(path); + }); + } // If compiler launcher was specified and not consumed above, it // goes to the beginning of the command line. |