COMPILER_LAUNCHER: Add support for generator expressions

Fixes: #23441
This commit is contained in:
Thomas Weißschuh authored and Brad King committed 2022-08-30 17:26:25 -04:00
1 parent 60a1ccbd6a
commit 36400e9dc1
5 files changed
+20 -5

No files matched your search

+5
View File
@@ -14,3 +14,8 @@ its arguments to the tool. Some example tools are distcc and ccache.
This property is initialized by the value of
the :variable:`CMAKE_<LANG>_COMPILER_LAUNCHER` variable if it is set
when a target is created.
.. versionadded:: 3.25
The property value may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
@@ -0,0 +1,5 @@
compiler-launcher-genexp
------------------------
* The :prop_tgt:`<LANG>_COMPILER_LAUNCHER` target property now supports
:manual:`generator expressions <cmake-generator-expressions(7)>`.
+4 -2
View File
@@ -1042,8 +1042,10 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
lang == "OBJCXX")) {
std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
cmValue clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
if (cmNonempty(clauncher)) {
compilerLauncher = *clauncher;
std::string evaluatedClauncher = cmGeneratorExpression::Evaluate(
*clauncher, this->LocalGenerator, config);
if (!evaluatedClauncher.empty()) {
compilerLauncher = evaluatedClauncher;
}
}
+4 -2
View File
@@ -912,8 +912,10 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
lang == "OBJCXX")) {
std::string const clauncher_prop = cmStrCat(lang, "_COMPILER_LAUNCHER");
cmValue clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
if (cmNonempty(clauncher)) {
compilerLauncher = *clauncher;
std::string evaluatedClauncher = cmGeneratorExpression::Evaluate(
*clauncher, this->LocalGenerator, config);
if (!evaluatedClauncher.empty()) {
compilerLauncher = evaluatedClauncher;
}
}
@@ -17,7 +17,8 @@ endfunction()
function(run_compiler_launcher_env lang)
string(REGEX REPLACE "-.*" "" core_lang "${lang}")
set(ENV{CMAKE_${core_lang}_COMPILER_LAUNCHER} "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1")
# Use the noop genexp $<PATH:...> genexp to validate genexp support.
set(ENV{CMAKE_${core_lang}_COMPILER_LAUNCHER} "$<PATH:CMAKE_PATH,${CMAKE_COMMAND}>;-E;env;USED_LAUNCHER=1")
run_compiler_launcher(${lang})
unset(ENV{CMAKE_${core_lang}_COMPILER_LAUNCHER})
endfunction()