diff options
author | Brad King <brad.king@kitware.com> | 2015-05-18 14:39:25 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-05-19 13:16:29 -0400 |
commit | ada5ffce7bad40c56e5d0dd76b9a7b30c96a9e92 (patch) | |
tree | 31755e49ec06997658c4cc24ef3ae33f1b3869df /Source/cmNinjaTargetGenerator.cxx | |
parent | 67fa3da9e84888029d128280f35a8e7b3d208377 (diff) | |
download | cmake-ada5ffce7bad40c56e5d0dd76b9a7b30c96a9e92.tar.gz |
Add options to run include-what-you-use with the compiler
Create a <LANG>_INCLUDE_WHAT_YOU_USE target property (initialized by a
CMAKE_<LANG>_INCLUDE_WHAT_YOU_USE variable) to specify an IWYU command
line to be run along with the compiler.
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cdc9cc8c70..879d6b79e0 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -458,6 +458,23 @@ cmNinjaTargetGenerator std::vector<std::string> compileCmds; cmSystemTools::ExpandListArgument(compileCmd, compileCmds); + // Maybe insert an include-what-you-use runner. + if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) + { + std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE"; + const char *iwyu = this->Target->GetProperty(iwyu_prop); + if (iwyu && *iwyu) + { + 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 += " -- "; + compileCmds.front().insert(0, run_iwyu); + } + } + if (!compileCmds.empty()) { compileCmds.front().insert(0, cldeps); |