summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-28 12:18:32 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-03-28 12:18:43 (GMT)
commitf4b8176447699ba82c2bf7baf2d609d0d6e3259b (patch)
tree12003372cec07b44f81a85baddcebe02451cd582 /Source
parentf81cc5e2c083c7ad655abc941d1a3b7e2be33dec (diff)
parent099934e3139263b9f5bcb420c81ae7a10fdfb61e (diff)
downloadCMake-f4b8176447699ba82c2bf7baf2d609d0d6e3259b.zip
CMake-f4b8176447699ba82c2bf7baf2d609d0d6e3259b.tar.gz
CMake-f4b8176447699ba82c2bf7baf2d609d0d6e3259b.tar.bz2
Merge topic 'lint-genex'
099934e313 Add generator expression support to static code analysis hooks Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !8361
Diffstat (limited to 'Source')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx43
-rw-r--r--Source/cmNinjaTargetGenerator.cxx37
2 files changed, 73 insertions, 7 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)) {
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 4c0f935..e163edb 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -908,18 +908,51 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
// Maybe insert an include-what-you-use runner.
if (!compileCmds.empty() &&
(lang == "C" || lang == "CXX" || lang == "OBJC" || lang == "OBJCXX")) {
- std::string const tidy_prop = cmStrCat(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 = cmStrCat(lang, "_INCLUDE_WHAT_YOU_USE");
iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
+ 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);
+ 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)) {