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

Function stripExportInterface

Source/cmGeneratorExpression.cxx:249–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249static std::string stripExportInterface(
250 cm::string_view input, cmGeneratorExpression::PreprocessContext context,
251 cm::string_view importPrefix)
252{
253 std::string result;
254
255 int nestingLevel = 0;
256 std::string::size_type pos = 0;
257 std::string::size_type lastPos = pos;
258 while (true) {
259 std::string::size_type bPos = input.find("$<BUILD_INTERFACE:", lastPos);
260 std::string::size_type iPos = input.find("$<INSTALL_INTERFACE:", lastPos);
261 std::string::size_type lPos =
262 input.find("$<BUILD_LOCAL_INTERFACE:", lastPos);
263
264 pos = std::min({ bPos, iPos, lPos });
265 if (pos == std::string::npos) {
266 break;
267 }
268
269 result += input.substr(lastPos, pos - lastPos);
270 enum class FoundGenex
271 {
272 BuildInterface,
273 InstallInterface,
274 BuildLocalInterface,
275 } foundGenex = FoundGenex::BuildInterface;
276 if (pos == bPos) {
277 foundGenex = FoundGenex::BuildInterface;
278 pos += cmStrLen("$<BUILD_INTERFACE:");
279 } else if (pos == iPos) {
280 foundGenex = FoundGenex::InstallInterface;
281 pos += cmStrLen("$<INSTALL_INTERFACE:");
282 } else if (pos == lPos) {
283 foundGenex = FoundGenex::BuildLocalInterface;
284 pos += cmStrLen("$<BUILD_LOCAL_INTERFACE:");
285 } else {
286 assert(false && "Invalid position found");
287 }
288 nestingLevel = 1;
289 char const* c = input.data() + pos;
290 char const* const cStart = c;
291 for (; *c; ++c) {
292 if (cmGeneratorExpression::StartsWithGeneratorExpression(c)) {
293 ++nestingLevel;
294 ++c;
295 continue;
296 }
297 if (c[0] == '>') {
298 --nestingLevel;
299 if (nestingLevel != 0) {
300 continue;
301 }
302 if (context == cmGeneratorExpression::BuildInterface &&
303 foundGenex == FoundGenex::BuildInterface) {
304 result += input.substr(pos, c - cStart);
305 } else if (context == cmGeneratorExpression::InstallInterface &&
306 foundGenex == FoundGenex::InstallInterface) {

Callers 1

PreprocessMethod · 0.85

Calls 8

minFunction · 0.85
prefixItemsFunction · 0.85
cmStrLenFunction · 0.70
cmStrCatFunction · 0.70
findMethod · 0.45
substrMethod · 0.45
dataMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…