summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefileTargetGenerator.cxx
diff options
context:
space:
mode:
authorStefan Schober <stenny.schober@gmail.com>2023-03-24 15:06:33 (GMT)
committerBrad King <brad.king@kitware.com>2023-03-27 15:48:41 (GMT)
commit099934e3139263b9f5bcb420c81ae7a10fdfb61e (patch)
treec1a19abd5462b53cc4602041d9eb207d515f933b /Source/cmMakefileTargetGenerator.cxx
parentc4c4ca0e87a900bf077b05b79b9a2198ec7493d6 (diff)
downloadCMake-099934e3139263b9f5bcb420c81ae7a10fdfb61e.zip
CMake-099934e3139263b9f5bcb420c81ae7a10fdfb61e.tar.gz
CMake-099934e3139263b9f5bcb420c81ae7a10fdfb61e.tar.bz2
Add generator expression support to static code analysis hooks
Teach target properties `<LANG>_CPPCHECK`, `<LANG>_CPPLINT`, `<LANG>_CLANG_TIDY` and `<LANG>_INCLUDE_WHAT_YOU_USE` to accept generator expressions.
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx43
1 files changed, 38 insertions, 5 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index e6f8cdd..3112acd 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1067,18 +1067,51 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
// Maybe insert an include-what-you-use runner.
if (!compileCommands.empty() &&
(lang == "C" || lang == "CXX" || lang == "OBJC" || lang == "OBJCXX")) {
- std::string const tidy_prop = lang + "_CLANG_TIDY";
- cmValue tidy = this->GeneratorTarget->GetProperty(tidy_prop);
+ cmValue tidy = nullptr;
cmValue iwyu = nullptr;
cmValue cpplint = nullptr;
cmValue cppcheck = nullptr;
+ std::string evaluatedTIDY;
+ std::string evaluatedIWYU;
+ std::string evaluatedCPPlint;
+ std::string evaluatedCPPcheck;
+
+ std::string const tidy_prop = cmStrCat(lang, "_CLANG_TIDY");
+ tidy = this->GeneratorTarget->GetProperty(tidy_prop);
+ evaluatedTIDY = cmGeneratorExpression::Evaluate(
+ *tidy, this->LocalGenerator, config, this->GeneratorTarget, nullptr,
+ this->GeneratorTarget, lang);
+ if (!evaluatedTIDY.empty()) {
+ tidy = cmValue(&evaluatedTIDY);
+ }
+
if (lang == "C" || lang == "CXX") {
- std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE";
+ std::string const iwyu_prop = cmStrCat(lang, "_INCLUDE_WHAT_YOU_USE");
iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
- std::string const cpplint_prop = lang + "_CPPLINT";
+ evaluatedIWYU = cmGeneratorExpression::Evaluate(
+ *iwyu, this->LocalGenerator, config, this->GeneratorTarget, nullptr,
+ this->GeneratorTarget, lang);
+ if (!evaluatedIWYU.empty()) {
+ iwyu = cmValue(&evaluatedIWYU);
+ }
+
+ std::string const cpplint_prop = cmStrCat(lang, "_CPPLINT");
cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
- std::string const cppcheck_prop = lang + "_CPPCHECK";
+ evaluatedCPPlint = cmGeneratorExpression::Evaluate(
+ *cpplint, this->LocalGenerator, config, this->GeneratorTarget,
+ nullptr, this->GeneratorTarget, lang);
+ if (!evaluatedCPPlint.empty()) {
+ cpplint = cmValue(&evaluatedCPPlint);
+ }
+
+ std::string const cppcheck_prop = cmStrCat(lang, "_CPPCHECK");
cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
+ evaluatedCPPcheck = cmGeneratorExpression::Evaluate(
+ *cppcheck, this->LocalGenerator, config, this->GeneratorTarget,
+ nullptr, this->GeneratorTarget, lang);
+ if (!evaluatedCPPcheck.empty()) {
+ cppcheck = cmValue(&evaluatedCPPcheck);
+ }
}
if (cmNonempty(iwyu) || cmNonempty(tidy) || cmNonempty(cpplint) ||
cmNonempty(cppcheck)) {