summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-08-01 13:30:41 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-08-01 13:30:55 (GMT)
commit08c637423c48f588c46d426bdafc1fd7b9e7bb86 (patch)
tree83f1f4ea85fe8edd17496f6afa089e9e1348006a
parentd56b0f9339c841c05fedee9ffb872638429caaa9 (diff)
parent09b7ac7f6781fcf665cadf08a19a274bfc8c3521 (diff)
downloadCMake-08c637423c48f588c46d426bdafc1fd7b9e7bb86.zip
CMake-08c637423c48f588c46d426bdafc1fd7b9e7bb86.tar.gz
CMake-08c637423c48f588c46d426bdafc1fd7b9e7bb86.tar.bz2
Merge topic 'clang-tidy-xcode-generator'
09b7ac7f67 strings: use single characters where possible 6aa9023700 string_view: use string_view literals in comparisons 1b60137b98 strings: combine string literals e1b70d7286 cmCPackDragNDropGenerator: use a string instead of a stream for commands f5d04b5bf0 cmStrCat: use where possible in Apple-specific sources 3af822cd8f cmXCode21Object: simplify streaming expression c4f751604b cmLocalXCodeGenerator: return a default string ce549909fb cmCPackPKGGenerator: remove unnecessary `.c_str()` calls ... Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !8660
-rw-r--r--Source/CPack/cmCPackBundleGenerator.cxx56
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.cxx140
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.h2
-rw-r--r--Source/CPack/cmCPackPKGGenerator.cxx43
-rw-r--r--Source/CPack/cmCPackProductBuildGenerator.cxx62
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx397
-rw-r--r--Source/cmGlobalXCodeGenerator.h2
-rw-r--r--Source/cmLocalXCodeGenerator.cxx2
-rw-r--r--Source/cmXCode21Object.cxx4
-rw-r--r--Source/cmXCodeObject.cxx12
-rw-r--r--Source/cmXCodeObject.h2
-rw-r--r--Source/cmXCodeScheme.cxx7
-rw-r--r--Source/cmXcFramework.cxx15
13 files changed, 393 insertions, 351 deletions
diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx
index 7e6e473..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(
@@ -196,15 +200,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 +216,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 +230,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 768bfbe..b4cada3 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -7,6 +7,9 @@
#include <iomanip>
#include <map>
+#include <cm/string_view>
+#include <cmext/string_view>
+
#include <CoreFoundation/CoreFoundation.h>
#include <cm3p/kwiml/abi.h>
@@ -136,8 +139,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 +153,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,13 +197,13 @@ 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("/");
- if (package_file == "ALL_IN_ONE") {
+ std::string full_package_name = cmStrCat(toplevel, '/');
+ if (package_file == "ALL_IN_ONE"_s) {
full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME");
} 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);
@@ -241,18 +246,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;
}
@@ -410,15 +415,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,
@@ -434,10 +445,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)) {
@@ -466,10 +477,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,
@@ -484,10 +495,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,
@@ -499,10 +512,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,
@@ -517,14 +530,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;
@@ -574,16 +588,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,
@@ -663,13 +679,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,
@@ -709,8 +727,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;
@@ -721,8 +739,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);
}
@@ -806,12 +824,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");
}
}
@@ -834,7 +852,7 @@ bool cmCPackDragNDropGenerator::WriteLicense(RezDoc& rez, size_t licenseNumber,
} else {
std::vector<std::string> 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/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;
diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx
index 76ef091..4d60c6c 100644
--- a/Source/CPack/cmCPackPKGGenerator.cxx
+++ b/Source/CPack/cmCPackPKGGenerator.cxx
@@ -4,6 +4,8 @@
#include <vector>
+#include <cmext/string_view>
+
#include "cmCPackComponentGroup.h"
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
@@ -38,13 +40,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 +161,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 +209,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 +227,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 +251,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,15 +383,14 @@ 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,
- "CPack option: " << cpackVar.c_str()
- << " not specified. It should point to "
- << (!name.empty() ? name : "<empty>")
- << ".rtf, " << name << ".html, or " << name
- << ".txt file" << std::endl);
+ "CPack option: "
+ << cpackVar << " not specified. It should point to "
+ << (!name.empty() ? name : "<empty>") << ".rtf, " << name
+ << ".html, or " << name << ".txt file" << std::endl);
return false;
}
if (!cmSystemTools::FileExists(inFileName)) {
@@ -400,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: "
@@ -414,7 +416,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)")
@@ -454,7 +457,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);
diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx
index 4ad616d..ae3c50e 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 =
@@ -102,15 +102,24 @@ 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 << "\""
- << (identifier.empty() ? "" : " --identifier \"" + identifier + "\"")
- << (identityName.empty() ? "" : " --sign \"" + identityName + "\"")
- << (keychainPath.empty() ? ""
- : " --keychain \"" + keychainPath + "\"")
- << " \"" << packageFileNames[0] << "\"";
+ " --version \""
+ << version << "\""
+ << (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
return RunProductBuild(pkgCmd.str());
@@ -184,10 +193,10 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
std::string resDir = packageFileDir;
if (component) {
- resDir += "/";
+ 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,
@@ -232,15 +241,24 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
keychainPath = p;
}
- pkgCmd << pkgbuild << " --root \"" << packageDir << "\""
- << " --identifier \"" << pkgId << "\""
- << " --scripts \"" << scriptDir << "\""
- << " --version \"" << version << "\""
- << " --install-location \"/\""
- << (identityName.empty() ? "" : " --sign \"" + identityName + "\"")
- << (keychainPath.empty() ? ""
- : " --keychain \"" + keychainPath + "\"")
- << " \"" << packageFile << "\"";
+ pkgCmd << pkgbuild << " --root \"" << packageDir
+ << "\""
+ " --identifier \""
+ << pkgId
+ << "\""
+ " --scripts \""
+ << scriptDir
+ << "\""
+ " --version \""
+ << version
+ << "\""
+ " --install-location \"/\""
+ << (identityName.empty() ? std::string{}
+ : cmStrCat(" --sign \"", identityName, "\""))
+ << (keychainPath.empty()
+ ? std::string{}
+ : cmStrCat(" --keychain \"", keychainPath, "\""))
+ << " \"" << packageFile << '"';
if (component && !component->Plist.empty()) {
pkgCmd << " --component-plist \"" << component->Plist << "\"";
@@ -253,10 +271,10 @@ 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 += "_";
+ scriptname += '_';
}
scriptname += "SCRIPT";
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 247d4fc..5297749 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;
}
}
@@ -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);
@@ -228,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");
}
}
}
@@ -250,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<cmGlobalGenerator>();
}
@@ -390,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) {
@@ -452,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);
@@ -703,7 +702,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
cmLocalGenerator* root, std::vector<cmLocalGenerator*> const& gens)
{
std::vector<std::string> lfiles;
- for (auto gen : gens) {
+ for (auto* gen : gens) {
cm::append(lfiles, gen->GetMakefile()->GetListFiles());
}
@@ -722,29 +721,30 @@ 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 "
<< this->ConvertToRelativeForMake(lfile) << "))\n";
}
- makefileStream << "\n";
+ makefileStream << '\n';
std::string checkCache =
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 "
@@ -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<cmXCodeObject>& l,
@@ -814,7 +814,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(
{
auto obj = cm::make_unique<cmXCode21Object>(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>(
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;
}
@@ -854,10 +854,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(
@@ -921,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());
}
@@ -945,10 +942,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;
@@ -1062,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";
@@ -1098,66 +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";
- } else if (ext == "mm" && !cm::contains(enabled_langs, "OBJCXX")) {
+ // NOLINTNEXTLINE(bugprone-branch-clone)
+ } else if (ext == "mm"_s && !cm::contains(enabled_langs, "OBJCXX")) {
sourcecode += ".cpp.objcpp";
- } else if (ext == "m" && !cm::contains(enabled_langs, "OBJC")) {
+ // NOLINTNEXTLINE(bugprone-branch-clone)
+ } 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";
}
@@ -1179,11 +1178,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
@@ -1278,7 +1277,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");
@@ -1299,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;
}
@@ -1334,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;
@@ -1350,7 +1349,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
this->SetCurrentLocalGenerator(gen);
std::vector<cmGeneratorTarget*> gts =
this->GetLocalGeneratorTargetsInOrder(gen);
- for (auto gtgt : gts) {
+ for (auto* gtgt : gts) {
if (!this->CreateXCodeTarget(gtgt, targets)) {
return false;
}
@@ -1386,8 +1385,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 +1431,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget(
std::vector<cmXCodeObject*> headerFiles;
std::vector<cmXCodeObject*> resourceFiles;
std::vector<cmXCodeObject*> sourceFiles;
- for (auto sourceFile : commonSourceFiles) {
+ for (auto* sourceFile : commonSourceFiles) {
cmXCodeObject* xsf = this->CreateXCodeSourceFile(
this->CurrentLocalGenerator, sourceFile, gtgt);
cmXCodeObject* fr = xsf->GetAttribute("fileRef");
@@ -1445,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);
}
@@ -1535,7 +1534,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget(
using mapOfVectorOfSourceFiles =
std::map<std::string, std::vector<cmSourceFile*>>;
mapOfVectorOfSourceFiles bundleFiles;
- for (auto sourceFile : commonSourceFiles) {
+ for (auto* sourceFile : commonSourceFiles) {
cmGeneratorTarget::SourceFileFlags tsFlags =
gtgt->GetTargetSourceFileFlags(sourceFile);
if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeMacContent) {
@@ -1554,7 +1553,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget(
if (gtgt->IsFrameworkOnApple()) {
// dstPath in frameworks is relative to Versions/<version>
ostr << keySources.first;
- } else if (keySources.first != "MacOS") {
+ } else if (keySources.first != "MacOS"_s) {
if (gtgt->Target->GetMakefile()->PlatformIsAppleEmbedded()) {
ostr << keySources.first;
} else {
@@ -1568,7 +1567,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 +1582,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget(
using mapOfVectorOfSourceFiles =
std::map<std::string, std::vector<cmSourceFile*>>;
mapOfVectorOfSourceFiles bundleFiles;
- for (auto sourceFile : commonSourceFiles) {
+ for (auto* sourceFile : commonSourceFiles) {
cmGeneratorTarget::SourceFileFlags tsFlags =
gtgt->GetTargetSourceFileFlags(sourceFile);
if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeDeepResource) {
@@ -1604,7 +1603,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);
@@ -1680,8 +1679,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
@@ -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);
@@ -1803,7 +1803,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(
// add all the sources
std::vector<cmCustomCommand> 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);
}
}
@@ -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()) {
@@ -2201,10 +2201,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"));
}
@@ -2219,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: ";
@@ -2242,7 +2243,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()];
}
}
@@ -2261,7 +2262,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
return cmStrCat(
depfilesDirectory,
this->GetObjectId(cmXCodeObject::PBXShellScriptBuildPhase, file),
- ".", config, ".d");
+ '.', config, ".d");
});
auto depfile = ccg.GetInternalDepfile();
@@ -2285,7 +2286,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
}
if (ccg.GetNumberOfCommands() > 0) {
- makefileStream << "\n";
+ makefileStream << '\n';
const std::vector<std::string>& outputs = ccg.GetOutputs();
if (!outputs.empty()) {
// There is at least one output, start the rule for it
@@ -2302,14 +2303,14 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
for (auto const& dep : realDepends) {
makefileStream << "\\\n" << this->ConvertToRelativeForMake(dep);
}
- makefileStream << "\n";
+ makefileStream << '\n';
if (cm::optional<std::string> 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.
@@ -2327,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.
@@ -2406,8 +2407,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;
}
@@ -2471,7 +2472,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::set<std::string> 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);
@@ -2558,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;
}
@@ -2645,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");
@@ -2671,7 +2672,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::string createFlags =
this->LookupFlags("CMAKE_", llang, "_LINK_FLAGS", "");
if (!createFlags.empty()) {
- extraLinkOptions += " ";
+ extraLinkOptions += ' ';
extraLinkOptions += createFlags;
}
}
@@ -2701,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;
}
}
@@ -2721,7 +2722,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::string createFlags =
this->LookupFlags("CMAKE_", llang, "_LINK_FLAGS", "");
if (!createFlags.empty()) {
- extraLinkOptions += " ";
+ extraLinkOptions += ' ';
extraLinkOptions += createFlags;
}
@@ -2830,7 +2831,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
includes, gtgt, language, configName);
if (!includeFlags.empty()) {
- cflags[language] += " " + includeFlags;
+ cflags[language] += cmStrCat(' ', includeFlags);
}
}
}
@@ -2854,8 +2855,8 @@ 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") {
- flags += " ";
+ if (gflag == "-gdwarf-2"_s) {
+ flags += ' ';
flags += gflag;
}
if (last_gflag && *last_gflag != gflag) {
@@ -2869,17 +2870,17 @@ 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";
- } 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];
@@ -2888,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));
@@ -2908,21 +2909,21 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
this->CreateString("NO"));
for (auto const& language : languages) {
- std::string flags = cflags[language] + " " + defFlags;
- if (language == "CXX" || language == "OBJCXX") {
- if (language == "CXX" ||
+ std::string flags = cmStrCat(cflags[language], ' ', defFlags);
+ 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));
}
@@ -2961,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);
@@ -2989,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);
}
@@ -3024,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()));
@@ -3036,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()));
@@ -3117,7 +3118,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,11 +3179,11 @@ 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: '",
- xcconfig, "' (configuration: ", configName, ")"));
+ xcconfig, "' (configuration: ", configName, ')'));
return;
}
@@ -3210,12 +3211,12 @@ 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(),
" do not contain xcconfig file: '", xcconfig,
- "' (configuration: ", configName, ")"));
+ "' (configuration: ", configName, ')'));
return;
}
@@ -3458,8 +3459,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) {
@@ -3482,8 +3483,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));
}
}
@@ -3497,7 +3498,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 +3514,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);
@@ -3574,14 +3575,14 @@ 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") {
- cmSystemTools::Error("Invalid value for XCODE_LINK_BUILD_PHASE_MODE: " +
- *prop);
+ } else if (*prop != "NONE"_s) {
+ cmSystemTools::Error(
+ cmStrCat("Invalid value for XCODE_LINK_BUILD_PHASE_MODE: ", *prop));
return;
}
}
@@ -3835,7 +3836,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
BuildObjectListOrString libSearchPaths(this, true);
std::vector<cmSourceFile const*> objs;
gt->GetExternalObjects(objs, configName);
- for (auto sourceFile : objs) {
+ for (auto const* sourceFile : objs) {
if (sourceFile->GetObjectLibrary().empty()) {
continue;
}
@@ -3869,12 +3870,12 @@ 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) {
- libSearchPaths.Add(this->XCodeEscapePath(
- libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"));
+ libSearchPaths.Add(this->XCodeEscapePath(cmStrCat(
+ libDir, "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)")));
}
libSearchPaths.Add(this->XCodeEscapePath(libDir));
}
@@ -4086,16 +4087,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);
@@ -4120,7 +4121,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);
@@ -4129,7 +4131,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
@@ -4171,7 +4173,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 +4184,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 +4192,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 +4202,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",
@@ -4311,7 +4313,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup(
for (std::vector<std::string>::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);
@@ -4350,7 +4352,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup(
} else {
tgroup = i_folder->second;
}
- curr_folder += "\\";
+ curr_folder += '\\';
}
return tgroup;
}
@@ -4594,7 +4596,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 +4622,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) {
@@ -4688,16 +4690,17 @@ 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);
// 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";
@@ -4713,7 +4716,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 ||
@@ -4738,20 +4741,20 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile(
if (y != target->GetDependTargets().end()) {
for (auto const& deptgt : y->second) {
makefileStream << this->PostBuildMakeTarget(deptgt, configName)
- << ": " << trel << "\n";
+ << ": " << trel << '\n';
}
}
std::vector<cmGeneratorTarget*> objlibs;
gt->GetObjectLibrariesCMP0026(objlibs);
- for (auto objLib : objlibs) {
+ 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);
@@ -4763,7 +4766,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),
@@ -4775,9 +4778,9 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile(
}
// Write the action to remove the target if it is out of date.
- makefileStream << "\n";
- makefileStream << "\t/bin/rm -f "
- << this->ConvertToRelativeForMake(tfull) << "\n";
+ makefileStream << "\n"
+ "\t/bin/rm -f "
+ << this->ConvertToRelativeForMake(tfull) << '\n';
// if building for more than one architecture
// then remove those executables as well
if (this->Architectures.size() > 1) {
@@ -4788,7 +4791,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile(
gt->GetFullName(configName));
makefileStream << "\t/bin/rm -f "
<< this->ConvertToRelativeForMake(universalFile)
- << "\n";
+ << '\n';
}
}
makefileStream << "\n\n";
@@ -4797,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";
}
@@ -4816,7 +4819,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) {
@@ -4941,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);
@@ -4954,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
@@ -5094,7 +5097,7 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
// Separate from previous flags.
if (!flags.empty()) {
- flags += " ";
+ flags += ' ';
}
// Check if the flag needs quoting.
@@ -5113,7 +5116,7 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
if (quoteFlag) {
// Open single quote.
- flags += "'";
+ flags += '\'';
}
// Flag value with escaped quotes and backslashes.
@@ -5129,7 +5132,7 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
if (quoteFlag) {
// Close single quote.
- flags += "'";
+ flags += '\'';
}
}
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<cmDepfileFormat> DepfileFormat() const override
+ cm::optional<cmDepfileFormat> DepfileFormat() const override
{
return this->XcodeBuildSystem == BuildSystem::One
? cmDepfileFormat::MakeDepfile
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,
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(
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx
index c817980..ddd9669 100644
--- a/Source/cmXCodeObject.cxx
+++ b/Source/cmXCodeObject.cxx
@@ -4,6 +4,8 @@
#include <ostream>
+#include <cmext/string_view>
+
#include <CoreFoundation/CoreFoundation.h>
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;
@@ -180,7 +182,7 @@ void cmXCodeObject::PrintList(std::vector<cmXCodeObject*> 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..80327e4 100644
--- a/Source/cmXCodeScheme.cxx
+++ b/Source/cmXCodeScheme.cxx
@@ -7,6 +7,7 @@
#include <utility>
#include <cmext/algorithm>
+#include <cmext/string_view>
#include "cmsys/String.h"
@@ -121,7 +122,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");
@@ -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);
@@ -447,7 +448,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();
}
diff --git a/Source/cmXcFramework.cxx b/Source/cmXcFramework.cxx
index 6435ef9..3c447e3 100644
--- a/Source/cmXcFramework.cxx
+++ b/Source/cmXcFramework.cxx
@@ -4,6 +4,7 @@
#include <string>
+#include <cm/string_view>
#include <cmext/string_view>
#include <cm3p/json/value.h>
@@ -43,23 +44,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;
}
@@ -112,8 +113,8 @@ cm::optional<cmXcFrameworkPlist> 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,