mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-24 07:08:38 -05:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "cmComputeLinkInformation.h"
|
||||
#include "cmSourceFile.h"
|
||||
#include "cmCustomCommandGenerator.h"
|
||||
#include "cmAlgorithms.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -475,6 +476,25 @@ cmNinjaTargetGenerator
|
||||
}
|
||||
}
|
||||
|
||||
// Maybe insert a compiler launcher like ccache or distcc
|
||||
if (!compileCmds.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, " ") + " ";
|
||||
compileCmds.front().insert(0, run_launcher);
|
||||
}
|
||||
}
|
||||
|
||||
if (!compileCmds.empty())
|
||||
{
|
||||
compileCmds.front().insert(0, cldeps);
|
||||
|
||||
@@ -333,10 +333,12 @@ void cmTarget::SetMakefile(cmMakefile* mf)
|
||||
this->SetPropertyDefault("MACOSX_BUNDLE", 0);
|
||||
this->SetPropertyDefault("MACOSX_RPATH", 0);
|
||||
this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", 0);
|
||||
this->SetPropertyDefault("C_COMPILER_LAUNCHER", 0);
|
||||
this->SetPropertyDefault("C_INCLUDE_WHAT_YOU_USE", 0);
|
||||
this->SetPropertyDefault("C_STANDARD", 0);
|
||||
this->SetPropertyDefault("C_STANDARD_REQUIRED", 0);
|
||||
this->SetPropertyDefault("C_EXTENSIONS", 0);
|
||||
this->SetPropertyDefault("CXX_COMPILER_LAUNCHER", 0);
|
||||
this->SetPropertyDefault("CXX_INCLUDE_WHAT_YOU_USE", 0);
|
||||
this->SetPropertyDefault("CXX_STANDARD", 0);
|
||||
this->SetPropertyDefault("CXX_STANDARD_REQUIRED", 0);
|
||||
|
||||
Reference in New Issue
Block a user