summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefileTargetGenerator.cxx
diff options
context:
space:
mode:
authorPigeonF <fnoegip@gmail.com>2021-09-08 17:08:28 (GMT)
committerBrad King <brad.king@kitware.com>2021-09-10 13:53:31 (GMT)
commitccfe1b0b401863a8ac9ef07bb88ef970af587edc (patch)
tree677d05150c8e1605f2b4fe5d0df841260abc2579 /Source/cmMakefileTargetGenerator.cxx
parentcf5ed709915bde5cef4a649ca2255833cc7afcd3 (diff)
downloadCMake-ccfe1b0b401863a8ac9ef07bb88ef970af587edc.zip
CMake-ccfe1b0b401863a8ac9ef07bb88ef970af587edc.tar.gz
CMake-ccfe1b0b401863a8ac9ef07bb88ef970af587edc.tar.bz2
IWYU: Add `--driver-mode=cl` when applicable
We already do this for `clang-tidy`. Fixes: #16554
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx20
1 files changed, 19 insertions, 1 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index c83a7ab..70b6d27 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -999,7 +999,25 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
}
if (cmNonempty(iwyu)) {
run_iwyu += " --iwyu=";
- run_iwyu += this->LocalGenerator->EscapeForShell(*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=";