From f5056d28c56155ca1ba137bff30255f42a74f70a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 26 Jul 2023 15:35:52 -0400 Subject: clang-tidy: fix `modernize-use-auto` lints --- Source/cmGlobalXCodeGenerator.cxx | 58 +++++++++++++++++++-------------------- Source/cmXCodeObject.cxx | 2 +- Source/cmXCodeObject.h | 2 +- Source/cmXCodeScheme.cxx | 2 +- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 247d4fc..68955ae 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -703,7 +703,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( cmLocalGenerator* root, std::vector const& gens) { std::vector lfiles; - for (auto gen : gens) { + for (auto* gen : gens) { cm::append(lfiles, gen->GetMakefile()->GetListFiles()); } @@ -814,7 +814,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateObject( { auto obj = cm::make_unique(ptype, cmXCodeObject::OBJECT, this->GetObjectId(ptype, key)); - auto ptr = obj.get(); + auto* ptr = obj.get(); this->addObject(std::move(obj)); return ptr; } @@ -824,7 +824,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type) auto obj = cm::make_unique( cmXCodeObject::None, type, "Temporary cmake object, should not be referred to in Xcode file"); - auto ptr = obj.get(); + auto* ptr = obj.get(); this->addObject(std::move(obj)); return ptr; } @@ -1350,7 +1350,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( this->SetCurrentLocalGenerator(gen); std::vector gts = this->GetLocalGeneratorTargetsInOrder(gen); - for (auto gtgt : gts) { + for (auto* gtgt : gts) { if (!this->CreateXCodeTarget(gtgt, targets)) { return false; } @@ -1386,8 +1386,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( } auto& gtgt_visited = this->CommandsVisited[gtgt]; - auto& deps = this->GetTargetDirectDepends(gtgt); - for (auto& d : deps) { + auto const& deps = this->GetTargetDirectDepends(gtgt); + for (auto const& d : deps) { // Take the union of visited source files of custom commands so far. // ComputeTargetOrder ensures our dependencies already visited their // custom commands and updated CommandsVisited. @@ -1432,7 +1432,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( std::vector headerFiles; std::vector resourceFiles; std::vector sourceFiles; - for (auto sourceFile : commonSourceFiles) { + for (auto* sourceFile : commonSourceFiles) { cmXCodeObject* xsf = this->CreateXCodeSourceFile( this->CurrentLocalGenerator, sourceFile, gtgt); cmXCodeObject* fr = xsf->GetAttribute("fileRef"); @@ -1535,7 +1535,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( using mapOfVectorOfSourceFiles = std::map>; mapOfVectorOfSourceFiles bundleFiles; - for (auto sourceFile : commonSourceFiles) { + for (auto* sourceFile : commonSourceFiles) { cmGeneratorTarget::SourceFileFlags tsFlags = gtgt->GetTargetSourceFileFlags(sourceFile); if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeMacContent) { @@ -1568,7 +1568,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( this->CreateString("0")); buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); copyFilesBuildPhase->AddAttribute("files", buildFiles); - for (auto sourceFile : keySources.second) { + for (auto* sourceFile : keySources.second) { cmXCodeObject* xsf = this->CreateXCodeSourceFile( this->CurrentLocalGenerator, sourceFile, gtgt); buildFiles->AddObject(xsf); @@ -1583,7 +1583,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( using mapOfVectorOfSourceFiles = std::map>; mapOfVectorOfSourceFiles bundleFiles; - for (auto sourceFile : commonSourceFiles) { + for (auto* sourceFile : commonSourceFiles) { cmGeneratorTarget::SourceFileFlags tsFlags = gtgt->GetTargetSourceFileFlags(sourceFile); if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeDeepResource) { @@ -1604,7 +1604,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( this->CreateString("0")); buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); copyFilesBuildPhase->AddAttribute("files", buildFiles); - for (auto sourceFile : keySources.second) { + for (auto* sourceFile : keySources.second) { cmXCodeObject* xsf = this->CreateXCodeSourceFile( this->CurrentLocalGenerator, sourceFile, gtgt); buildFiles->AddObject(xsf); @@ -1803,7 +1803,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands( // add all the sources std::vector commands; auto& visited = this->CommandsVisited[gtgt]; - for (auto sourceFile : classes) { + for (auto* sourceFile : classes) { if (sourceFile->GetCustomCommand() && visited.insert(sourceFile).second) { commands.push_back(*sourceFile->GetCustomCommand()); @@ -1842,7 +1842,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands( if (resourceBuildPhase) { buildPhases->AddObject(resourceBuildPhase); } - for (auto obj : contentBuildPhases) { + for (auto* obj : contentBuildPhases) { buildPhases->AddObject(obj); } if (sourceBuildPhase) { @@ -1871,7 +1871,7 @@ void cmGlobalXCodeGenerator::CreateRunScriptBuildPhases( return; } auto& visited = this->CommandsVisited[gt]; - for (auto sf : sources) { + for (auto* sf : sources) { this->CreateRunScriptBuildPhases(buildPhases, sf, gt, visited); } } @@ -3117,7 +3117,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget( // Add CMakeLists.txt file for user convenience. this->AddXCodeProjBuildRule(gtgt, sources); - for (auto sourceFile : sources) { + for (auto* sourceFile : sources) { if (!sourceFile->GetIsGenerated()) { this->CreateXCodeFileReference(sourceFile, gtgt); } @@ -3178,7 +3178,7 @@ void cmGlobalXCodeGenerator::CreateGlobalXCConfigSettings( return; } - auto sf = this->CurrentMakefile->GetSource(xcconfig); + auto* sf = this->CurrentMakefile->GetSource(xcconfig); if (!sf) { cmSystemTools::Error( cmStrCat("sources for ALL_BUILD do not contain xcconfig file: '", @@ -3210,7 +3210,7 @@ void cmGlobalXCodeGenerator::CreateTargetXCConfigSettings( return; } - auto sf = target->Makefile->GetSource(xcconfig); + auto* sf = target->Makefile->GetSource(xcconfig); if (!sf) { cmSystemTools::Error(cmStrCat("target sources for target ", target->Target->GetName(), @@ -3497,7 +3497,7 @@ void cmGlobalXCodeGenerator::AppendBuildSettingAttribute( target->GetAttribute("buildConfigurationList")->GetObject(); cmXCodeObject* buildConfigs = configurationList->GetAttribute("buildConfigurations"); - for (auto obj : buildConfigs->GetObjectList()) { + for (auto* obj : buildConfigs->GetObjectList()) { if (configName.empty() || obj->GetAttribute("name")->GetString() == configName) { cmXCodeObject* settings = obj->GetAttribute("buildSettings"); @@ -3513,7 +3513,7 @@ void cmGlobalXCodeGenerator::InheritBuildSettingAttribute( target->GetAttribute("buildConfigurationList")->GetObject(); cmXCodeObject* buildConfigs = configurationList->GetAttribute("buildConfigurations"); - for (auto obj : buildConfigs->GetObjectList()) { + for (auto* obj : buildConfigs->GetObjectList()) { cmXCodeObject* settings = obj->GetAttribute("buildSettings"); if (cmXCodeObject* attr = settings->GetAttribute(attribute)) { BuildObjectListOrString inherited(this, true); @@ -3835,7 +3835,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) BuildObjectListOrString libSearchPaths(this, true); std::vector objs; gt->GetExternalObjects(objs, configName); - for (auto sourceFile : objs) { + for (auto const* sourceFile : objs) { if (sourceFile->GetObjectLibrary().empty()) { continue; } @@ -4171,7 +4171,7 @@ void cmGlobalXCodeGenerator::AddEmbeddedObjects( void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target) { - static const auto dstSubfolderSpec = "10"; + static auto const* const dstSubfolderSpec = "10"; // Despite the name, by default Xcode uses "Embed Frameworks" build phase // for both frameworks and dynamic libraries @@ -4182,7 +4182,7 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target) void cmGlobalXCodeGenerator::AddEmbeddedPlugIns(cmXCodeObject* target) { - static const auto dstSubfolderSpec = "13"; + static auto const* const dstSubfolderSpec = "13"; this->AddEmbeddedObjects(target, "Embed PlugIns", "XCODE_EMBED_PLUGINS", dstSubfolderSpec, NoActionOnCopyByDefault); @@ -4190,7 +4190,7 @@ void cmGlobalXCodeGenerator::AddEmbeddedPlugIns(cmXCodeObject* target) void cmGlobalXCodeGenerator::AddEmbeddedAppExtensions(cmXCodeObject* target) { - static const auto dstSubfolderSpec = "13"; + static auto const* const dstSubfolderSpec = "13"; this->AddEmbeddedObjects(target, "Embed App Extensions", "XCODE_EMBED_APP_EXTENSIONS", dstSubfolderSpec, @@ -4200,7 +4200,7 @@ void cmGlobalXCodeGenerator::AddEmbeddedAppExtensions(cmXCodeObject* target) void cmGlobalXCodeGenerator::AddEmbeddedExtensionKitExtensions( cmXCodeObject* target) { - static const auto dstSubfolderSpec = "16"; + static auto const* const dstSubfolderSpec = "16"; this->AddEmbeddedObjects(target, "Embed App Extensions", "XCODE_EMBED_EXTENSIONKIT_EXTENSIONS", @@ -4594,7 +4594,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( this->CustomCommandRoots.clear(); } // loop over all targets and add link and depend info - for (auto t : targets) { + for (auto* t : targets) { this->AddDependAndLinkInformation(t); this->AddEmbeddedFrameworks(t); this->AddEmbeddedPlugIns(t); @@ -4620,7 +4620,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( } // now add all targets to the root object cmXCodeObject* allTargets = this->CreateObject(cmXCodeObject::OBJECT_LIST); - for (auto t : targets) { + for (auto* t : targets) { allTargets->AddObject(t); cmXCodeObject* productRef = t->GetAttribute("productReference"); if (productRef) { @@ -4713,7 +4713,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile( "# does not seem to check these dependencies itself.\n"; /* clang-format on */ for (const auto& configName : this->CurrentConfigurationTypes) { - for (auto target : targets) { + for (auto* target : targets) { cmGeneratorTarget* gt = target->GetTarget(); if (gt->GetType() == cmStateEnums::EXECUTABLE || @@ -4744,7 +4744,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile( std::vector objlibs; gt->GetObjectLibrariesCMP0026(objlibs); - for (auto objLib : objlibs) { + for (auto* objLib : objlibs) { makefileStream << this->PostBuildMakeTarget(objLib->GetName(), configName) << ": " << trel << "\n"; @@ -4763,7 +4763,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile( } } - for (auto objLib : objlibs) { + for (auto* objLib : objlibs) { const std::string objLibName = objLib->GetName(); std::string d = cmStrCat(this->GetTargetTempDir(gt, configName), diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index c817980..73f0992 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -180,7 +180,7 @@ void cmXCodeObject::PrintList(std::vector const& objs, { cmXCodeObject::Indent(1, out); out << "objects = {\n"; - for (auto obj : objs) { + for (auto* obj : objs) { if (obj->TypeValue == OBJECT) { obj->Print(out); } diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 389fb62..10a6861 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -129,7 +129,7 @@ public: // search the attribute list for an object of the specified type cmXCodeObject* GetObject(cmXCodeObject::PBXType t) const { - for (auto o : this->List) { + for (auto* o : this->List) { if (o->IsA == t) { return o; } diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index 7f26fd8..217ac61 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -121,7 +121,7 @@ void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout, xout.Attribute("shouldUseLaunchSchemeArgsEnv", "YES"); xout.StartElement("Testables"); - for (auto test : this->Tests) { + for (auto const* test : this->Tests) { xout.StartElement("TestableReference"); xout.BreakAttributes(); xout.Attribute("skipped", "NO"); -- cgit v0.12 From 084aa40ecb4ce50029db61b19b7ed614d59d0a0d Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 26 Jul 2023 15:41:12 -0400 Subject: clang-tidy: fix `modernize-loop-convert` lints --- Source/CPack/cmCPackDragNDropGenerator.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 768bfbe..aa63ff7 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -574,16 +574,18 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, header_data.push_back(0); header_data.push_back(languages.size()); + // NOLINTNEXTLINE(modernize-loop-convert): `HAVE_CoreServices` needs `i` for (cmList::size_type i = 0; i < languages.size(); ++i) { + auto const& language = languages[i]; CFStringRef language_cfstring = CFStringCreateWithCString( - nullptr, languages[i].c_str(), kCFStringEncodingUTF8); + nullptr, language.c_str(), kCFStringEncodingUTF8); CFStringRef iso_language = CFLocaleCreateCanonicalLanguageIdentifierFromString( nullptr, language_cfstring); if (!iso_language) { cmCPackLogger(cmCPackLog::LOG_ERROR, - languages[i] << " is not a recognized language" - << std::endl); + language << " is not a recognized language" + << std::endl); } char iso_language_cstr[65]; CFStringGetCString(iso_language, iso_language_cstr, -- cgit v0.12 From efd9398844eb38b8e0f2faa0fd684a8b4cb1b741 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 26 Jul 2023 15:42:35 -0400 Subject: clang-tidy: fix `modernize-use-default-member-init` lints --- Source/cmGlobalXCodeGenerator.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 68955ae..aad1fe6 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -105,15 +105,13 @@ public: class cmGlobalXCodeGenerator::BuildObjectListOrString { cmGlobalXCodeGenerator* Generator; - cmXCodeObject* Group; - bool Empty; + cmXCodeObject* Group = nullptr; + bool Empty = true; std::string String; public: BuildObjectListOrString(cmGlobalXCodeGenerator* gen, bool buildObjectList) : Generator(gen) - , Group(nullptr) - , Empty(true) { if (buildObjectList) { this->Group = this->Generator->CreateObject(cmXCodeObject::OBJECT_LIST); -- cgit v0.12 From 709c185d8f850451d13d282c050d9d1c6a106a1a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 26 Jul 2023 15:42:45 -0400 Subject: clang-tidy: fix `bugprone-branch-clone` lints --- Source/cmGlobalXCodeGenerator.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index aad1fe6..2ce872a 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1107,8 +1107,10 @@ std::string GetSourcecodeValueFromFileExtension( } else if (ext == "storyboard") { keepLastKnownFileType = true; sourcecode = "file.storyboard"; + // NOLINTNEXTLINE(bugprone-branch-clone) } else if (ext == "mm" && !cm::contains(enabled_langs, "OBJCXX")) { sourcecode += ".cpp.objcpp"; + // NOLINTNEXTLINE(bugprone-branch-clone) } else if (ext == "m" && !cm::contains(enabled_langs, "OBJC")) { sourcecode += ".c.objc"; } else if (ext == "swift") { -- cgit v0.12 From 1c334644851fd5e5ac92748d1355da3bfdc6f85f Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 26 Jul 2023 15:43:06 -0400 Subject: clang-tidy: fix `readability-else-after-return` lints --- Source/cmGlobalXCodeGenerator.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 2ce872a..14fe832 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1179,11 +1179,11 @@ std::string GetTargetObjectDirArch(T const& target, cmList archs{ target.GetSafeProperty("OSX_ARCHITECTURES") }; if (archs.size() > 1) { return "$(CURRENT_ARCH)"; - } else if (archs.size() == 1) { + } + if (archs.size() == 1) { return archs.front(); - } else { - return defaultVal; } + return defaultVal; } } // anonymous -- cgit v0.12 From e98088ef7551f2fef31204a0a0b1dabd9ee10928 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 26 Jul 2023 15:43:20 -0400 Subject: clang-tidy: fix `modernize-use-override` lints --- Source/cmGlobalXCodeGenerator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 1fdd189..efde755 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -120,7 +120,7 @@ public: * Used to determine if this generator supports DEPFILE option. */ bool SupportsCustomCommandDepfile() const override { return true; } - virtual cm::optional DepfileFormat() const override + cm::optional DepfileFormat() const override { return this->XcodeBuildSystem == BuildSystem::One ? cmDepfileFormat::MakeDepfile -- cgit v0.12 From 22bc92fbc1bfe0bbee310c8eecf08e4eb5982b6d Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 26 Jul 2023 15:43:33 -0400 Subject: clang-tidy: fix `readability-braces-around-statements` lints --- Source/cmGlobalXCodeGenerator.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 14fe832..f1131fe 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1680,8 +1680,9 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt) if (const char* productType = GetTargetProductType(gtgt)) { if (strcmp(productType, "com.apple.product-type.app-extension.messages-sticker-pack") == - 0) + 0) { return; + } } // Add an empty source file to the target that compiles with the -- cgit v0.12 From e48dbbf048604397ec00a2f95600e57b57634577 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 09:16:02 -0400 Subject: cmCPackDragNDropGenerator: remove unnecessary string construction --- Source/CPack/cmCPackDragNDropGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index aa63ff7..bd92839 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -198,7 +198,7 @@ int cmCPackDragNDropGenerator::PackageFiles() } else { full_package_name += package_file; } - full_package_name += std::string(GetOutputExtension()); + full_package_name += GetOutputExtension(); packageFileNames.push_back(full_package_name); std::string src_dir = cmStrCat(toplevel, '/', package_file); -- cgit v0.12 From ce549909fbed7ae5567099d0f9ea2e452119181b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 26 Jul 2023 15:42:08 -0400 Subject: cmCPackPKGGenerator: remove unnecessary `.c_str()` calls --- Source/CPack/cmCPackPKGGenerator.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index 76ef091..554cfcd 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -385,11 +385,10 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name, cmValue inFileName = this->GetOption(cpackVar); if (!inFileName) { cmCPackLogger(cmCPackLog::LOG_ERROR, - "CPack option: " << cpackVar.c_str() - << " not specified. It should point to " - << (!name.empty() ? name : "") - << ".rtf, " << name << ".html, or " << name - << ".txt file" << std::endl); + "CPack option: " + << cpackVar << " not specified. It should point to " + << (!name.empty() ? name : "") << ".rtf, " << name + << ".html, or " << name << ".txt file" << std::endl); return false; } if (!cmSystemTools::FileExists(inFileName)) { @@ -454,7 +453,7 @@ int cmCPackPKGGenerator::CopyInstallScript(const std::string& resdir, { std::string dst = cmStrCat(resdir, '/', name); cmSystemTools::CopyFileAlways(script, dst); - cmSystemTools::SetPermissions(dst.c_str(), 0777); + cmSystemTools::SetPermissions(dst, 0777); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "copy script : " << script << "\ninto " << dst << std::endl); -- cgit v0.12 From c4f751604b1f76ad8d5215fb14c2838ed8c8a330 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 09:16:13 -0400 Subject: cmLocalXCodeGenerator: return a default string Instead of using the `strlen`-based constructor. --- Source/cmLocalXCodeGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index eb05424..9646e66 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -31,7 +31,7 @@ std::string cmLocalXCodeGenerator::GetTargetDirectory( cmGeneratorTarget const*) const { // No per-target directory for this generator (yet). - return ""; + return std::string{}; } void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags, -- cgit v0.12 From 3af822cd8f2197d176fa918f08f10e22dc3d4730 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 09:16:26 -0400 Subject: cmXCode21Object: simplify streaming expression --- Source/cmXCode21Object.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/cmXCode21Object.cxx b/Source/cmXCode21Object.cxx index 9b0dc58..7a40eaa 100644 --- a/Source/cmXCode21Object.cxx +++ b/Source/cmXCode21Object.cxx @@ -26,9 +26,7 @@ void cmXCode21Object::PrintComment(std::ostream& out) if (this->Comment.empty()) { return; } - out << " /* "; - out << this->Comment; - out << " */"; + out << " /* " << this->Comment << " */"; } void cmXCode21Object::PrintList( -- cgit v0.12 From f5d04b5bf0c1b610ab80209f313996f050cd5979 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 26 Jul 2023 15:39:34 -0400 Subject: cmStrCat: use where possible in Apple-specific sources --- Source/CPack/cmCPackDragNDropGenerator.cxx | 28 ++++++----- Source/CPack/cmCPackPKGGenerator.cxx | 27 +++++----- Source/CPack/cmCPackProductBuildGenerator.cxx | 26 ++++++---- Source/cmGlobalXCodeGenerator.cxx | 72 +++++++++++++-------------- Source/cmXCodeScheme.cxx | 2 +- 5 files changed, 82 insertions(+), 73 deletions(-) diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index bd92839..82f58a2 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -136,8 +136,10 @@ int cmCPackDragNDropGenerator::InitializeInternal() return 0; } for (auto const& language : languages) { - std::string license = slaDirectory + "/" + language + ".license.txt"; - std::string license_rtf = slaDirectory + "/" + language + ".license.rtf"; + std::string license = + cmStrCat(slaDirectory, "/", language, ".license.txt"); + std::string license_rtf = + cmStrCat(slaDirectory, "/", language, ".license.rtf"); if (!singleLicense) { if (!cmSystemTools::FileExists(license) && !cmSystemTools::FileExists(license_rtf)) { @@ -148,7 +150,7 @@ int cmCPackDragNDropGenerator::InitializeInternal() return 0; } } - std::string menu = slaDirectory + "/" + language + ".menu.txt"; + std::string menu = cmStrCat(slaDirectory, "/", language, ".menu.txt"); if (!cmSystemTools::FileExists(menu)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing menu file " << language << ".menu.txt" @@ -192,7 +194,7 @@ int cmCPackDragNDropGenerator::PackageFiles() // loop to create dmg files packageFileNames.clear(); for (auto const& package_file : package_files) { - std::string full_package_name = std::string(toplevel) + std::string("/"); + std::string full_package_name = cmStrCat(toplevel, "/"); if (package_file == "ALL_IN_ONE") { full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME"); } else { @@ -711,8 +713,8 @@ std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix( if (this->componentPackageMethod == ONE_PACKAGE_PER_GROUP) { // We have to find the name of the COMPONENT GROUP // the current COMPONENT belongs to. - std::string groupVar = - "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; + std::string groupVar = cmStrCat( + "CPACK_COMPONENT_", cmSystemTools::UpperCase(componentName), "_GROUP"); cmValue _groupName = this->GetOption(groupVar); if (_groupName) { std::string groupName = _groupName; @@ -723,8 +725,8 @@ std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix( } } - std::string componentFileName = - "CPACK_DMG_" + cmSystemTools::UpperCase(componentName) + "_FILE_NAME"; + std::string componentFileName = cmStrCat( + "CPACK_DMG_", cmSystemTools::UpperCase(componentName), "_FILE_NAME"); if (this->IsSet(componentFileName)) { return this->GetOption(componentFileName); } @@ -808,12 +810,12 @@ bool cmCPackDragNDropGenerator::WriteLicense(RezDoc& rez, size_t licenseNumber, actual_license = licenseFile; } else { std::string license_wo_ext = - slaDirectory + "/" + licenseLanguage + ".license"; - if (cmSystemTools::FileExists(license_wo_ext + ".txt")) { - actual_license = license_wo_ext + ".txt"; + cmStrCat(slaDirectory, "/", licenseLanguage, ".license"); + if (cmSystemTools::FileExists(cmStrCat(license_wo_ext, ".txt"))) { + actual_license = cmStrCat(license_wo_ext, ".txt"); } else { licenseArray = &rez.RTF; - actual_license = license_wo_ext + ".rtf"; + actual_license = cmStrCat(license_wo_ext, ".rtf"); } } @@ -836,7 +838,7 @@ bool cmCPackDragNDropGenerator::WriteLicense(RezDoc& rez, size_t licenseNumber, } else { std::vector lines; std::string actual_menu = - slaDirectory + "/" + licenseLanguage + ".menu.txt"; + cmStrCat(slaDirectory, "/", licenseLanguage, ".menu.txt"); if (!this->ReadFile(actual_menu, lines, error)) { return false; } diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index 554cfcd..f113ff4 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -38,13 +38,12 @@ std::string cmCPackPKGGenerator::GetPackageName( if (component.ArchiveFile.empty()) { std::string packagesDir = cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), ".dummy"); - std::ostringstream out; - out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-" - << component.Name << ".pkg"; - return out.str(); + return cmStrCat( + cmSystemTools::GetFilenameWithoutLastExtension(packagesDir), "-", + component.Name, ".pkg"); } - return component.ArchiveFile + ".pkg"; + return cmStrCat(component.ArchiveFile, ".pkg"); } void cmCPackPKGGenerator::CreateBackground(const char* themeName, @@ -160,14 +159,15 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile, for (auto const& comp : this->Components) { if (!comp.second.Group) { xChoiceOut.StartElement("line"); - xChoiceOut.Attribute("choice", comp.first + "Choice"); + xChoiceOut.Attribute("choice", cmStrCat(comp.first, "Choice")); xChoiceOut.Content(""); // Avoid self-closing tag. xChoiceOut.EndElement(); } } if (!this->PostFlightComponent.Name.empty()) { xChoiceOut.StartElement("line"); - xChoiceOut.Attribute("choice", PostFlightComponent.Name + "Choice"); + xChoiceOut.Attribute("choice", + cmStrCat(PostFlightComponent.Name, "Choice")); xChoiceOut.Content(""); // Avoid self-closing tag. xChoiceOut.EndElement(); } @@ -207,14 +207,14 @@ void cmCPackPKGGenerator::CreateChoiceOutline( const cmCPackComponentGroup& group, cmXMLWriter& xout) { xout.StartElement("line"); - xout.Attribute("choice", group.Name + "Choice"); + xout.Attribute("choice", cmStrCat(group.Name, "Choice")); for (cmCPackComponentGroup* subgroup : group.Subgroups) { CreateChoiceOutline(*subgroup, xout); } for (cmCPackComponent* comp : group.Components) { xout.StartElement("line"); - xout.Attribute("choice", comp->Name + "Choice"); + xout.Attribute("choice", cmStrCat(comp->Name, "Choice")); xout.Content(""); // Avoid self-closing tag. xout.EndElement(); } @@ -225,7 +225,7 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponentGroup& group, cmXMLWriter& xout) { xout.StartElement("choice"); - xout.Attribute("id", group.Name + "Choice"); + xout.Attribute("id", cmStrCat(group.Name, "Choice")); xout.Attribute("title", group.DisplayName); xout.Attribute("start_selected", "true"); xout.Attribute("start_enabled", "true"); @@ -249,7 +249,7 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component, } xout.StartElement("choice"); - xout.Attribute("id", component.Name + "Choice"); + xout.Attribute("id", cmStrCat(component.Name, "Choice")); xout.Attribute("title", component.DisplayName); xout.Attribute( "start_selected", @@ -381,7 +381,7 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name, const std::string& dirName) { std::string uname = cmSystemTools::UpperCase(name); - std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; + std::string cpackVar = cmStrCat("CPACK_RESOURCE_FILE_", uname); cmValue inFileName = this->GetOption(cpackVar); if (!inFileName) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -413,7 +413,8 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name, // Set this so that distribution.dist gets the right name (without // the path). - this->SetOption("CPACK_RESOURCE_FILE_" + uname + "_NOPATH", (name + ext)); + this->SetOption(cmStrCat("CPACK_RESOURCE_FILE_", uname, "_NOPATH"), + cmStrCat(name, ext)); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << (inFileName ? *inFileName : "(NULL)") diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index 4ad616d..843219d 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -58,7 +58,7 @@ int cmCPackProductBuildGenerator::PackageFiles() } } - std::string resDir = packageDirFileName + "/Contents"; + std::string resDir = cmStrCat(packageDirFileName, "/Contents"); if (this->IsSet("CPACK_PRODUCTBUILD_RESOURCES_DIR")) { std::string userResDir = @@ -106,10 +106,14 @@ int cmCPackProductBuildGenerator::PackageFiles() << "\"" << " --resources \"" << resDir << "\"" << " --version \"" << version << "\"" - << (identifier.empty() ? "" : " --identifier \"" + identifier + "\"") - << (identityName.empty() ? "" : " --sign \"" + identityName + "\"") - << (keychainPath.empty() ? "" - : " --keychain \"" + keychainPath + "\"") + << (identifier.empty() + ? std::string{} + : cmStrCat(" --identifier \"", identifier, '"')) + << (identityName.empty() ? std::string{} + : cmStrCat(" --sign \"", identityName, '"')) + << (keychainPath.empty() + ? std::string{} + : cmStrCat(" --keychain \"", keychainPath, '"')) << " \"" << packageFileNames[0] << "\""; // Run ProductBuild @@ -187,7 +191,7 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( resDir += "/"; resDir += component->Name; } - std::string scriptDir = resDir + "/scripts"; + std::string scriptDir = cmStrCat(resDir, "/scripts"); if (!cmsys::SystemTools::MakeDirectory(scriptDir.c_str())) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -237,9 +241,11 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( << " --scripts \"" << scriptDir << "\"" << " --version \"" << version << "\"" << " --install-location \"/\"" - << (identityName.empty() ? "" : " --sign \"" + identityName + "\"") - << (keychainPath.empty() ? "" - : " --keychain \"" + keychainPath + "\"") + << (identityName.empty() ? std::string{} + : cmStrCat(" --sign \"", identityName, "\"")) + << (keychainPath.empty() + ? std::string{} + : cmStrCat(" --keychain \"", keychainPath, "\"")) << " \"" << packageFile << "\""; if (component && !component->Plist.empty()) { @@ -253,7 +259,7 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( cmValue cmCPackProductBuildGenerator::GetComponentScript( const char* script, const char* component_name) { - std::string scriptname = std::string("CPACK_") + script + "_"; + std::string scriptname = cmStrCat("CPACK_", script, "_"); if (component_name) { scriptname += cmSystemTools::UpperCase(component_name); scriptname += "_"; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index f1131fe..b7766dc 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -226,7 +226,8 @@ cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(const std::string& name, if (commandResult) { std::string::size_type pos = out.find(".app/"); if (pos != std::string::npos) { - versionFile = out.substr(0, pos + 5) + "Contents/version.plist"; + versionFile = + cmStrCat(out.substr(0, pos + 5), "Contents/version.plist"); } } } @@ -248,7 +249,7 @@ cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(const std::string& name, if (version_number < 50) { cm->IssueMessage(MessageType::FATAL_ERROR, - "Xcode " + version_string + " not supported."); + cmStrCat("Xcode ", version_string, " not supported.")); return std::unique_ptr(); } @@ -450,7 +451,7 @@ bool cmGlobalXCodeGenerator::Open(const std::string& bindir, bool ret = false; #ifdef HAVE_APPLICATION_SERVICES - std::string url = bindir + "/" + projectName + ".xcodeproj"; + std::string url = cmStrCat(bindir, "/", projectName, ".xcodeproj"); if (dryRun) { return cmSystemTools::FileExists(url, false); @@ -852,10 +853,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateFlatClone(cmXCodeObject* orig) static std::string GetGroupMapKeyFromPath(cmGeneratorTarget* target, const std::string& fullpath) { - std::string key(target->GetName()); - key += "-"; - key += fullpath; - return key; + return cmStrCat(target->GetName(), "-", fullpath); } cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeBuildFileFromPath( @@ -943,10 +941,10 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( std::string const& srcfmt = sf->GetSafeProperty("Fortran_FORMAT"); switch (cmOutputConverter::GetFortranFormat(srcfmt)) { case cmOutputConverter::FortranFormatFixed: - flags = "-fixed " + flags; + flags = cmStrCat("-fixed ", flags); break; case cmOutputConverter::FortranFormatFree: - flags = "-free " + flags; + flags = cmStrCat("-free ", flags); break; default: break; @@ -1278,7 +1276,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( this->GroupMap[key] = group; } if (!group) { - cmSystemTools::Error("Could not find a PBX group for " + key); + cmSystemTools::Error(cmStrCat("Could not find a PBX group for ", key)); return nullptr; } cmXCodeObject* children = group->GetAttribute("children"); @@ -2202,10 +2200,10 @@ void cmGlobalXCodeGenerator::AddCommandsToBuildPhase( std::string cdir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory(); cdir = this->ConvertToRelativeForMake(cdir); - std::string makecmd = - cmStrCat("make -C ", cdir, " -f ", - this->ConvertToRelativeForMake((makefile + "$CONFIGURATION")), - " OBJDIR=$(basename \"$OBJECT_FILE_DIR_normal\") all"); + std::string makecmd = cmStrCat( + "make -C ", cdir, " -f ", + this->ConvertToRelativeForMake(cmStrCat(makefile, "$CONFIGURATION")), + " OBJDIR=$(basename \"$OBJECT_FILE_DIR_normal\") all"); buildphase->AddAttribute("shellScript", this->CreateString(makecmd)); buildphase->AddAttribute("showEnvVarsInLog", this->CreateString("0")); } @@ -2243,7 +2241,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( } else { std::ostringstream str; str << "_buildpart_" << count++; - tname[&ccg.GetCC()] = target->GetName() + str.str(); + tname[&ccg.GetCC()] = cmStrCat(target->GetName(), str.str()); makefileStream << "\\\n\t" << tname[&ccg.GetCC()]; } } @@ -2407,8 +2405,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::string llang = gtgt->GetLinkerLanguage(configName); if (binary && llang.empty()) { cmSystemTools::Error( - "CMake can not determine linker language for target: " + - gtgt->GetName()); + cmStrCat("CMake can not determine linker language for target: ", + gtgt->GetName())); return; } @@ -2472,7 +2470,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::set defines(targetSwiftDefines.begin(), targetSwiftDefines.end()); this->CurrentLocalGenerator->JoinDefines(defines, defineString, "Swift"); - cflags["Swift"] += " " + defineString; + cflags["Swift"] += cmStrCat(" ", defineString); } else { BuildObjectListOrString swiftDefs(this, true); this->AppendDefines(swiftDefs, targetSwiftDefines); @@ -2831,7 +2829,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, includes, gtgt, language, configName); if (!includeFlags.empty()) { - cflags[language] += " " + includeFlags; + cflags[language] += cmStrCat(" ", includeFlags); } } } @@ -2909,7 +2907,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, this->CreateString("NO")); for (auto const& language : languages) { - std::string flags = cflags[language] + " " + defFlags; + std::string flags = cmStrCat(cflags[language], " ", defFlags); if (language == "CXX" || language == "OBJCXX") { if (language == "CXX" || !buildSettings->GetAttribute("OTHER_CPLUSPLUSFLAGS")) { @@ -3459,8 +3457,8 @@ void cmGlobalXCodeGenerator::AppendBuildSettingAttribute( { if (value->GetType() != cmXCodeObject::OBJECT_LIST && value->GetType() != cmXCodeObject::STRING) { - cmSystemTools::Error("Unsupported value type for appending: " + - std::string(attribute)); + cmSystemTools::Error( + cmStrCat("Unsupported value type for appending: ", attribute)); return; } if (attr->GetType() == cmXCodeObject::OBJECT_LIST) { @@ -3483,8 +3481,8 @@ void cmGlobalXCodeGenerator::AppendBuildSettingAttribute( attr->SetString(newValue); } } else { - cmSystemTools::Error("Unsupported attribute type for appending: " + - std::string(attribute)); + cmSystemTools::Error( + cmStrCat("Unsupported attribute type for appending: ", attribute)); } } @@ -3581,8 +3579,8 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) useLinkPhase = true; forceLinkPhase = true; } else if (*prop != "NONE") { - cmSystemTools::Error("Invalid value for XCODE_LINK_BUILD_PHASE_MODE: " + - *prop); + cmSystemTools::Error( + cmStrCat("Invalid value for XCODE_LINK_BUILD_PHASE_MODE: ", *prop)); return; } } @@ -3874,8 +3872,8 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) cmPolicies::PolicyStatus cmp0142 = target->GetTarget()->GetPolicyStatusCMP0142(); if (cmp0142 == cmPolicies::OLD || cmp0142 == cmPolicies::WARN) { - libSearchPaths.Add(this->XCodeEscapePath( - libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)")); + libSearchPaths.Add(this->XCodeEscapePath(cmStrCat( + libDir, "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"))); } libSearchPaths.Add(this->XCodeEscapePath(libDir)); } @@ -4087,16 +4085,16 @@ void cmGlobalXCodeGenerator::AddEmbeddedObjects( // This is a target - get it's product path reference auto* xcTarget = this->FindXCodeTarget(genTarget); if (!xcTarget) { - cmSystemTools::Error("Can not find a target for " + - genTarget->GetName()); + cmSystemTools::Error( + cmStrCat("Can not find a target for ", genTarget->GetName())); continue; } // Add the target output file as a build reference for other targets // to link against auto* fileRefObject = xcTarget->GetAttribute("productReference"); if (!fileRefObject) { - cmSystemTools::Error("Target " + genTarget->GetName() + - " is missing product reference"); + cmSystemTools::Error(cmStrCat("Target ", genTarget->GetName(), + " is missing product reference")); continue; } auto it = this->FileRefToEmbedBuildFileMap.find(fileRefObject); @@ -4121,7 +4119,8 @@ void cmGlobalXCodeGenerator::AddEmbeddedObjects( this->CreateObjectReference(fileRef)); } if (!buildFile) { - cmSystemTools::Error("Can't create build file for " + relFile); + cmSystemTools::Error( + cmStrCat("Can't create build file for ", relFile)); continue; } this->EmbeddedLibRefs.emplace(filePath, buildFile); @@ -4130,7 +4129,7 @@ void cmGlobalXCodeGenerator::AddEmbeddedObjects( } } if (!buildFile) { - cmSystemTools::Error("Can't find a build file for " + relFile); + cmSystemTools::Error(cmStrCat("Can't find a build file for ", relFile)); continue; } // Set build file configuration @@ -4689,7 +4688,8 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile( { cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile); if (!makefileStream) { - cmSystemTools::Error("Could not create " + this->CurrentXCodeHackMakefile); + cmSystemTools::Error( + cmStrCat("Could not create ", this->CurrentXCodeHackMakefile)); return; } makefileStream.SetCopyIfDifferent(true); @@ -4817,7 +4817,7 @@ void cmGlobalXCodeGenerator::OutputXCodeProject( std::string xcodeDir = cmStrCat(root->GetCurrentBinaryDirectory(), '/', root->GetProjectName(), ".xcodeproj"); cmSystemTools::MakeDirectory(xcodeDir); - std::string xcodeProjFile = xcodeDir + "/project.pbxproj"; + std::string xcodeProjFile = cmStrCat(xcodeDir, "/project.pbxproj"); cmGeneratedFileStream fout(xcodeProjFile); fout.SetCopyIfDifferent(true); if (!fout) { diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index 217ac61..0019278 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -447,7 +447,7 @@ void cmXCodeScheme::WriteBuildableReference(cmXMLWriter& xout, std::string const noConfig; // FIXME: What config to use here? xout.Attribute("BuildableName", xcObj->GetTarget()->GetFullName(noConfig)); xout.Attribute("BlueprintName", xcObj->GetTarget()->GetName()); - xout.Attribute("ReferencedContainer", "container:" + container); + xout.Attribute("ReferencedContainer", cmStrCat("container:", container)); xout.EndElement(); } -- cgit v0.12 From e1b70d7286d8a53b5046b1fb5e2b042333f5b736 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 26 Jul 2023 15:40:26 -0400 Subject: cmCPackDragNDropGenerator: use a string instead of a stream for commands --- Source/CPack/cmCPackBundleGenerator.cxx | 36 +++++------ Source/CPack/cmCPackDragNDropGenerator.cxx | 97 +++++++++++++++++------------- Source/CPack/cmCPackDragNDropGenerator.h | 2 +- 3 files changed, 70 insertions(+), 65 deletions(-) diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index 7e6e473..dad404a 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -196,15 +196,11 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir) // sign the files supplied by the user, ie. frameworks. for (auto const& file : relFiles) { - std::ostringstream temp_sign_file_cmd; - temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); - temp_sign_file_cmd << " " << sign_parameter << " -s \"" - << cpack_apple_cert_app; - temp_sign_file_cmd << "\" -i "; - temp_sign_file_cmd << this->GetOption("CPACK_APPLE_BUNDLE_ID"); - temp_sign_file_cmd << " \""; - temp_sign_file_cmd << bundle_path; - temp_sign_file_cmd << file << "\""; + auto temp_sign_file_cmd = + cmStrCat(this->GetOption("CPACK_COMMAND_CODESIGN"), ' ', + sign_parameter, " -s \"", cpack_apple_cert_app, "\" -i ", + this->GetOption("CPACK_APPLE_BUNDLE_ID"), " \"", bundle_path, + file, '"'); if (!this->RunCommand(temp_sign_file_cmd, &output)) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -216,11 +212,9 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir) } // sign main binary - std::ostringstream temp_sign_binary_cmd; - temp_sign_binary_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); - temp_sign_binary_cmd << " " << sign_parameter << " -s \"" - << cpack_apple_cert_app; - temp_sign_binary_cmd << "\" \"" << bundle_path << "\""; + auto temp_sign_binary_cmd = + cmStrCat(this->GetOption("CPACK_COMMAND_CODESIGN"), ' ', sign_parameter, + " -s \"", cpack_apple_cert_app, "\" \"", bundle_path, '"'); if (!this->RunCommand(temp_sign_binary_cmd, &output)) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -232,15 +226,15 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir) } // sign app bundle - std::ostringstream temp_codesign_cmd; - temp_codesign_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); - temp_codesign_cmd << " " << sign_parameter << " -s \"" - << cpack_apple_cert_app << "\""; + auto temp_codesign_cmd = + cmStrCat(this->GetOption("CPACK_COMMAND_CODESIGN"), ' ', sign_parameter, + " -s \"", cpack_apple_cert_app, "\""); if (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")) { - temp_codesign_cmd << " --entitlements "; - temp_codesign_cmd << this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS"); + temp_codesign_cmd += + cmStrCat(" --entitlements ", + this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")); } - temp_codesign_cmd << " \"" << bundle_path << "\""; + temp_codesign_cmd += cmStrCat(" \"", bundle_path, '"'); if (!this->RunCommand(temp_codesign_cmd, &output)) { cmCPackLogger(cmCPackLog::LOG_ERROR, diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 82f58a2..3beba64 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -243,18 +243,18 @@ bool cmCPackDragNDropGenerator::CreateEmptyFile(std::ostringstream& target, return true; } -bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command, +bool cmCPackDragNDropGenerator::RunCommand(std::string const& command, std::string* output) { int exit_code = 1; bool result = cmSystemTools::RunSingleCommand( - command.str(), output, output, &exit_code, nullptr, this->GeneratorVerbose, + command, output, output, &exit_code, nullptr, this->GeneratorVerbose, cmDuration::zero()); if (!result || exit_code) { cmCPackLogger(cmCPackLog::LOG_ERROR, - "Error executing: " << command.str() << std::endl); + "Error executing: " << command << std::endl); return false; } @@ -412,15 +412,21 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/temp.dmg"); std::string create_error; - std::ostringstream temp_image_command; - temp_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); - temp_image_command << " create"; - temp_image_command << " -ov"; - temp_image_command << " -srcfolder \"" << staging.str() << "\""; - temp_image_command << " -volname \"" << cpack_dmg_volume_name << "\""; - temp_image_command << " -fs \"" << cpack_dmg_filesystem << "\""; - temp_image_command << " -format " << temp_image_format; - temp_image_command << " \"" << temp_image << "\""; + auto temp_image_command = + cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"), + " create" + " -ov" + " -srcfolder \"", + staging.str(), + "\"" + " -volname \"", + cpack_dmg_volume_name, + "\"" + " -fs \"", + cpack_dmg_filesystem, + "\"" + " -format ", + temp_image_format, " \"", temp_image, "\""); if (!this->RunCommand(temp_image_command, &create_error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -436,10 +442,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, // before we exit. bool had_error = false; - std::ostringstream attach_command; - attach_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); - attach_command << " attach"; - attach_command << " \"" << temp_image << "\""; + auto attach_command = cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"), + " attach" + " \"", + temp_image, "\""); std::string attach_output; if (!this->RunCommand(attach_command, &attach_output)) { @@ -468,10 +474,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, // Optionally set the custom icon flag for the image ... if (!had_error && !cpack_package_icon->empty()) { std::string error; - std::ostringstream setfile_command; - setfile_command << this->GetOption("CPACK_COMMAND_SETFILE"); - setfile_command << " -a C"; - setfile_command << " \"" << temp_mount << "\""; + auto setfile_command = cmStrCat(this->GetOption("CPACK_COMMAND_SETFILE"), + " -a C" + " \"", + temp_mount, "\""); if (!this->RunCommand(setfile_command, &error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -486,10 +492,12 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, // Optionally we can execute a custom apple script to generate // the .DS_Store for the volume folder ... if (!had_error && !cpack_dmg_ds_store_setup_script->empty()) { - std::ostringstream setup_script_command; - setup_script_command << "osascript" - << " \"" << cpack_dmg_ds_store_setup_script << "\"" - << " \"" << temp_mount_name << "\""; + auto setup_script_command = cmStrCat("osascript" + " \"", + cpack_dmg_ds_store_setup_script, + "\"" + " \"", + temp_mount_name, "\""); std::string error; if (!this->RunCommand(setup_script_command, &error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -501,10 +509,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, } } - std::ostringstream detach_command; - detach_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); - detach_command << " detach"; - detach_command << " \"" << temp_mount << "\""; + auto detach_command = cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"), + " detach" + " \"", + temp_mount, '\"'); if (!this->RunCommand(detach_command)) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -519,14 +527,15 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, } // Create the final compressed read-only disk image ... - std::ostringstream final_image_command; - final_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); - final_image_command << " convert \"" << temp_image << "\""; - final_image_command << " -format "; - final_image_command << cpack_dmg_format; - final_image_command << " -imagekey"; - final_image_command << " zlib-level=9"; - final_image_command << " -o \"" << output_file << "\""; + auto final_image_command = cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"), + " convert \"", temp_image, + "\"" + " -format ", + cpack_dmg_format, + " -imagekey" + " zlib-level=9" + " -o \"", + output_file, "\""); std::string convert_error; @@ -667,13 +676,15 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, this->WriteRezXML(sla_xml, rez); // Create the final compressed read-only disk image ... - std::ostringstream embed_sla_command; - embed_sla_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); - embed_sla_command << " udifrez"; - embed_sla_command << " -xml"; - embed_sla_command << " \"" << sla_xml << "\""; - embed_sla_command << " FIXME_WHY_IS_THIS_ARGUMENT_NEEDED"; - embed_sla_command << " \"" << output_file << "\""; + auto embed_sla_command = cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"), + " udifrez" + " -xml" + " \"", + sla_xml, + "\"" + " FIXME_WHY_IS_THIS_ARGUMENT_NEEDED" + " \"", + output_file, "\""); std::string embed_error; if (!this->RunCommand(embed_sla_command, &embed_error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h index 6d1267b..6089ae5 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.h +++ b/Source/CPack/cmCPackDragNDropGenerator.h @@ -33,7 +33,7 @@ protected: bool CopyFile(std::ostringstream& source, std::ostringstream& target); bool CreateEmptyFile(std::ostringstream& target, size_t size); - bool RunCommand(std::ostringstream& command, std::string* output = nullptr); + bool RunCommand(std::string const& command, std::string* output = nullptr); std::string GetComponentInstallDirNameSuffix( const std::string& componentName) override; -- cgit v0.12 From 1b60137b98b26866c84ca29aee62031d429f34a5 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 26 Jul 2023 15:40:56 -0400 Subject: strings: combine string literals --- Source/CPack/cmCPackBundleGenerator.cxx | 20 ++++++----- Source/CPack/cmCPackProductBuildGenerator.cxx | 28 ++++++++++----- Source/cmGlobalXCodeGenerator.cxx | 52 ++++++++++++++------------- 3 files changed, 59 insertions(+), 41 deletions(-) diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index dad404a..37be798 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -86,24 +86,28 @@ int cmCPackBundleGenerator::ConstructBundle() std::string const staging = toplevel; std::ostringstream contents; - contents << staging << "/" << cpack_bundle_name << ".app/" - << "Contents"; + contents << staging << "/" << cpack_bundle_name + << ".app/" + "Contents"; std::ostringstream application; - application << contents.str() << "/" - << "MacOS"; + application << contents.str() + << "/" + "MacOS"; std::ostringstream resources; - resources << contents.str() << "/" - << "Resources"; + resources << contents.str() + << "/" + "Resources"; // Install a required, user-provided bundle metadata file ... std::ostringstream plist_source; plist_source << cpack_bundle_plist; std::ostringstream plist_target; - plist_target << contents.str() << "/" - << "Info.plist"; + plist_target << contents.str() + << "/" + "Info.plist"; if (!this->CopyFile(plist_source, plist_target)) { cmCPackLogger( diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index 843219d..fd3c659 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -102,10 +102,15 @@ int cmCPackProductBuildGenerator::PackageFiles() pkgCmd << productbuild << " --distribution \"" << packageDirFileName << "/Contents/distribution.dist\"" - << " --package-path \"" << packageDirFileName << "/Contents/Packages" + " --package-path \"" + << packageDirFileName + << "/Contents/Packages" + "\"" + " --resources \"" + << resDir << "\"" - << " --resources \"" << resDir << "\"" - << " --version \"" << version << "\"" + " --version \"" + << version << "\"" << (identifier.empty() ? std::string{} : cmStrCat(" --identifier \"", identifier, '"')) @@ -236,11 +241,18 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( keychainPath = p; } - pkgCmd << pkgbuild << " --root \"" << packageDir << "\"" - << " --identifier \"" << pkgId << "\"" - << " --scripts \"" << scriptDir << "\"" - << " --version \"" << version << "\"" - << " --install-location \"/\"" + pkgCmd << pkgbuild << " --root \"" << packageDir + << "\"" + " --identifier \"" + << pkgId + << "\"" + " --scripts \"" + << scriptDir + << "\"" + " --version \"" + << version + << "\"" + " --install-location \"/\"" << (identityName.empty() ? std::string{} : cmStrCat(" --sign \"", identityName, "\"")) << (keychainPath.empty() diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b7766dc..5411a23 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -721,12 +721,12 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( this->CurrentReRunCMakeMakefile += "/ReRunCMake.make"; cmGeneratedFileStream makefileStream(this->CurrentReRunCMakeMakefile); makefileStream.SetCopyIfDifferent(true); - makefileStream << "# Generated by CMake, DO NOT EDIT\n\n"; + makefileStream << "# Generated by CMake, DO NOT EDIT\n\n" - makefileStream << "TARGETS:= \n"; - makefileStream << "empty:= \n"; - makefileStream << "space:= $(empty) $(empty)\n"; - makefileStream << "spaceplus:= $(empty)\\ $(empty)\n\n"; + "TARGETS:= \n" + "empty:= \n" + "space:= $(empty) $(empty)\n" + "spaceplus:= $(empty)\\ $(empty)\n\n"; for (const auto& lfile : lfiles) { makefileStream << "TARGETS += $(subst $(space),$(spaceplus),$(wildcard " @@ -738,12 +738,13 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( cmStrCat(root->GetBinaryDirectory(), "/CMakeFiles/cmake.check_cache"); if (cm->DoWriteGlobVerifyTarget()) { - makefileStream << ".NOTPARALLEL:\n\n"; - makefileStream << ".PHONY: all VERIFY_GLOBS\n\n"; - makefileStream << "all: VERIFY_GLOBS " - << this->ConvertToRelativeForMake(checkCache) << "\n\n"; - makefileStream << "VERIFY_GLOBS:\n"; - makefileStream << "\t" + makefileStream << ".NOTPARALLEL:\n\n" + ".PHONY: all VERIFY_GLOBS\n\n" + "all: VERIFY_GLOBS " + << this->ConvertToRelativeForMake(checkCache) + << "\n\n" + "VERIFY_GLOBS:\n" + "\t" << this->ConvertToRelativeForMake( cmSystemTools::GetCMakeCommand()) << " -P " @@ -2218,12 +2219,13 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( return; } makefileStream.SetCopyIfDifferent(true); - makefileStream << "# Generated by CMake, DO NOT EDIT\n"; - makefileStream << "# Custom rules for " << target->GetName() << "\n"; + makefileStream << "# Generated by CMake, DO NOT EDIT\n" + "# Custom rules for " + << target->GetName() << '\n'; // disable the implicit rules makefileStream << ".SUFFIXES: " - << "\n"; + "\n"; // have all depend on all outputs makefileStream << "all: "; @@ -4696,9 +4698,9 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile( // one more pass for external depend information not handled // correctly by xcode /* clang-format off */ - makefileStream << "# DO NOT EDIT\n"; - makefileStream << "# This makefile makes sure all linkable targets are\n"; - makefileStream << "# up-to-date with anything they link to\n" + makefileStream << "# DO NOT EDIT\n" + "# This makefile makes sure all linkable targets are\n" + "# up-to-date with anything they link to\n" "default:\n" "\techo \"Do not invoke directly\"\n" "\n"; @@ -4776,8 +4778,8 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile( } // Write the action to remove the target if it is out of date. - makefileStream << "\n"; - makefileStream << "\t/bin/rm -f " + makefileStream << "\n" + "\t/bin/rm -f " << this->ConvertToRelativeForMake(tfull) << "\n"; // if building for more than one architecture // then remove those executables as well @@ -4798,8 +4800,8 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile( } makefileStream << "\n\n" - << "# For each target create a dummy rule" - << "so the target does not have to exist\n"; + "# For each target create a dummy rule" + "so the target does not have to exist\n"; for (auto const& dummyRule : dummyRules) { makefileStream << dummyRule << ":\n"; } @@ -4942,8 +4944,8 @@ void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout, { SortXCodeObjects(); - fout << "// !$*UTF8*$!\n"; - fout << "{\n"; + fout << "// !$*UTF8*$!\n" + "{\n"; cmXCodeObject::Indent(1, fout); fout << "archiveVersion = 1;\n"; cmXCodeObject::Indent(1, fout); @@ -4955,8 +4957,8 @@ void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout, cmXCode21Object::PrintList(this->XCodeObjects, fout); cmXCodeObject::Indent(1, fout); fout << "rootObject = " << this->RootObject->GetId() - << " /* Project object */;\n"; - fout << "}\n"; + << " /* Project object */;\n" + "}\n"; } const char* cmGlobalXCodeGenerator::GetCMakeCFGIntDir() const -- cgit v0.12 From 6aa90237006f1c4556e0cd18ae0e493650e7515c Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 09:06:36 -0400 Subject: string_view: use string_view literals in comparisons --- Source/CPack/cmCPackDragNDropGenerator.cxx | 5 +- Source/CPack/cmCPackPKGGenerator.cxx | 5 +- Source/cmGlobalXCodeGenerator.cxx | 126 ++++++++++++++--------------- Source/cmXCodeObject.cxx | 10 ++- Source/cmXCodeScheme.cxx | 3 +- Source/cmXcFramework.cxx | 15 ++-- 6 files changed, 87 insertions(+), 77 deletions(-) diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 3beba64..c7b8bfe 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -7,6 +7,9 @@ #include #include +#include +#include + #include #include @@ -195,7 +198,7 @@ int cmCPackDragNDropGenerator::PackageFiles() packageFileNames.clear(); for (auto const& package_file : package_files) { std::string full_package_name = cmStrCat(toplevel, "/"); - if (package_file == "ALL_IN_ONE") { + if (package_file == "ALL_IN_ONE"_s) { full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME"); } else { full_package_name += package_file; diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index f113ff4..13135f5 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -4,6 +4,8 @@ #include +#include + #include "cmCPackComponentGroup.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" @@ -399,7 +401,8 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name, return false; } std::string ext = cmSystemTools::GetFilenameLastExtension(inFileName); - if (ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt") { + if (ext != ".rtfd"_s && ext != ".rtf"_s && ext != ".html"_s && + ext != ".txt"_s) { cmCPackLogger( cmCPackLog::LOG_ERROR, "Bad file extension specified: " diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 5411a23..3b19808 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -82,10 +82,10 @@ public: } void EndElement(const std::string& name) override { - if (name == "key") { + if (name == "key"_s) { this->Key = this->Data; - } else if (name == "string") { - if (this->Key == "CFBundleShortVersionString") { + } else if (name == "string"_s) { + if (this->Key == "CFBundleShortVersionString"_s) { this->Version = this->Data; } } @@ -389,7 +389,7 @@ bool cmGlobalXCodeGenerator::ParseGeneratorToolset(std::string const& ts, bool cmGlobalXCodeGenerator::ProcessGeneratorToolsetField( std::string const& key, std::string const& value, cmMakefile* mf) { - if (key == "buildsystem") { + if (key == "buildsystem"_s) { if (value == "1"_s) { this->XcodeBuildSystem = BuildSystem::One; } else if (value == "12"_s) { @@ -1059,30 +1059,30 @@ bool IsLinkPhaseLibraryExtension(const std::string& fileExt) { // Empty file extension is a special case for paths to framework's // internal binary which could be MyFw.framework/Versions/*/MyFw - return (fileExt == ".framework" || fileExt == ".xcframework" || - fileExt == ".a" || fileExt == ".o" || fileExt == ".dylib" || - fileExt == ".tbd" || fileExt.empty()); + return (fileExt == ".framework"_s || fileExt == ".xcframework"_s || + fileExt == ".a"_s || fileExt == ".o"_s || fileExt == ".dylib"_s || + fileExt == ".tbd"_s || fileExt.empty()); } bool IsLibraryType(const std::string& fileType) { - return (fileType == "wrapper.framework" || - fileType == "wrapper.xcframework" || fileType == "archive.ar" || - fileType == "compiled.mach-o.objfile" || - fileType == "compiled.mach-o.dylib" || - fileType == "compiled.mach-o.executable" || - fileType == "sourcecode.text-based-dylib-definition"); + return (fileType == "wrapper.framework"_s || + fileType == "wrapper.xcframework"_s || fileType == "archive.ar"_s || + fileType == "compiled.mach-o.objfile"_s || + fileType == "compiled.mach-o.dylib"_s || + fileType == "compiled.mach-o.executable"_s || + fileType == "sourcecode.text-based-dylib-definition"_s); } std::string GetDirectoryValueFromFileExtension(const std::string& dirExt) { std::string ext = cmSystemTools::LowerCase(dirExt); - if (ext == "framework") { + if (ext == "framework"_s) { return "wrapper.framework"; } - if (ext == "xcframework") { + if (ext == "xcframework"_s) { return "wrapper.xcframework"; } - if (ext == "xcassets") { + if (ext == "xcassets"_s) { return "folder.assetcatalog"; } return "folder"; @@ -1095,68 +1095,68 @@ std::string GetSourcecodeValueFromFileExtension( std::string ext = cmSystemTools::LowerCase(_ext); std::string sourcecode = "sourcecode"; - if (ext == "o") { + if (ext == "o"_s) { keepLastKnownFileType = true; sourcecode = "compiled.mach-o.objfile"; - } else if (ext == "xctest") { + } else if (ext == "xctest"_s) { sourcecode = "wrapper.cfbundle"; - } else if (ext == "xib") { + } else if (ext == "xib"_s) { keepLastKnownFileType = true; sourcecode = "file.xib"; - } else if (ext == "storyboard") { + } else if (ext == "storyboard"_s) { keepLastKnownFileType = true; sourcecode = "file.storyboard"; // NOLINTNEXTLINE(bugprone-branch-clone) - } else if (ext == "mm" && !cm::contains(enabled_langs, "OBJCXX")) { + } else if (ext == "mm"_s && !cm::contains(enabled_langs, "OBJCXX")) { sourcecode += ".cpp.objcpp"; // NOLINTNEXTLINE(bugprone-branch-clone) - } else if (ext == "m" && !cm::contains(enabled_langs, "OBJC")) { + } else if (ext == "m"_s && !cm::contains(enabled_langs, "OBJC")) { sourcecode += ".c.objc"; - } else if (ext == "swift") { + } else if (ext == "swift"_s) { sourcecode += ".swift"; - } else if (ext == "plist") { + } else if (ext == "plist"_s) { sourcecode += ".text.plist"; - } else if (ext == "h") { + } else if (ext == "h"_s) { sourcecode += ".c.h"; - } else if (ext == "hxx" || ext == "hpp" || ext == "txx" || ext == "pch" || - ext == "hh" || ext == "inl") { + } else if (ext == "hxx"_s || ext == "hpp"_s || ext == "txx"_s || + ext == "pch"_s || ext == "hh"_s || ext == "inl"_s) { sourcecode += ".cpp.h"; - } else if (ext == "png" || ext == "gif" || ext == "jpg") { + } else if (ext == "png"_s || ext == "gif"_s || ext == "jpg"_s) { keepLastKnownFileType = true; sourcecode = "image"; - } else if (ext == "txt") { + } else if (ext == "txt"_s) { sourcecode += ".text"; - } else if (lang == "CXX") { + } else if (lang == "CXX"_s) { sourcecode += ".cpp.cpp"; - } else if (lang == "C") { + } else if (lang == "C"_s) { sourcecode += ".c.c"; - } else if (lang == "OBJCXX") { + } else if (lang == "OBJCXX"_s) { sourcecode += ".cpp.objcpp"; - } else if (lang == "OBJC") { + } else if (lang == "OBJC"_s) { sourcecode += ".c.objc"; - } else if (lang == "Fortran") { + } else if (lang == "Fortran"_s) { sourcecode += ".fortran.f90"; - } else if (lang == "ASM") { + } else if (lang == "ASM"_s) { sourcecode += ".asm"; - } else if (ext == "metal") { + } else if (ext == "metal"_s) { sourcecode += ".metal"; - } else if (ext == "mig") { + } else if (ext == "mig"_s) { sourcecode += ".mig"; - } else if (ext == "tbd") { + } else if (ext == "tbd"_s) { sourcecode += ".text-based-dylib-definition"; - } else if (ext == "a") { + } else if (ext == "a"_s) { keepLastKnownFileType = true; sourcecode = "archive.ar"; - } else if (ext == "dylib") { + } else if (ext == "dylib"_s) { keepLastKnownFileType = true; sourcecode = "compiled.mach-o.dylib"; - } else if (ext == "framework") { + } else if (ext == "framework"_s) { keepLastKnownFileType = true; sourcecode = "wrapper.framework"; - } else if (ext == "xcassets") { + } else if (ext == "xcassets"_s) { keepLastKnownFileType = true; sourcecode = "folder.assetcatalog"; - } else if (ext == "xcconfig") { + } else if (ext == "xcconfig"_s) { keepLastKnownFileType = true; sourcecode = "text.xcconfig"; } @@ -1298,8 +1298,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReference( bool cmGlobalXCodeGenerator::SpecialTargetEmitted(std::string const& tname) { - if (tname == "ALL_BUILD" || tname == "install" || tname == "package" || - tname == "RUN_TESTS" || tname == CMAKE_CHECK_BUILD_SYSTEM_TARGET) { + if (tname == "ALL_BUILD"_s || tname == "install"_s || tname == "package"_s || + tname == "RUN_TESTS"_s || tname == CMAKE_CHECK_BUILD_SYSTEM_TARGET) { if (this->TargetDoneSet.find(tname) != this->TargetDoneSet.end()) { return true; } @@ -1333,10 +1333,10 @@ struct cmCompareTargets { std::string const& a = l->GetTarget()->GetName(); std::string const& b = r->GetTarget()->GetName(); - if (a == "ALL_BUILD") { + if (a == "ALL_BUILD"_s) { return true; } - if (b == "ALL_BUILD") { + if (b == "ALL_BUILD"_s) { return false; } return a < b; @@ -1444,7 +1444,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( cmGeneratorTarget::SourceFileFlags tsFlags = gtgt->GetTargetSourceFileFlags(sourceFile); - if (filetype && filetype->GetString() == "compiled.mach-o.objfile") { + if (filetype && filetype->GetString() == "compiled.mach-o.objfile"_s) { if (sourceFile->GetObjectLibrary().empty()) { externalObjFiles.push_back(xsf); } @@ -1553,7 +1553,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( if (gtgt->IsFrameworkOnApple()) { // dstPath in frameworks is relative to Versions/ ostr << keySources.first; - } else if (keySources.first != "MacOS") { + } else if (keySources.first != "MacOS"_s) { if (gtgt->Target->GetMakefile()->PlatformIsAppleEmbedded()) { ostr << keySources.first; } else { @@ -2855,7 +2855,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, gflag = this->ExtractFlag("-g", flags); // put back gdwarf-2 if used since there is no way // to represent it in the gui, but we still want debug yes - if (gflag == "-gdwarf-2") { + if (gflag == "-gdwarf-2"_s) { flags += " "; flags += gflag; } @@ -2874,13 +2874,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, cflags[language] += gflags[language]; } debugStr = "NO"; - } else if (last_gflag && (last_gflag->empty() || *last_gflag == "-g0")) { + } else if (last_gflag && (last_gflag->empty() || *last_gflag == "-g0"_s)) { debugStr = "NO"; } // extract C++ stdlib for (auto const& language : languages) { - if (language != "CXX" && language != "OBJCXX") { + if (language != "CXX"_s && language != "OBJCXX"_s) { continue; } std::string& flags = cflags[language]; @@ -2889,7 +2889,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, this->ExtractFlagRegex("(^| )(-stdlib=[^ ]+)( |$)", 2, flags); if (stdlib.size() > 8) { const auto cxxLibrary = stdlib.substr(8); - if (language == "CXX" || + if (language == "CXX"_s || !buildSettings->GetAttribute("CLANG_CXX_LIBRARY")) { buildSettings->AddAttribute("CLANG_CXX_LIBRARY", this->CreateString(cxxLibrary)); @@ -2910,20 +2910,20 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, for (auto const& language : languages) { std::string flags = cmStrCat(cflags[language], " ", defFlags); - if (language == "CXX" || language == "OBJCXX") { - if (language == "CXX" || + if (language == "CXX"_s || language == "OBJCXX"_s) { + if (language == "CXX"_s || !buildSettings->GetAttribute("OTHER_CPLUSPLUSFLAGS")) { buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS", this->CreateString(flags)); } - } else if (language == "Fortran") { + } else if (language == "Fortran"_s) { buildSettings->AddAttribute("IFORT_OTHER_FLAGS", this->CreateString(flags)); - } else if (language == "C" || language == "OBJC") { - if (language == "C" || !buildSettings->GetAttribute("OTHER_CFLAGS")) { + } else if (language == "C"_s || language == "OBJC"_s) { + if (language == "C"_s || !buildSettings->GetAttribute("OTHER_CFLAGS")) { buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags)); } - } else if (language == "Swift") { + } else if (language == "Swift"_s) { buildSettings->AddAttribute("OTHER_SWIFT_FLAGS", this->CreateString(flags)); } @@ -3575,12 +3575,12 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) cmValue prop = target->GetTarget()->GetProperty("XCODE_LINK_BUILD_PHASE_MODE"); if (prop) { - if (*prop == "BUILT_ONLY") { + if (*prop == "BUILT_ONLY"_s) { useLinkPhase = true; - } else if (*prop == "KNOWN_LOCATION") { + } else if (*prop == "KNOWN_LOCATION"_s) { useLinkPhase = true; forceLinkPhase = true; - } else if (*prop != "NONE") { + } else if (*prop != "NONE"_s) { cmSystemTools::Error( cmStrCat("Invalid value for XCODE_LINK_BUILD_PHASE_MODE: ", *prop)); return; @@ -3870,7 +3870,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) std::string linkDirs; for (auto const& libDir : cli->GetDirectories()) { - if (!libDir.empty() && libDir != "/usr/lib") { + if (!libDir.empty() && libDir != "/usr/lib"_s) { cmPolicies::PolicyStatus cmp0142 = target->GetTarget()->GetPolicyStatusCMP0142(); if (cmp0142 == cmPolicies::OLD || cmp0142 == cmPolicies::WARN) { diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 73f0992..ddd9669 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -4,6 +4,8 @@ #include +#include + #include const char* cmXCodeObject::PBXTypeNames[] = { @@ -91,13 +93,13 @@ void cmXCodeObject::Print(std::ostream& out) out << this->Id; this->PrintComment(out); out << " = {"; - if (separator == "\n") { + if (separator == "\n"_s) { out << separator; } cmXCodeObject::Indent(3 * indentFactor, out); out << "isa = " << PBXTypeNames[this->IsA] << ";" << separator; for (const auto& keyVal : this->ObjectAttributes) { - if (keyVal.first == "isa") { + if (keyVal.first == "isa"_s) { continue; } @@ -142,7 +144,7 @@ void cmXCodeObject::PrintAttribute(std::ostream& out, int level, case ATTRIBUTE_GROUP: { out << name << " = {"; - if (separator == "\n") { + if (separator == "\n"_s) { out << separator; } for (const auto& keyVal : object->ObjectAttributes) { @@ -156,7 +158,7 @@ void cmXCodeObject::PrintAttribute(std::ostream& out, int level, case OBJECT_REF: { cmXCodeObject::PrintString(out, name); out << " = " << object->Object->Id; - if (object->Object->HasComment() && name != "remoteGlobalIDString") { + if (object->Object->HasComment() && name != "remoteGlobalIDString"_s) { object->Object->PrintComment(out); } out << ";" << separator; diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index 0019278..80327e4 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -7,6 +7,7 @@ #include #include +#include #include "cmsys/String.h" @@ -157,7 +158,7 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout, cmValue launchMode = this->Target->GetTarget()->GetProperty("XCODE_SCHEME_LAUNCH_MODE"); std::string value = "0"; // == 'AUTO' - if (launchMode && *launchMode == "WAIT") { + if (launchMode && *launchMode == "WAIT"_s) { value = "1"; } xout.Attribute("launchStyle", value); diff --git a/Source/cmXcFramework.cxx b/Source/cmXcFramework.cxx index c91e7f2..a45bf2b 100644 --- a/Source/cmXcFramework.cxx +++ b/Source/cmXcFramework.cxx @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -44,23 +45,23 @@ bool PlistSupportedPlatformHelper( return false; } - if (value->asString() == "macos") { + if (value->asString() == "macos"_s) { platform = cmXcFrameworkPlistSupportedPlatform::macOS; return true; } - if (value->asString() == "ios") { + if (value->asString() == "ios"_s) { platform = cmXcFrameworkPlistSupportedPlatform::iOS; return true; } - if (value->asString() == "tvos") { + if (value->asString() == "tvos"_s) { platform = cmXcFrameworkPlistSupportedPlatform::tvOS; return true; } - if (value->asString() == "watchos") { + if (value->asString() == "watchos"_s) { platform = cmXcFrameworkPlistSupportedPlatform::watchOS; return true; } - if (value->asString() == "xros") { + if (value->asString() == "xros"_s) { platform = cmXcFrameworkPlistSupportedPlatform::visionOS; return true; } @@ -113,8 +114,8 @@ cm::optional cmParseXcFrameworkPlist( cmStrCat("Invalid xcframework .plist file:\n ", plistPath), bt); return cm::nullopt; } - if (metadata.CFBundlePackageType != "XFWK" || - metadata.XCFrameworkFormatVersion != "1.0") { + if (metadata.CFBundlePackageType != "XFWK"_s || + metadata.XCFrameworkFormatVersion != "1.0"_s) { mf.GetCMakeInstance()->IssueMessage( MessageType::FATAL_ERROR, cmStrCat("Expected:\n ", plistPath, -- cgit v0.12 From 09b7ac7f6781fcf665cadf08a19a274bfc8c3521 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 27 Jul 2023 09:10:04 -0400 Subject: strings: use single characters where possible --- Source/CPack/cmCPackDragNDropGenerator.cxx | 24 ++++---- Source/CPack/cmCPackPKGGenerator.cxx | 2 +- Source/CPack/cmCPackProductBuildGenerator.cxx | 10 ++-- Source/cmGlobalXCodeGenerator.cxx | 82 +++++++++++++-------------- 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index c7b8bfe..b4cada3 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -140,9 +140,9 @@ int cmCPackDragNDropGenerator::InitializeInternal() } for (auto const& language : languages) { std::string license = - cmStrCat(slaDirectory, "/", language, ".license.txt"); + cmStrCat(slaDirectory, '/', language, ".license.txt"); std::string license_rtf = - cmStrCat(slaDirectory, "/", language, ".license.rtf"); + cmStrCat(slaDirectory, '/', language, ".license.rtf"); if (!singleLicense) { if (!cmSystemTools::FileExists(license) && !cmSystemTools::FileExists(license_rtf)) { @@ -153,7 +153,7 @@ int cmCPackDragNDropGenerator::InitializeInternal() return 0; } } - std::string menu = cmStrCat(slaDirectory, "/", language, ".menu.txt"); + std::string menu = cmStrCat(slaDirectory, '/', language, ".menu.txt"); if (!cmSystemTools::FileExists(menu)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing menu file " << language << ".menu.txt" @@ -197,7 +197,7 @@ int cmCPackDragNDropGenerator::PackageFiles() // loop to create dmg files packageFileNames.clear(); for (auto const& package_file : package_files) { - std::string full_package_name = cmStrCat(toplevel, "/"); + std::string full_package_name = cmStrCat(toplevel, '/'); if (package_file == "ALL_IN_ONE"_s) { full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME"); } else { @@ -429,7 +429,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, cpack_dmg_filesystem, "\"" " -format ", - temp_image_format, " \"", temp_image, "\""); + temp_image_format, " \"", temp_image, '"'); if (!this->RunCommand(temp_image_command, &create_error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -448,7 +448,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, auto attach_command = cmStrCat(this->GetOption("CPACK_COMMAND_HDIUTIL"), " attach" " \"", - temp_image, "\""); + temp_image, '"'); std::string attach_output; if (!this->RunCommand(attach_command, &attach_output)) { @@ -480,7 +480,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, auto setfile_command = cmStrCat(this->GetOption("CPACK_COMMAND_SETFILE"), " -a C" " \"", - temp_mount, "\""); + temp_mount, '"'); if (!this->RunCommand(setfile_command, &error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -500,7 +500,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, cpack_dmg_ds_store_setup_script, "\"" " \"", - temp_mount_name, "\""); + temp_mount_name, '"'); std::string error; if (!this->RunCommand(setup_script_command, &error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -538,7 +538,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, " -imagekey" " zlib-level=9" " -o \"", - output_file, "\""); + output_file, '"'); std::string convert_error; @@ -687,7 +687,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, "\"" " FIXME_WHY_IS_THIS_ARGUMENT_NEEDED" " \"", - output_file, "\""); + output_file, '"'); std::string embed_error; if (!this->RunCommand(embed_sla_command, &embed_error)) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -824,7 +824,7 @@ bool cmCPackDragNDropGenerator::WriteLicense(RezDoc& rez, size_t licenseNumber, actual_license = licenseFile; } else { std::string license_wo_ext = - cmStrCat(slaDirectory, "/", licenseLanguage, ".license"); + cmStrCat(slaDirectory, '/', licenseLanguage, ".license"); if (cmSystemTools::FileExists(cmStrCat(license_wo_ext, ".txt"))) { actual_license = cmStrCat(license_wo_ext, ".txt"); } else { @@ -852,7 +852,7 @@ bool cmCPackDragNDropGenerator::WriteLicense(RezDoc& rez, size_t licenseNumber, } else { std::vector lines; std::string actual_menu = - cmStrCat(slaDirectory, "/", licenseLanguage, ".menu.txt"); + cmStrCat(slaDirectory, '/', licenseLanguage, ".menu.txt"); if (!this->ReadFile(actual_menu, lines, error)) { return false; } diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index 13135f5..4d60c6c 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -41,7 +41,7 @@ std::string cmCPackPKGGenerator::GetPackageName( std::string packagesDir = cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), ".dummy"); return cmStrCat( - cmSystemTools::GetFilenameWithoutLastExtension(packagesDir), "-", + cmSystemTools::GetFilenameWithoutLastExtension(packagesDir), '-', component.Name, ".pkg"); } diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index fd3c659..ae3c50e 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -119,7 +119,7 @@ int cmCPackProductBuildGenerator::PackageFiles() << (keychainPath.empty() ? std::string{} : cmStrCat(" --keychain \"", keychainPath, '"')) - << " \"" << packageFileNames[0] << "\""; + << " \"" << packageFileNames[0] << '"'; // Run ProductBuild return RunProductBuild(pkgCmd.str()); @@ -193,7 +193,7 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( std::string resDir = packageFileDir; if (component) { - resDir += "/"; + resDir += '/'; resDir += component->Name; } std::string scriptDir = cmStrCat(resDir, "/scripts"); @@ -258,7 +258,7 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( << (keychainPath.empty() ? std::string{} : cmStrCat(" --keychain \"", keychainPath, "\"")) - << " \"" << packageFile << "\""; + << " \"" << packageFile << '"'; if (component && !component->Plist.empty()) { pkgCmd << " --component-plist \"" << component->Plist << "\""; @@ -271,10 +271,10 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( cmValue cmCPackProductBuildGenerator::GetComponentScript( const char* script, const char* component_name) { - std::string scriptname = cmStrCat("CPACK_", script, "_"); + std::string scriptname = cmStrCat("CPACK_", script, '_'); if (component_name) { scriptname += cmSystemTools::UpperCase(component_name); - scriptname += "_"; + scriptname += '_'; } scriptname += "SCRIPT"; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 3b19808..5297749 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -451,7 +451,7 @@ bool cmGlobalXCodeGenerator::Open(const std::string& bindir, bool ret = false; #ifdef HAVE_APPLICATION_SERVICES - std::string url = cmStrCat(bindir, "/", projectName, ".xcodeproj"); + std::string url = cmStrCat(bindir, '/', projectName, ".xcodeproj"); if (dryRun) { return cmSystemTools::FileExists(url, false); @@ -732,7 +732,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( makefileStream << "TARGETS += $(subst $(space),$(spaceplus),$(wildcard " << this->ConvertToRelativeForMake(lfile) << "))\n"; } - makefileStream << "\n"; + makefileStream << '\n'; std::string checkCache = cmStrCat(root->GetBinaryDirectory(), "/CMakeFiles/cmake.check_cache"); @@ -755,11 +755,11 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( makefileStream << this->ConvertToRelativeForMake(checkCache) << ": $(TARGETS)\n"; makefileStream - << "\t" << this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand()) + << '\t' << this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand()) << " -S" << this->ConvertToRelativeForMake(root->GetSourceDirectory()) << " -B" << this->ConvertToRelativeForMake(root->GetBinaryDirectory()) << (cm->GetIgnoreWarningAsError() ? " --compile-no-warning-as-error" : "") - << "\n"; + << '\n'; } static bool objectIdLessThan(const std::unique_ptr& l, @@ -854,7 +854,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateFlatClone(cmXCodeObject* orig) static std::string GetGroupMapKeyFromPath(cmGeneratorTarget* target, const std::string& fullpath) { - return cmStrCat(target->GetName(), "-", fullpath); + return cmStrCat(target->GetName(), '-', fullpath); } cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeBuildFileFromPath( @@ -918,7 +918,7 @@ public: "Xcode does not support per-config per-source " << property << ":\n" " " << expression << "\n" "specified for source:\n" - " " << this->SourceFile->ResolveFullPath() << "\n"; + " " << this->SourceFile->ResolveFullPath() << '\n'; /* clang-format on */ this->LocalGenerator->IssueMessage(MessageType::FATAL_ERROR, e.str()); } @@ -1693,7 +1693,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt) gtgt->GetName(), "-CMakeForceLinker.", cmSystemTools::LowerCase(llang)); { cmGeneratedFileStream fout(fname); - fout << "\n"; + fout << '\n'; } if (cmSourceFile* sf = mf->GetOrCreateSource(fname)) { sf->SetProperty("LANGUAGE", llang); @@ -1906,7 +1906,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateRunScriptBuildPhase( auto depfilesDirectory = cmStrCat( gt->GetLocalGenerator()->GetCurrentBinaryDirectory(), "/CMakeFiles/d/"); - auto depfilesPrefix = cmStrCat(depfilesDirectory, buildPhase->GetId(), "."); + auto depfilesPrefix = cmStrCat(depfilesDirectory, buildPhase->GetId(), '.'); std::string shellScript = "set -e\n"; for (std::string const& configName : this->CurrentConfigurationTypes) { @@ -2076,7 +2076,7 @@ std::string cmGlobalXCodeGenerator::ConstructScript( } wd = lg->ConvertToOutputFormat(wd, cmOutputConverter::SHELL); ReplaceScriptVars(wd); - script = cmStrCat(script, " cd ", wd, "\n"); + script = cmStrCat(script, " cd ", wd, '\n'); for (unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) { std::string cmd = ccg.GetCommand(c); if (cmd.empty()) { @@ -2262,7 +2262,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( return cmStrCat( depfilesDirectory, this->GetObjectId(cmXCodeObject::PBXShellScriptBuildPhase, file), - ".", config, ".d"); + '.', config, ".d"); }); auto depfile = ccg.GetInternalDepfile(); @@ -2286,7 +2286,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( } if (ccg.GetNumberOfCommands() > 0) { - makefileStream << "\n"; + makefileStream << '\n'; const std::vector& outputs = ccg.GetOutputs(); if (!outputs.empty()) { // There is at least one output, start the rule for it @@ -2303,14 +2303,14 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( for (auto const& dep : realDepends) { makefileStream << "\\\n" << this->ConvertToRelativeForMake(dep); } - makefileStream << "\n"; + makefileStream << '\n'; if (cm::optional comment = ccg.GetComment()) { std::string echo_cmd = cmStrCat("echo ", (this->CurrentLocalGenerator->EscapeForShell( *comment, ccg.GetCC().GetEscapeAllowMakeVars()))); - makefileStream << "\t" << echo_cmd << "\n"; + makefileStream << '\t' << echo_cmd << '\n'; } // Add each command line to the set of commands. @@ -2328,7 +2328,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( } cmd += cmd2; ccg.AppendArguments(c, cmd); - makefileStream << "\t" << cmd << "\n"; + makefileStream << '\t' << cmd << '\n'; } // Symbolic inputs are not expected to exist, so add dummy rules. @@ -2472,7 +2472,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::set defines(targetSwiftDefines.begin(), targetSwiftDefines.end()); this->CurrentLocalGenerator->JoinDefines(defines, defineString, "Swift"); - cflags["Swift"] += cmStrCat(" ", defineString); + cflags["Swift"] += cmStrCat(' ', defineString); } else { BuildObjectListOrString swiftDefs(this, true); this->AppendDefines(swiftDefs, targetSwiftDefines); @@ -2559,9 +2559,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::string realName = components.base; std::string soName = components.base; if (version && soversion) { - realName += "."; + realName += '.'; realName += *version; - soName += "."; + soName += '.'; soName += *soversion; } @@ -2646,7 +2646,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::string createFlags = this->LookupFlags( "CMAKE_SHARED_MODULE_CREATE_", llang, "_FLAGS", "-bundle"); if (!createFlags.empty()) { - extraLinkOptions += " "; + extraLinkOptions += ' '; extraLinkOptions += createFlags; } cmValue ext = gtgt->GetProperty("BUNDLE_EXTENSION"); @@ -2672,7 +2672,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::string createFlags = this->LookupFlags("CMAKE_", llang, "_LINK_FLAGS", ""); if (!createFlags.empty()) { - extraLinkOptions += " "; + extraLinkOptions += ' '; extraLinkOptions += createFlags; } } @@ -2702,7 +2702,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::string createFlags = this->LookupFlags( "CMAKE_SHARED_LIBRARY_CREATE_", llang, "_FLAGS", "-dynamiclib"); if (!createFlags.empty()) { - extraLinkOptions += " "; + extraLinkOptions += ' '; extraLinkOptions += createFlags; } } @@ -2722,7 +2722,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::string createFlags = this->LookupFlags("CMAKE_", llang, "_LINK_FLAGS", ""); if (!createFlags.empty()) { - extraLinkOptions += " "; + extraLinkOptions += ' '; extraLinkOptions += createFlags; } @@ -2831,7 +2831,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, includes, gtgt, language, configName); if (!includeFlags.empty()) { - cflags[language] += cmStrCat(" ", includeFlags); + cflags[language] += cmStrCat(' ', includeFlags); } } } @@ -2856,7 +2856,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // put back gdwarf-2 if used since there is no way // to represent it in the gui, but we still want debug yes if (gflag == "-gdwarf-2"_s) { - flags += " "; + flags += ' '; flags += gflag; } if (last_gflag && *last_gflag != gflag) { @@ -2870,7 +2870,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // We can't set the Xcode flag differently depending on the language, // so put them back in this case. for (auto const& language : languages) { - cflags[language] += " "; + cflags[language] += ' '; cflags[language] += gflags[language]; } debugStr = "NO"; @@ -2909,7 +2909,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, this->CreateString("NO")); for (auto const& language : languages) { - std::string flags = cmStrCat(cflags[language], " ", defFlags); + std::string flags = cmStrCat(cflags[language], ' ', defFlags); if (language == "CXX"_s || language == "OBJCXX"_s) { if (language == "CXX"_s || !buildSettings->GetAttribute("OTHER_CPLUSPLUSFLAGS")) { @@ -2962,7 +2962,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // Convert to a path for the native build tool. cmSystemTools::ConvertToUnixSlashes(install_name_dir); install_name += install_name_dir; - install_name += "/"; + install_name += '/'; } install_name += gtgt->GetSOName(configName); @@ -2990,7 +2990,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, if (unique_dirs.find(runpath) == unique_dirs.end()) { unique_dirs.insert(runpath); if (!search_paths.empty()) { - search_paths += " "; + search_paths += ' '; } search_paths += this->XCodeEscapePath(runpath); } @@ -3025,7 +3025,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // Xcode always wants at least 1.0.0 or nothing if (!(major == 0 && minor == 0 && patch == 0)) { - v << major << "." << minor << "." << patch; + v << major << '.' << minor << '.' << patch; } buildSettings->AddAttribute("DYLIB_CURRENT_VERSION", this->CreateString(v.str())); @@ -3037,7 +3037,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // Xcode always wants at least 1.0.0 or nothing if (!(major == 0 && minor == 0 && patch == 0)) { - vso << major << "." << minor << "." << patch; + vso << major << '.' << minor << '.' << patch; } buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION", this->CreateString(vso.str())); @@ -3183,7 +3183,7 @@ void cmGlobalXCodeGenerator::CreateGlobalXCConfigSettings( if (!sf) { cmSystemTools::Error( cmStrCat("sources for ALL_BUILD do not contain xcconfig file: '", - xcconfig, "' (configuration: ", configName, ")")); + xcconfig, "' (configuration: ", configName, ')')); return; } @@ -3216,7 +3216,7 @@ void cmGlobalXCodeGenerator::CreateTargetXCConfigSettings( cmSystemTools::Error(cmStrCat("target sources for target ", target->Target->GetName(), " do not contain xcconfig file: '", xcconfig, - "' (configuration: ", configName, ")")); + "' (configuration: ", configName, ')')); return; } @@ -4313,7 +4313,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup( for (std::vector::size_type i = 0; i < tgt_folders.size(); i++) { if (i != 0) { - curr_tgt_folder += "/"; + curr_tgt_folder += '/'; } curr_tgt_folder += tgt_folders[i]; it = this->TargetGroup.find(curr_tgt_folder); @@ -4352,7 +4352,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup( } else { tgroup = i_folder->second; } - curr_folder += "\\"; + curr_folder += '\\'; } return tgroup; } @@ -4741,7 +4741,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile( if (y != target->GetDependTargets().end()) { for (auto const& deptgt : y->second) { makefileStream << this->PostBuildMakeTarget(deptgt, configName) - << ": " << trel << "\n"; + << ": " << trel << '\n'; } } @@ -4750,11 +4750,11 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile( for (auto* objLib : objlibs) { makefileStream << this->PostBuildMakeTarget(objLib->GetName(), configName) - << ": " << trel << "\n"; + << ": " << trel << '\n'; } // Create a rule for this target. - makefileStream << trel << ":"; + makefileStream << trel << ':'; // List dependencies if any exist. auto const x = target->GetDependLibraries().find(configName); @@ -4780,7 +4780,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile( // Write the action to remove the target if it is out of date. makefileStream << "\n" "\t/bin/rm -f " - << this->ConvertToRelativeForMake(tfull) << "\n"; + << this->ConvertToRelativeForMake(tfull) << '\n'; // if building for more than one architecture // then remove those executables as well if (this->Architectures.size() > 1) { @@ -4791,7 +4791,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile( gt->GetFullName(configName)); makefileStream << "\t/bin/rm -f " << this->ConvertToRelativeForMake(universalFile) - << "\n"; + << '\n'; } } makefileStream << "\n\n"; @@ -5097,7 +5097,7 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags, // Separate from previous flags. if (!flags.empty()) { - flags += " "; + flags += ' '; } // Check if the flag needs quoting. @@ -5116,7 +5116,7 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags, if (quoteFlag) { // Open single quote. - flags += "'"; + flags += '\''; } // Flag value with escaped quotes and backslashes. @@ -5132,7 +5132,7 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags, if (quoteFlag) { // Close single quote. - flags += "'"; + flags += '\''; } } -- cgit v0.12