summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorGergely Meszaros <gergely.meszaros@intel.com>2024-09-18 08:27:37 (GMT)
committerGergely Meszaros <gergely.meszaros@intel.com>2024-09-18 08:27:37 (GMT)
commit54381b5a81a2ef9e3e1e5508d1a8434413b9aace (patch)
tree14d9ffb87627901b6a9a432617773634761491a4 /Source
parent52fd4a3479c428ee7b5ad1688d03084cf52fe93e (diff)
downloadCMake-54381b5a81a2ef9e3e1e5508d1a8434413b9aace.zip
CMake-54381b5a81a2ef9e3e1e5508d1a8434413b9aace.tar.gz
CMake-54381b5a81a2ef9e3e1e5508d1a8434413b9aace.tar.bz2
Linking: extract wrapping linker options to a lambda (NFC)
Extract logic to wrap flags in wrapOptions, it will be reused in a follow-up commit.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget_Options.cxx72
1 files changed, 38 insertions, 34 deletions
diff --git a/Source/cmGeneratorTarget_Options.cxx b/Source/cmGeneratorTarget_Options.cxx
index f77ef72..df22b90 100644
--- a/Source/cmGeneratorTarget_Options.cxx
+++ b/Source/cmGeneratorTarget_Options.cxx
@@ -111,6 +111,43 @@ std::vector<BT<std::string>> wrapOptions(
return result;
}
+ auto insertWrapped = [&](std::vector<std::string>& opts) {
+ if (!wrapperSep.empty()) {
+ if (concatFlagAndArgs) {
+ // insert flag elements except last one
+ for (auto i = wrapperFlag.begin(); i != wrapperFlag.end() - 1; ++i) {
+ result.emplace_back(*i, bt);
+ }
+ // concatenate last flag element and all list values
+ // in one option
+ 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(opts, wrapperSep), bt);
+ }
+ } else {
+ // prefix each element of list with wrapper
+ if (concatFlagAndArgs) {
+ std::transform(opts.begin(), opts.end(), opts.begin(),
+ [&wrapperFlag](std::string const& o) -> std::string {
+ return wrapperFlag.back() + o;
+ });
+ }
+ for (std::string& o : opts) {
+ for (auto i = wrapperFlag.begin(),
+ e = concatFlagAndArgs ? wrapperFlag.end() - 1
+ : wrapperFlag.end();
+ i != e; ++i) {
+ result.emplace_back(*i, bt);
+ }
+ result.emplace_back(std::move(o), bt);
+ }
+ }
+ };
+
for (std::vector<std::string>::size_type index = 0; index < options.size();
index++) {
if (cmHasLiteralPrefix(options[index], "LINKER:")) {
@@ -154,40 +191,7 @@ std::vector<BT<std::string>> wrapOptions(
continue;
}
- if (!wrapperSep.empty()) {
- if (concatFlagAndArgs) {
- // insert flag elements except last one
- for (auto i = wrapperFlag.begin(); i != wrapperFlag.end() - 1; ++i) {
- result.emplace_back(*i, bt);
- }
- // concatenate last flag element and all list values
- // in one option
- 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(opts, wrapperSep), bt);
- }
- } else {
- // prefix each element of list with wrapper
- if (concatFlagAndArgs) {
- std::transform(opts.begin(), opts.end(), opts.begin(),
- [&wrapperFlag](std::string const& o) -> std::string {
- return wrapperFlag.back() + o;
- });
- }
- for (std::string& o : opts) {
- for (auto i = wrapperFlag.begin(),
- e = concatFlagAndArgs ? wrapperFlag.end() - 1
- : wrapperFlag.end();
- i != e; ++i) {
- result.emplace_back(*i, bt);
- }
- result.emplace_back(std::move(o), bt);
- }
- }
+ insertWrapped(opts);
}
return result;
}