summaryrefslogtreecommitdiff
path: root/Source/cmMakefileTargetGenerator.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2015-06-04 15:56:56 -0400
committerBrad King <brad.king@kitware.com>2015-06-15 09:36:48 -0400
commit698f75971bee336133d21260db069bb139bd3d76 (patch)
treebb84e66564527d57821a0268053e2ddfd2fce571 /Source/cmMakefileTargetGenerator.cxx
parentd3bb5da9294ddbfcc5fddf7ba3dafd2c3e0b32b2 (diff)
downloadcmake-698f75971bee336133d21260db069bb139bd3d76.tar.gz
Add options to launch the compiler through tools like ccache or distcc
Create a <LANG>_COMPILER_LAUNCHER target property (initialized by a CMAKE_<LANG>_COMPILER_LAUNCHER variable) to specify a compiler launcher tool. This will supersede the CMAKE_<LANG>_COMPILER_ARG1 approach to using such tools. The old approach set CMAKE_<LANG>_COMPILER to the launcher tool while the new approach leaves this variable set to the actual compiler. Implement this property for Makefile and Ninja generators. It cannot be implemented for VS or Xcode generators as the IDE build tools offer no such hooks.
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 7b88bc7b2f..481f4fee6f 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -775,6 +775,25 @@ cmMakefileTargetGenerator
}
}
+ // Maybe insert a compiler launcher like ccache or distcc
+ if (!compileCommands.empty() && (lang == "C" || lang == "CXX"))
+ {
+ std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
+ const char *clauncher = this->Target->GetProperty(clauncher_prop);
+ if (clauncher && *clauncher)
+ {
+ std::vector<std::string> launcher_cmd;
+ cmSystemTools::ExpandListArgument(clauncher, launcher_cmd, true);
+ for (std::vector<std::string>::iterator i = launcher_cmd.begin(),
+ e = launcher_cmd.end(); i != e; ++i)
+ {
+ *i = this->LocalGenerator->EscapeForShell(*i);
+ }
+ std::string const& run_launcher = cmJoin(launcher_cmd, " ") + " ";
+ compileCommands.front().insert(0, run_launcher);
+ }
+ }
+
// Expand placeholders in the commands.
for(std::vector<std::string>::iterator i = compileCommands.begin();
i != compileCommands.end(); ++i)