summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaTargetGenerator.cxx
diff options
context:
space:
mode:
authorHanjiang Yu <42531996+de1acr0ix@users.noreply.github.com>2020-01-19 08:39:18 (GMT)
committerBrad King <brad.king@kitware.com>2020-01-27 18:59:05 (GMT)
commitf6f4eb090714df50b77b164bbd5bb65a8ce59cbc (patch)
treedeb85ea2868c93016388410f8b22750aeb7323f3 /Source/cmNinjaTargetGenerator.cxx
parent33e7bd66c09ee51edbbccfc1014813e30d80ec5f (diff)
downloadCMake-f6f4eb090714df50b77b164bbd5bb65a8ce59cbc.zip
CMake-f6f4eb090714df50b77b164bbd5bb65a8ce59cbc.tar.gz
CMake-f6f4eb090714df50b77b164bbd5bb65a8ce59cbc.tar.bz2
clang-tidy: Add driver mode argument
`clang-tidy` does not infer driver mode if it is not provided with a JSON compilation database. This is exactly the way cmake launches it. Hence clang-tidy will only use the default driver mode. Add an explicit driver mode argument to avoid this.
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx8
1 files changed, 7 insertions, 1 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 455d809..5a9f74c 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -759,7 +759,13 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
}
if (tidy && *tidy) {
run_iwyu += " --tidy=";
- run_iwyu += this->GetLocalGenerator()->EscapeForShell(tidy);
+ const char* driverMode = this->Makefile->GetDefinition(
+ "CMAKE_" + lang + "_CLANG_TIDY_DRIVER_MODE");
+ if (!(driverMode && *driverMode)) {
+ driverMode = lang == "C" ? "gcc" : "g++";
+ }
+ run_iwyu += this->GetLocalGenerator()->EscapeForShell(
+ cmStrCat(tidy, ";--driver-mode=", driverMode));
}
if (cpplint && *cpplint) {
run_iwyu += " --cpplint=";