| 103 | }; |
| 104 | |
| 105 | std::vector<BT<std::string>> wrapOptions( |
| 106 | std::vector<std::string>& options, cmListFileBacktrace const& bt, |
| 107 | std::vector<std::string> const& wrapperFlag, std::string const& wrapperSep, |
| 108 | bool concatFlagAndArgs, NestedLinkerFlags nestedLinkerFlags) |
| 109 | { |
| 110 | std::vector<BT<std::string>> result; |
| 111 | |
| 112 | if (options.empty()) { |
| 113 | return result; |
| 114 | } |
| 115 | |
| 116 | if (wrapperFlag.empty()) { |
| 117 | // nothing specified, insert elements as is |
| 118 | result.reserve(options.size()); |
| 119 | for (std::string& o : options) { |
| 120 | result.emplace_back(std::move(o), bt); |
| 121 | } |
| 122 | return result; |
| 123 | } |
| 124 | |
| 125 | auto insertWrapped = [&](std::vector<std::string>& opts) { |
| 126 | if (!wrapperSep.empty()) { |
| 127 | if (concatFlagAndArgs) { |
| 128 | // insert flag elements except last one |
| 129 | for (auto i = wrapperFlag.begin(); i != wrapperFlag.end() - 1; ++i) { |
| 130 | result.emplace_back(*i, bt); |
| 131 | } |
| 132 | // concatenate last flag element and all list values |
| 133 | // in one option |
| 134 | result.emplace_back(wrapperFlag.back() + cmJoin(opts, wrapperSep), bt); |
| 135 | } else { |
| 136 | for (std::string const& i : wrapperFlag) { |
| 137 | result.emplace_back(i, bt); |
| 138 | } |
| 139 | // concatenate all list values in one option |
| 140 | result.emplace_back(cmJoin(opts, wrapperSep), bt); |
| 141 | } |
| 142 | } else { |
| 143 | // prefix each element of list with wrapper |
| 144 | if (concatFlagAndArgs) { |
| 145 | std::transform(opts.begin(), opts.end(), opts.begin(), |
| 146 | [&wrapperFlag](std::string const& o) -> std::string { |
| 147 | return wrapperFlag.back() + o; |
| 148 | }); |
| 149 | } |
| 150 | for (std::string& o : opts) { |
| 151 | for (auto i = wrapperFlag.begin(), |
| 152 | e = concatFlagAndArgs ? wrapperFlag.end() - 1 |
| 153 | : wrapperFlag.end(); |
| 154 | i != e; ++i) { |
| 155 | result.emplace_back(*i, bt); |
| 156 | } |
| 157 | result.emplace_back(std::move(o), bt); |
| 158 | } |
| 159 | } |
| 160 | }; |
| 161 | |
| 162 | if (nestedLinkerFlags == NestedLinkerFlags::PreserveAsSpelled) { |
no test coverage detected
searching dependent graphs…