summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaTargetGenerator.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2017-08-16 16:24:44 (GMT)
committerBrad King <brad.king@kitware.com>2017-08-30 14:23:46 (GMT)
commit311b7b1a7095ec460fab950a6767571eb3b9652c (patch)
tree23843c9cd26d9d150e76fadda88a8fbf47d5f12c /Source/cmNinjaTargetGenerator.cxx
parentfff28e30cd01a88b2e5f67db2aaf4c068f1bfc89 (diff)
downloadCMake-311b7b1a7095ec460fab950a6767571eb3b9652c.zip
CMake-311b7b1a7095ec460fab950a6767571eb3b9652c.tar.gz
CMake-311b7b1a7095ec460fab950a6767571eb3b9652c.tar.bz2
Add properties to run cppcheck along with the compiler
Create a `<LANG>_CPPCHECK` target property (initialized by a `CMAKE_<LANG>_CPPCHECK` variable) to specify a `cppcheck` command line to be run along with the compiler.
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx12
1 files changed, 10 insertions, 2 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 4a4e5b2..b08c19b 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -617,7 +617,10 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
const char* tidy = this->GeneratorTarget->GetProperty(tidy_prop);
std::string const cpplint_prop = lang + "_CPPLINT";
const char* cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
- if ((iwyu && *iwyu) || (tidy && *tidy) || (cpplint && *cpplint)) {
+ std::string const cppcheck_prop = lang + "_CPPCHECK";
+ const char* cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
+ if ((iwyu && *iwyu) || (tidy && *tidy) || (cpplint && *cpplint) ||
+ (cppcheck && *cppcheck)) {
std::string run_iwyu = this->GetLocalGenerator()->ConvertToOutputFormat(
cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
run_iwyu += " -E __run_iwyu";
@@ -633,7 +636,12 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
run_iwyu += " --cpplint=";
run_iwyu += this->GetLocalGenerator()->EscapeForShell(cpplint);
}
- if ((tidy && *tidy) || (cpplint && *cpplint)) {
+ if (cppcheck && *cppcheck) {
+ run_iwyu += " --cppcheck=";
+ run_iwyu += this->GetLocalGenerator()->EscapeForShell(cppcheck);
+ }
+ if ((tidy && *tidy) || (cpplint && *cpplint) ||
+ (cppcheck && *cppcheck)) {
run_iwyu += " --source=$in";
}
run_iwyu += " -- ";