diff options
author | Brad King <brad.king@kitware.com> | 2023-03-28 12:18:32 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-03-28 12:18:43 (GMT) |
commit | f4b8176447699ba82c2bf7baf2d609d0d6e3259b (patch) | |
tree | 12003372cec07b44f81a85baddcebe02451cd582 /Source | |
parent | f81cc5e2c083c7ad655abc941d1a3b7e2be33dec (diff) | |
parent | 099934e3139263b9f5bcb420c81ae7a10fdfb61e (diff) | |
download | CMake-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.cxx | 43 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 37 |
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)) { |