|
|
@@ -95,7 +95,7 @@ void processOptions(cmGeneratorTarget const* tgt,
|
|
|
enum class NestedLinkerFlags
|
|
|
{
|
|
|
PreserveAsSpelled,
|
|
|
- Normalize,
|
|
|
+ Normalize
|
|
|
};
|
|
|
|
|
|
std::vector<BT<std::string>> wrapOptions(
|
|
|
@@ -525,32 +525,31 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-std::vector<BT<std::string>>& cmGeneratorTarget::ResolveLinkerWrapper(
|
|
|
- std::vector<BT<std::string>>& result, const std::string& language,
|
|
|
- bool joinItems) const
|
|
|
+std::vector<BT<std::string>>& cmGeneratorTarget::ResolvePrefixWrapper(
|
|
|
+ std::vector<BT<std::string>>& result, cm::string_view prefix,
|
|
|
+ const std::string& language, bool joinItems) const
|
|
|
{
|
|
|
- // replace "LINKER:" prefixed elements by actual linker wrapper
|
|
|
+ // replace "LINKER:" or "ARCHIVER:" prefixed elements by actual linker or
|
|
|
+ // archiver wrapper
|
|
|
const std::string wrapper(this->Makefile->GetSafeDefinition(
|
|
|
- "CMAKE_" + language +
|
|
|
- (this->IsDeviceLink() ? "_DEVICE_LINKER_WRAPPER_FLAG"
|
|
|
- : "_LINKER_WRAPPER_FLAG")));
|
|
|
+ cmStrCat("CMAKE_", language, (this->IsDeviceLink() ? "_DEVICE_" : "_"),
|
|
|
+ prefix, "_WRAPPER_FLAG")));
|
|
|
cmList wrapperFlag{ wrapper };
|
|
|
const std::string wrapperSep(this->Makefile->GetSafeDefinition(
|
|
|
- "CMAKE_" + language +
|
|
|
- (this->IsDeviceLink() ? "_DEVICE_LINKER_WRAPPER_FLAG_SEP"
|
|
|
- : "_LINKER_WRAPPER_FLAG_SEP")));
|
|
|
+ cmStrCat("CMAKE_", language, (this->IsDeviceLink() ? "_DEVICE_" : "_"),
|
|
|
+ prefix, "_WRAPPER_FLAG_SEP")));
|
|
|
bool concatFlagAndArgs = true;
|
|
|
if (!wrapperFlag.empty() && wrapperFlag.back() == " ") {
|
|
|
concatFlagAndArgs = false;
|
|
|
wrapperFlag.pop_back();
|
|
|
}
|
|
|
|
|
|
- const std::string LINKER{ "LINKER:" };
|
|
|
+ const std::string PREFIX{ cmStrCat(prefix, ':') };
|
|
|
const std::string SHELL{ "SHELL:" };
|
|
|
- const std::string LINKER_SHELL = LINKER + SHELL;
|
|
|
+ const std::string PREFIX_SHELL = cmStrCat(PREFIX, SHELL);
|
|
|
|
|
|
for (auto entry = result.begin(); entry != result.end(); ++entry) {
|
|
|
- if (entry->Value.compare(0, LINKER.length(), LINKER) != 0) {
|
|
|
+ if (entry->Value.compare(0, PREFIX.length(), PREFIX) != 0) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
@@ -558,27 +557,28 @@ std::vector<BT<std::string>>& cmGeneratorTarget::ResolveLinkerWrapper(
|
|
|
cmListFileBacktrace bt = std::move(entry->Backtrace);
|
|
|
entry = result.erase(entry);
|
|
|
|
|
|
- std::vector<std::string> linkerOptions;
|
|
|
- if (value.compare(0, LINKER_SHELL.length(), LINKER_SHELL) == 0) {
|
|
|
+ std::vector<std::string> options;
|
|
|
+ if (value.compare(0, PREFIX_SHELL.length(), PREFIX_SHELL) == 0) {
|
|
|
cmSystemTools::ParseUnixCommandLine(
|
|
|
- value.c_str() + LINKER_SHELL.length(), linkerOptions);
|
|
|
+ value.c_str() + PREFIX_SHELL.length(), options);
|
|
|
} else {
|
|
|
- linkerOptions =
|
|
|
- cmTokenize(value.substr(LINKER.length()), ',', cmTokenizerMode::New);
|
|
|
+ options =
|
|
|
+ cmTokenize(value.substr(PREFIX.length()), ',', cmTokenizerMode::New);
|
|
|
}
|
|
|
|
|
|
- if (linkerOptions.empty()) {
|
|
|
+ if (options.empty()) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// for now, raise an error if prefix SHELL: is part of arguments
|
|
|
- if (std::find_if(linkerOptions.begin(), linkerOptions.end(),
|
|
|
+ if (std::find_if(options.begin(), options.end(),
|
|
|
[&SHELL](const std::string& item) -> bool {
|
|
|
return item.find(SHELL) != std::string::npos;
|
|
|
- }) != linkerOptions.end()) {
|
|
|
+ }) != options.end()) {
|
|
|
this->LocalGenerator->GetCMakeInstance()->IssueMessage(
|
|
|
MessageType::FATAL_ERROR,
|
|
|
- "'SHELL:' prefix is not supported as part of 'LINKER:' arguments.",
|
|
|
+ cmStrCat("'SHELL:' prefix is not supported as part of '", prefix,
|
|
|
+ ":' arguments."),
|
|
|
this->GetBacktrace());
|
|
|
return result;
|
|
|
}
|
|
|
@@ -586,21 +586,30 @@ std::vector<BT<std::string>>& cmGeneratorTarget::ResolveLinkerWrapper(
|
|
|
// Very old versions of the C++ standard library return void for insert, so
|
|
|
// can't use it to get the new iterator
|
|
|
const auto index = entry - result.begin();
|
|
|
- std::vector<BT<std::string>> options =
|
|
|
- wrapOptions(linkerOptions, bt, wrapperFlag, wrapperSep,
|
|
|
- concatFlagAndArgs, NestedLinkerFlags::PreserveAsSpelled);
|
|
|
+ std::vector<BT<std::string>> processedOptions =
|
|
|
+ wrapOptions(options, bt, wrapperFlag, wrapperSep, concatFlagAndArgs,
|
|
|
+ NestedLinkerFlags::PreserveAsSpelled);
|
|
|
if (joinItems) {
|
|
|
result.insert(
|
|
|
- entry, cmJoin(cmMakeRange(options.begin(), options.end()), " "_s));
|
|
|
+ entry,
|
|
|
+ cmJoin(cmMakeRange(processedOptions.begin(), processedOptions.end()),
|
|
|
+ " "_s));
|
|
|
entry = std::next(result.begin(), index);
|
|
|
} else {
|
|
|
- result.insert(entry, options.begin(), options.end());
|
|
|
- entry = std::next(result.begin(), index + options.size() - 1);
|
|
|
+ result.insert(entry, processedOptions.begin(), processedOptions.end());
|
|
|
+ entry = std::next(result.begin(), index + processedOptions.size() - 1);
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+std::vector<BT<std::string>>& cmGeneratorTarget::ResolveLinkerWrapper(
|
|
|
+ std::vector<BT<std::string>>& result, const std::string& language,
|
|
|
+ bool joinItems) const
|
|
|
+{
|
|
|
+ return this->ResolvePrefixWrapper(result, "LINKER"_s, language, joinItems);
|
|
|
+}
|
|
|
+
|
|
|
void cmGeneratorTarget::GetStaticLibraryLinkOptions(
|
|
|
std::vector<std::string>& result, const std::string& config,
|
|
|
const std::string& language) const
|
|
|
@@ -633,9 +642,20 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetStaticLibraryLinkOptions(
|
|
|
processOptions(this, entries, result, uniqueOptions, false,
|
|
|
"static library link options", OptionsParse::Shell);
|
|
|
|
|
|
+ // Last step: replace "ARCHIVER:" prefixed elements by
|
|
|
+ // actual archiver wrapper
|
|
|
+ this->ResolveArchiverWrapper(result, language);
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+std::vector<BT<std::string>>& cmGeneratorTarget::ResolveArchiverWrapper(
|
|
|
+ std::vector<BT<std::string>>& result, const std::string& language,
|
|
|
+ bool joinItems) const
|
|
|
+{
|
|
|
+ return this->ResolvePrefixWrapper(result, "ARCHIVER"_s, language, joinItems);
|
|
|
+}
|
|
|
+
|
|
|
void cmGeneratorTarget::GetLinkDepends(std::vector<std::string>& result,
|
|
|
const std::string& config,
|
|
|
const std::string& language) const
|