summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-04-01 14:21:06 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-04-01 14:21:11 (GMT)
commitb362c0bb26906b053727b04a15a9bc6ef19b7859 (patch)
tree38fae85d9783e38c33bba512b8a283db9ae527ca /Source/cmGeneratorTarget.cxx
parent763b02b8f03b59e3061a2578561c9af1b85fc9b7 (diff)
parentbb96984ec932c899c9544ce21b6b63ef4c455e55 (diff)
downloadCMake-b362c0bb26906b053727b04a15a9bc6ef19b7859.zip
CMake-b362c0bb26906b053727b04a15a9bc6ef19b7859.tar.gz
CMake-b362c0bb26906b053727b04a15a9bc6ef19b7859.tar.bz2
Merge topic 'CUDA-device-link'
bb96984ec9 CUDA Device link: Ensure all link options are correctly formatted Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5962
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx60
1 files changed, 52 insertions, 8 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index d3c9959..365f8b8 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -3655,13 +3655,58 @@ std::vector<BT<std::string>> wrapOptions(
return result;
}
- if (wrapperFlag.empty() || cmHasLiteralPrefix(options.front(), "LINKER:")) {
- // nothing specified or LINKER wrapper, insert elements as is
+ if (wrapperFlag.empty()) {
+ // nothing specified, insert elements as is
result.reserve(options.size());
for (std::string& o : options) {
result.emplace_back(std::move(o), bt);
}
- } else {
+ return result;
+ }
+
+ for (std::vector<std::string>::size_type index = 0; index < options.size();
+ index++) {
+ if (cmHasLiteralPrefix(options[index], "LINKER:")) {
+ // LINKER wrapper specified, insert elements as is
+ result.emplace_back(std::move(options[index]), bt);
+ continue;
+ }
+ if (cmHasLiteralPrefix(options[index], "-Wl,")) {
+ // replace option by LINKER wrapper
+ result.emplace_back(options[index].replace(0, 4, "LINKER:"), bt);
+ continue;
+ }
+ if (cmHasLiteralPrefix(options[index], "-Xlinker=")) {
+ // replace option by LINKER wrapper
+ result.emplace_back(options[index].replace(0, 9, "LINKER:"), bt);
+ continue;
+ }
+ if (options[index] == "-Xlinker") {
+ // replace option by LINKER wrapper
+ if (index + 1 < options.size()) {
+ result.emplace_back("LINKER:" + options[++index], bt);
+ } else {
+ result.emplace_back(std::move(options[index]), bt);
+ }
+ continue;
+ }
+
+ // collect all options which must be transformed
+ std::vector<std::string> opts;
+ while (index < options.size()) {
+ if (!cmHasLiteralPrefix(options[index], "LINKER:") &&
+ !cmHasLiteralPrefix(options[index], "-Wl,") &&
+ !cmHasLiteralPrefix(options[index], "-Xlinker")) {
+ opts.emplace_back(std::move(options[index++]));
+ } else {
+ --index;
+ break;
+ }
+ }
+ if (opts.empty()) {
+ continue;
+ }
+
if (!wrapperSep.empty()) {
if (concatFlagAndArgs) {
// insert flag elements except last one
@@ -3670,24 +3715,23 @@ std::vector<BT<std::string>> wrapOptions(
}
// concatenate last flag element and all list values
// in one option
- result.emplace_back(wrapperFlag.back() + cmJoin(options, wrapperSep),
- bt);
+ result.emplace_back(wrapperFlag.back() + cmJoin(opts, wrapperSep), bt);
} else {
for (std::string const& i : wrapperFlag) {
result.emplace_back(i, bt);
}
// concatenate all list values in one option
- result.emplace_back(cmJoin(options, wrapperSep), bt);
+ result.emplace_back(cmJoin(opts, wrapperSep), bt);
}
} else {
// prefix each element of list with wrapper
if (concatFlagAndArgs) {
- std::transform(options.begin(), options.end(), options.begin(),
+ std::transform(opts.begin(), opts.end(), opts.begin(),
[&wrapperFlag](std::string const& o) -> std::string {
return wrapperFlag.back() + o;
});
}
- for (std::string& o : options) {
+ for (std::string& o : opts) {
for (auto i = wrapperFlag.begin(),
e = concatFlagAndArgs ? wrapperFlag.end() - 1
: wrapperFlag.end();