diff options
author | Brad King <brad.king@kitware.com> | 2021-09-14 13:35:57 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-09-14 13:36:13 (GMT) |
commit | 085719d4d8b9fbf28699fa7c3d7eee9b4b1925e5 (patch) | |
tree | ee4409806af4ff2fc2f4a067a9e1c302d423868b /Source/cmNinjaTargetGenerator.cxx | |
parent | 2a8d9bf4cc97edbf57142d96ace5c74473f76809 (diff) | |
parent | ccfe1b0b401863a8ac9ef07bb88ef970af587edc (diff) | |
download | CMake-085719d4d8b9fbf28699fa7c3d7eee9b4b1925e5.zip CMake-085719d4d8b9fbf28699fa7c3d7eee9b4b1925e5.tar.gz CMake-085719d4d8b9fbf28699fa7c3d7eee9b4b1925e5.tar.bz2 |
Merge topic 'iwyu-cl'
ccfe1b0b40 IWYU: Add `--driver-mode=cl` when applicable
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !6511
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index be8bb08..7cc1581 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -877,8 +877,26 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, compilerLauncher.clear(); } if (cmNonempty(iwyu)) { - run_iwyu += cmStrCat(" --iwyu=", - this->GetLocalGenerator()->EscapeForShell(*iwyu)); + run_iwyu += " --iwyu="; + + // Only add --driver-mode if it is not already specified, as adding + // it unconditionally might override a user-specified driver-mode + if (iwyu.Get()->find("--driver-mode=") == std::string::npos) { + cmProp p = this->Makefile->GetDefinition( + cmStrCat("CMAKE_", lang, "_INCLUDE_WHAT_YOU_USE_DRIVER_MODE")); + std::string driverMode; + + if (cmNonempty(p)) { + driverMode = *p; + } else { + driverMode = lang == "C" ? "gcc" : "g++"; + } + + run_iwyu += this->LocalGenerator->EscapeForShell( + cmStrCat(*iwyu, ";--driver-mode=", driverMode)); + } else { + run_iwyu += this->LocalGenerator->EscapeForShell(*iwyu); + } } if (cmNonempty(tidy)) { run_iwyu += " --tidy="; |