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

Method AppendFlag

Source/cmGlobalXCodeGenerator.cxx:5427–5474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5425}
5426
5427void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
5428 std::string const& flag) const
5429{
5430 // Short-circuit for an empty flag.
5431 if (flag.empty()) {
5432 return;
5433 }
5434
5435 // Separate from previous flags.
5436 if (!flags.empty()) {
5437 flags += ' ';
5438 }
5439
5440 // Check if the flag needs quoting.
5441 bool quoteFlag =
5442 flag.find_first_of("`~!@#$%^&*()+={}[]|:;\"'<>,.? ") != std::string::npos;
5443
5444 // We escape a flag as follows:
5445 // - Place each flag in single quotes ''
5446 // - Escape a single quote as \'
5447 // - Escape a backslash as \\ since it itself is an escape
5448 // Note that in the code below we need one more level of escapes for
5449 // C string syntax in this source file.
5450 //
5451 // The final level of escaping is done when the string is stored
5452 // into the project file by cmXCodeObject::PrintString.
5453
5454 if (quoteFlag) {
5455 // Open single quote.
5456 flags += '\'';
5457 }
5458
5459 // Flag value with escaped quotes and backslashes.
5460 for (auto c : flag) {
5461 if (c == '\'') {
5462 flags += "'\\''";
5463 } else if (c == '\\') {
5464 flags += "\\\\";
5465 } else {
5466 flags += c;
5467 }
5468 }
5469
5470 if (quoteFlag) {
5471 // Close single quote.
5472 flags += '\'';
5473 }
5474}
5475
5476std::string cmGlobalXCodeGenerator::ComputeInfoPListLocation(
5477 cmGeneratorTarget* target)

Callers 1

AppendDefinesMethod · 0.95

Calls 2

find_first_ofMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected