summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaTargetGenerator.cxx
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2016-04-08 20:09:27 (GMT)
committerBrad King <brad.king@kitware.com>2016-04-13 13:56:10 (GMT)
commit5e62444cff5ead280a111c116a3fe810181379cf (patch)
tree83764d54d99f246c011defdd49e0ccfa658f8fd6 /Source/cmNinjaTargetGenerator.cxx
parent9ac11bc25d6b9f5e7db786034f922d96613e6143 (diff)
downloadCMake-5e62444cff5ead280a111c116a3fe810181379cf.zip
CMake-5e62444cff5ead280a111c116a3fe810181379cf.tar.gz
CMake-5e62444cff5ead280a111c116a3fe810181379cf.tar.bz2
Add options to run clang-tidy with the compiler
Create a <LANG>_CLANG_TIDY target property (initialized by a CMAKE_<LANG>_CLANG_TIDY variable) to specify a clang-tidy command line to be run along with the compiler.
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx18
1 files changed, 15 insertions, 3 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 753a5ae..fd1d16d 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -419,13 +419,25 @@ cmNinjaTargetGenerator
{
std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE";
const char *iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
- if (iwyu && *iwyu)
+ std::string const tidy_prop = lang + "_CLANG_TIDY";
+ const char *tidy = this->GeneratorTarget->GetProperty(tidy_prop);
+ if ((iwyu && *iwyu) || (tidy && *tidy))
{
std::string run_iwyu =
this->GetLocalGenerator()->ConvertToOutputFormat(
cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
- run_iwyu += " -E __run_iwyu --iwyu=";
- run_iwyu += this->GetLocalGenerator()->EscapeForShell(iwyu);
+ run_iwyu += " -E __run_iwyu";
+ if (iwyu && *iwyu)
+ {
+ run_iwyu += " --iwyu=";
+ run_iwyu += this->GetLocalGenerator()->EscapeForShell(iwyu);
+ }
+ if (tidy && *tidy)
+ {
+ run_iwyu += " --tidy=";
+ run_iwyu += this->GetLocalGenerator()->EscapeForShell(tidy);
+ run_iwyu += " --source=$in";
+ }
run_iwyu += " -- ";
compileCmds.front().insert(0, run_iwyu);
}