summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBobby D Reynolds <boreynol@microsoft.com>2021-05-18 15:57:02 (GMT)
committerBrad King <brad.king@kitware.com>2021-05-28 16:28:43 (GMT)
commitae108418ae45aff7740605bb7add3843b050d226 (patch)
tree1b46b02e2c567538b0437fed2aef91564cd8f577 /Source
parent92c8b83641eae61700d16602e0b60d9c9c6f3b15 (diff)
downloadCMake-ae108418ae45aff7740605bb7add3843b050d226.zip
CMake-ae108418ae45aff7740605bb7add3843b050d226.tar.gz
CMake-ae108418ae45aff7740605bb7add3843b050d226.tar.bz2
Launchers: Support setting linker launchers
Fixes: #18316
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCommonTargetGenerator.cxx22
-rw-r--r--Source/cmCommonTargetGenerator.h2
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx6
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx6
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx5
-rw-r--r--Source/cmRulePlaceholderExpander.cxx20
-rw-r--r--Source/cmRulePlaceholderExpander.h1
-rw-r--r--Source/cmTarget.cxx4
8 files changed, 65 insertions, 1 deletions
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index 0c5a7df..7c2e20c 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -15,6 +15,7 @@
#include "cmMakefile.h"
#include "cmOutputConverter.h"
#include "cmProperty.h"
+#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
@@ -291,3 +292,24 @@ void cmCommonTargetGenerator::AppendOSXVerFlag(std::string& flags,
this->LocalCommonGenerator->AppendFlags(flags, vflag.str());
}
}
+
+std::string cmCommonTargetGenerator::GetLinkerLauncher(
+ const std::string& config)
+{
+ std::string lang = this->GeneratorTarget->GetLinkerLanguage(config);
+ cmProp launcherProp =
+ this->GeneratorTarget->GetProperty(lang + "_LINKER_LAUNCHER");
+ if (cmNonempty(launcherProp)) {
+ // Convert ;-delimited list to single string
+ std::vector<std::string> args = cmExpandedList(*launcherProp, true);
+ if (!args.empty()) {
+ args[0] = this->LocalCommonGenerator->ConvertToOutputFormat(
+ args[0], cmOutputConverter::SHELL);
+ for (std::string& i : cmMakeRange(args.begin() + 1, args.end())) {
+ i = this->LocalCommonGenerator->EscapeForShell(i);
+ }
+ return cmJoin(args, " ");
+ }
+ }
+ return std::string();
+}
diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h
index fba6b0a..a156a41 100644
--- a/Source/cmCommonTargetGenerator.h
+++ b/Source/cmCommonTargetGenerator.h
@@ -64,6 +64,8 @@ protected:
const std::string& config) const;
std::string ComputeTargetCompilePDB(const std::string& config) const;
+ std::string GetLinkerLauncher(const std::string& config);
+
private:
using ByLanguageMap = std::map<std::string, std::string>;
struct ByConfig
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 2940b8b..3a2744e 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -571,6 +571,12 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
vars.LinkFlags = linkFlags.c_str();
vars.Manifests = manifests.c_str();
+ std::string linkerLauncher =
+ this->GetLinkerLauncher(this->GetConfigName());
+ if (cmNonempty(linkerLauncher)) {
+ vars.Launcher = linkerLauncher.c_str();
+ }
+
if (this->GeneratorTarget->GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
std::string cmakeCommand =
cmStrCat(this->LocalGenerator->ConvertToOutputFormat(
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index f96bcde..d0e3837 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -804,6 +804,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
vars.LanguageCompileFlags = langFlags.c_str();
+ std::string linkerLauncher =
+ this->GetLinkerLauncher(this->GetConfigName());
+ if (cmNonempty(linkerLauncher)) {
+ vars.Launcher = linkerLauncher.c_str();
+ }
+
std::string launcher;
cmProp val = this->LocalGenerator->GetRuleLauncher(this->GeneratorTarget,
"RULE_LAUNCH_LINK");
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 03fc0b4..9a48047 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -456,6 +456,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile,
vars.LanguageCompileFlags = langFlags.c_str();
}
+ std::string linkerLauncher = this->GetLinkerLauncher(config);
+ if (cmNonempty(linkerLauncher)) {
+ vars.Launcher = linkerLauncher.c_str();
+ }
+
std::string launcher;
cmProp val = this->GetLocalGenerator()->GetRuleLauncher(
this->GetGeneratorTarget(), "RULE_LAUNCH_LINK");
diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx
index d00bbdf..7480aeb 100644
--- a/Source/cmRulePlaceholderExpander.cxx
+++ b/Source/cmRulePlaceholderExpander.cxx
@@ -6,6 +6,7 @@
#include <utility>
#include "cmOutputConverter.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
cmRulePlaceholderExpander::cmRulePlaceholderExpander(
@@ -280,6 +281,13 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable(
this->VariableMappings["CMAKE_" + compIt->second +
"_COMPILE_OPTIONS_SYSROOT"];
+ if (compIt->second == replaceValues.Language && replaceValues.Launcher) {
+ // Add launcher as part of expansion so that it always appears
+ // immediately before the command itself, regardless of whether the
+ // overall rule template contains other content at the front.
+ ret = cmStrCat(replaceValues.Launcher, " ", ret);
+ }
+
// if there are required arguments to the compiler add it
// to the compiler string
if (!compilerArg1.empty()) {
@@ -317,7 +325,17 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable(
auto mapIt = this->VariableMappings.find(variable);
if (mapIt != this->VariableMappings.end()) {
if (variable.find("_FLAG") == std::string::npos) {
- return outputConverter->ConvertToOutputForExisting(mapIt->second);
+ std::string ret =
+ outputConverter->ConvertToOutputForExisting(mapIt->second);
+
+ if (replaceValues.Launcher && variable == "CMAKE_LINKER") {
+ // Add launcher as part of expansion so that it always appears
+ // immediately before the command itself, regardless of whether the
+ // overall rule template contains other content at the front.
+ ret = cmStrCat(replaceValues.Launcher, " ", ret);
+ }
+
+ return ret;
}
return mapIt->second;
}
diff --git a/Source/cmRulePlaceholderExpander.h b/Source/cmRulePlaceholderExpander.h
index f8dc368..c22e0fa 100644
--- a/Source/cmRulePlaceholderExpander.h
+++ b/Source/cmRulePlaceholderExpander.h
@@ -67,6 +67,7 @@ public:
const char* ISPCHeader = nullptr;
const char* Fatbinary = nullptr;
const char* RegisterFile = nullptr;
+ const char* Launcher = nullptr;
};
// Expand rule variables in CMake of the type found in language rules
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 29e361c..6f2e447 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -354,11 +354,13 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
initProp("C_CPPLINT");
initProp("C_CPPCHECK");
initProp("C_INCLUDE_WHAT_YOU_USE");
+ initProp("C_LINKER_LAUNCHER");
initProp("LINK_WHAT_YOU_USE");
initProp("CXX_CLANG_TIDY");
initProp("CXX_CPPLINT");
initProp("CXX_CPPCHECK");
initProp("CXX_INCLUDE_WHAT_YOU_USE");
+ initProp("CXX_LINKER_LAUNCHER");
initProp("CUDA_SEPARABLE_COMPILATION");
initProp("CUDA_RESOLVE_DEVICE_SYMBOLS");
initProp("CUDA_RUNTIME_LIBRARY");
@@ -374,7 +376,9 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
initProp("LINK_SEARCH_START_STATIC");
initProp("LINK_SEARCH_END_STATIC");
initProp("OBJC_CLANG_TIDY");
+ initProp("OBJC_LINKER_LAUNCHER");
initProp("OBJCXX_CLANG_TIDY");
+ initProp("OBJCXX_LINKER_LAUNCHER");
initProp("Swift_LANGUAGE_VERSION");
initProp("Swift_MODULE_DIRECTORY");
initProp("VS_JUST_MY_CODE_DEBUGGING");