MCPcopy Create free account
hub / github.com/Kitware/CMake / wrapOptions

Function wrapOptions

Source/cmGeneratorTarget_Options.cxx:105–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103};
104
105std::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) {

Callers 2

GetLinkOptionsMethod · 0.85

Calls 11

moveFunction · 0.85
transformFunction · 0.85
cmHasLiteralPrefixFunction · 0.85
reserveMethod · 0.80
emplace_backMethod · 0.80
cmJoinFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…