Source: Use cmStrCat in place of string addition

This commit is contained in:
AJIOB
2025-12-09 11:06:59 -05:00
committed by Brad King
parent eb7a8f8e85
commit fe173b68f0
37 changed files with 227 additions and 202 deletions
+16 -15
View File
@@ -663,7 +663,7 @@ bool cmCTest::OpenOutputFile(std::string const& path, std::string const& name,
return false;
}
}
std::string filename = testingDir + "/" + name;
std::string filename = cmStrCat(testingDir, '/', name);
stream.Open(filename);
if (!stream) {
cmCTestLog(this, ERROR_MESSAGE,
@@ -695,8 +695,8 @@ bool cmCTest::AddIfExists(Part part, std::string const& file)
bool cmCTest::CTestFileExists(std::string const& filename)
{
std::string testingDir = this->Impl->BinaryDir + "/Testing/" +
this->Impl->CurrentTag + "/" + filename;
std::string testingDir = cmStrCat(this->Impl->BinaryDir, "/Testing/",
this->Impl->CurrentTag, '/', filename);
return cmSystemTools::FileExists(testingDir);
}
@@ -821,7 +821,7 @@ int cmCTest::ProcessSteps()
unsigned long kk;
for (kk = 0; kk < d.GetNumberOfFiles(); kk++) {
char const* file = d.GetFile(kk);
std::string fullname = notes_dir + "/" + file;
std::string fullname = cmStrCat(notes_dir, '/', file);
if (cmSystemTools::FileExists(fullname, true)) {
if (!this->Impl->NotesFiles.empty()) {
this->Impl->NotesFiles += ";";
@@ -1032,8 +1032,8 @@ void cmCTest::StartXML(cmXMLWriter& xml, cmake* cm, bool append)
std::string buildname =
cmCTest::SafeBuildIdField(this->GetCTestConfiguration("BuildName"));
std::string stamp = cmCTest::SafeBuildIdField(this->Impl->CurrentTag + "-" +
this->GetTestGroupString());
std::string stamp = cmCTest::SafeBuildIdField(
cmStrCat(this->Impl->CurrentTag, '-', this->GetTestGroupString()));
std::string site =
cmCTest::SafeBuildIdField(this->GetCTestConfiguration("Site"));
@@ -1150,8 +1150,9 @@ int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml, cmake* cm,
"<file:///Dart/Source/Server/XSL/Build.xsl> \"");
xml.StartElement("Site");
xml.Attribute("BuildName", buildname);
xml.Attribute("BuildStamp",
this->Impl->CurrentTag + "-" + this->GetTestGroupString());
xml.Attribute(
"BuildStamp",
cmStrCat(this->Impl->CurrentTag, '-', this->GetTestGroupString()));
xml.Attribute("Name", this->GetCTestConfiguration("Site"));
xml.Attribute("Generator",
std::string("ctest-") + cmVersion::GetCMakeVersion());
@@ -1175,7 +1176,7 @@ int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml, cmake* cm,
}
ifs.close();
} else {
xml.Content("Problem reading file: " + file + "\n");
xml.Content(cmStrCat("Problem reading file: ", file, '\n'));
cmCTestLog(this, ERROR_MESSAGE,
"Problem reading file: " << file << " while creating notes"
<< std::endl);
@@ -1667,12 +1668,12 @@ bool cmCTest::SetArgsFromPreset(std::string const& presetName,
auto const& start = expandedPreset->Filter->Include->Index->Start;
auto const& end = expandedPreset->Filter->Include->Index->End;
auto const& stride = expandedPreset->Filter->Include->Index->Stride;
std::string indexOptions;
indexOptions += (start ? std::to_string(*start) : "") + ",";
indexOptions += (end ? std::to_string(*end) : "") + ",";
indexOptions += (stride ? std::to_string(*stride) : "") + ",";
indexOptions +=
cmJoin(expandedPreset->Filter->Include->Index->SpecificTests, ",");
std::string indexOptions = cmStrCat(
(start ? std::to_string(*start) : std::string{}), ',',
(end ? std::to_string(*end) : std::string{}), ',',
(stride ? std::to_string(*stride) : std::string{}), ',',
cmJoin(expandedPreset->Filter->Include->Index->SpecificTests,
","));
this->Impl->TestOptions.TestsToRunInformation = indexOptions;
} else {
+2 -1
View File
@@ -292,7 +292,8 @@ bool cmCacheManager::SaveCache(std::string const& path, cmMessenger* messenger)
if (!ce.Initialized) {
/*
// This should be added in, but is not for now.
cmSystemTools::Error("Cache entry \"" + i.first + "\" is uninitialized");
cmSystemTools::Error(cmStrCat("Cache entry \"", i.first, "\" is
uninitialized"));
*/
} else if (t != cmStateEnums::INTERNAL) {
// Format is key:type=value
+3 -3
View File
@@ -275,8 +275,8 @@ std::string cmCommonTargetGenerator::GetManifests(std::string const& config)
manifests.reserve(manifest_srcs.size());
std::string lang = this->GeneratorTarget->GetLinkerLanguage(config);
std::string manifestFlag =
this->Makefile->GetDefinition("CMAKE_" + lang + "_LINKER_MANIFEST_FLAG");
std::string manifestFlag = this->Makefile->GetDefinition(
cmStrCat("CMAKE_", lang, "_LINKER_MANIFEST_FLAG"));
for (cmSourceFile const* manifest_src : manifest_srcs) {
manifests.push_back(manifestFlag +
this->LocalCommonGenerator->ConvertToOutputFormat(
@@ -425,7 +425,7 @@ std::string cmCommonTargetGenerator::GenerateCodeCheckRules(
if (cmNonempty(tidy)) {
code_check += " --tidy=";
cmValue const p = this->Makefile->GetDefinition(
"CMAKE_" + lang + "_CLANG_TIDY_DRIVER_MODE");
cmStrCat("CMAKE_", lang, "_CLANG_TIDY_DRIVER_MODE"));
std::string driverMode;
if (cmNonempty(p)) {
driverMode = *p;
+5 -5
View File
@@ -127,7 +127,7 @@ std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
ret.reserve(values.size());
int i = 0;
for (std::string const& value : values) {
ret.emplace_back("[" + std::to_string(i++) + "]", value);
ret.emplace_back(cmStrCat('[', i++, ']'), value);
}
return ret;
});
@@ -151,7 +151,7 @@ std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
ret.reserve(values.size());
int i = 0;
for (std::string const& value : values) {
ret.emplace_back("[" + std::to_string(i++) + "]", value);
ret.emplace_back(cmStrCat('[', i++, ']'), value);
}
return ret;
});
@@ -176,7 +176,7 @@ std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
ret.reserve(list.size());
int i = 0;
for (auto const& item : list) {
ret.emplace_back("[" + std::to_string(i++) + "]", item.Value);
ret.emplace_back(cmStrCat('[', i++, ']'), item.Value);
}
return ret;
@@ -426,8 +426,8 @@ std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::Create(
for (auto const& key : keys) {
auto entry = std::make_shared<cmDebuggerVariables>(
variablesManager,
key + ":" +
cmState::CacheEntryTypeToString(state->GetCacheEntryType(key)),
cmStrCat(key, ':',
cmState::CacheEntryTypeToString(state->GetCacheEntryType(key))),
supportsVariableType, [=]() {
std::vector<cmDebuggerVariableEntry> ret;
auto properties = state->GetCacheEntryPropertyList(key);
+5 -3
View File
@@ -8,6 +8,8 @@
#include <stdexcept>
#include <utility>
#include "cmStringAlgorithms.h"
namespace cmDebugger {
#ifdef _WIN32
@@ -131,8 +133,8 @@ std::string cmDebuggerPipeConnection_WIN32::GetErrorMessage(DWORD errorCode)
FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&message, 0, nullptr);
std::string errorMessage = "Internal Error with " + this->PipeName + ": " +
std::string(message, size);
std::string errorMessage = cmStrCat("Internal Error with ", this->PipeName,
": ", std::string(message, size));
LocalFree(message);
return errorMessage;
}
@@ -238,7 +240,7 @@ std::string cmDebuggerPipeClient_WIN32::GetErrorMessage(DWORD errorCode)
nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&message, 0, nullptr);
std::string errorMessage =
this->PipeName + ": " + std::string(message, size);
cmStrCat(this->PipeName, ": ", std::string(message, size));
LocalFree(message);
return errorMessage;
}
+2 -1
View File
@@ -160,7 +160,8 @@ bool cmDependsC::WriteDependencies(std::set<std::string> const& sources,
// regex.
if (fullName.empty() &&
this->IncludeRegexComplain.find(current.FileName)) {
cmSystemTools::Error("Cannot find file \"" + current.FileName + "\".");
cmSystemTools::Error(
cmStrCat("Cannot find file \"", current.FileName, "\"."));
return false;
}
+1 -1
View File
@@ -479,7 +479,7 @@ bool cmDocumentation::PrintHelpOneManual(std::ostream& os)
std::string mname = this->CurrentArgument;
std::string::size_type mlen = mname.length();
if (mlen > 3 && mname[mlen - 3] == '(' && mname[mlen - 1] == ')') {
mname = mname.substr(0, mlen - 3) + "." + mname[mlen - 2];
mname = cmStrCat(mname.substr(0, mlen - 3), '.', mname[mlen - 2]);
}
if (this->PrintFiles(os, cmStrCat("manual/", mname)) ||
this->PrintFiles(os, cmStrCat("manual/", mname, ".[0-9]"))) {
+8 -7
View File
@@ -79,7 +79,8 @@ static bool HandleTargetsMode(std::vector<std::string> const& args,
Arguments arguments = parser.Parse(args, &unknownArgs);
if (!unknownArgs.empty()) {
status.SetError("Unknown argument: \"" + unknownArgs.front() + "\".");
status.SetError(
cmStrCat("Unknown argument: \"", unknownArgs.front(), "\"."));
return false;
}
@@ -117,7 +118,7 @@ static bool HandleTargetsMode(std::vector<std::string> const& args,
} else {
// Interpret relative paths with respect to the current build dir.
std::string const& dir = mf.GetCurrentBinaryDirectory();
fname = dir + "/" + fname;
fname = cmStrCat(dir, '/', fname);
}
std::vector<cmExportBuildFileGenerator::TargetExport> targets;
@@ -304,7 +305,7 @@ static bool HandleExportMode(std::vector<std::string> const& args,
} else {
// Interpret relative paths with respect to the current build dir.
std::string const& dir = mf.GetCurrentBinaryDirectory();
fname = dir + "/" + fname;
fname = cmStrCat(dir, '/', fname);
}
if (gg->GetExportedTargetsFile(fname)) {
@@ -414,8 +415,8 @@ static bool HandleSetupMode(std::vector<std::string> const& args,
cmMakeRange(packageDependencyArgs).advance(1), &unknownArgs);
if (!unknownArgs.empty()) {
status.SetError("PACKAGE_DEPENDENCY given unknown argument: \"" +
unknownArgs.front() + "\".");
status.SetError(cmStrCat("PACKAGE_DEPENDENCY given unknown argument: \"",
unknownArgs.front(), "\"."));
return false;
}
auto& packageDependency =
@@ -457,8 +458,8 @@ static bool HandleSetupMode(std::vector<std::string> const& args,
targetParser.Parse(cmMakeRange(targetArgs).advance(1), &unknownArgs);
if (!unknownArgs.empty()) {
status.SetError("TARGET given unknown argument: \"" +
unknownArgs.front() + "\".");
status.SetError(cmStrCat("TARGET given unknown argument: \"",
unknownArgs.front(), "\"."));
return false;
}
exportSet.SetXcFrameworkLocation(targetArgs.front(),
+17 -17
View File
@@ -157,11 +157,11 @@ void cmExportInstallCMakeConfigGenerator::GenerateImportPrefix(
} else {
// Add code to compute the installation prefix relative to the
// import file location.
std::string absDest = installPrefix + "/" + expDest;
std::string absDestS = absDest + "/";
std::string absDest = cmStrCat(installPrefix, '/', expDest);
std::string absDestS = absDest + '/';
os << "# Compute the installation prefix relative to this file.\n"
<< "get_filename_component(_IMPORT_PREFIX"
<< " \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n";
"get_filename_component(_IMPORT_PREFIX"
" \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n";
if (cmHasLiteralPrefix(absDestS, "/lib/") ||
cmHasLiteralPrefix(absDestS, "/lib64/") ||
cmHasLiteralPrefix(absDestS, "/libx32/") ||
@@ -189,9 +189,9 @@ void cmExportInstallCMakeConfigGenerator::GenerateImportPrefix(
dest = cmSystemTools::GetFilenamePath(dest);
}
os << "if(_IMPORT_PREFIX STREQUAL \"/\")\n"
<< " set(_IMPORT_PREFIX \"\")\n"
<< "endif()\n"
<< "\n";
" set(_IMPORT_PREFIX \"\")\n"
"endif()\n"
"\n";
}
}
@@ -200,8 +200,8 @@ void cmExportInstallCMakeConfigGenerator::CleanupTemporaryVariables(
{
/* clang-format off */
os << "# Cleanup temporary variables.\n"
<< "set(_IMPORT_PREFIX)\n"
<< "\n";
"set(_IMPORT_PREFIX)\n"
"\n";
/* clang-format on */
}
@@ -210,14 +210,14 @@ void cmExportInstallCMakeConfigGenerator::LoadConfigFiles(std::ostream& os)
// Now load per-configuration properties for them.
/* clang-format off */
os << "# Load information for each installed configuration.\n"
<< "file(GLOB _cmake_config_files \"${CMAKE_CURRENT_LIST_DIR}/"
<< this->GetConfigImportFileGlob() << "\")\n"
<< "foreach(_cmake_config_file IN LISTS _cmake_config_files)\n"
<< " include(\"${_cmake_config_file}\")\n"
<< "endforeach()\n"
<< "unset(_cmake_config_file)\n"
<< "unset(_cmake_config_files)\n"
<< "\n";
"file(GLOB _cmake_config_files \"${CMAKE_CURRENT_LIST_DIR}/"
<< this->GetConfigImportFileGlob() << "\")\n"
"foreach(_cmake_config_file IN LISTS _cmake_config_files)\n"
" include(\"${_cmake_config_file}\")\n"
"endforeach()\n"
"unset(_cmake_config_file)\n"
"unset(_cmake_config_files)\n"
"\n";
/* clang-format on */
}
+4 -3
View File
@@ -52,12 +52,13 @@ int cmExprParserHelper::ParseString(char const* str, int verb)
this->InputBuffer, "\": ", fail.what(), '.');
this->SetError(std::move(e));
} catch (std::out_of_range const&) {
std::string e = "cannot evaluate the expression: \"" + this->InputBuffer +
"\": a numeric value is out of range.";
std::string e =
cmStrCat("cannot evaluate the expression: \"", this->InputBuffer,
"\": a numeric value is out of range.");
this->SetError(std::move(e));
} catch (...) {
std::string e =
"cannot parse the expression: \"" + this->InputBuffer + "\".";
cmStrCat("cannot parse the expression: \"", this->InputBuffer, "\".");
this->SetError(std::move(e));
}
cmExpr_yylex_destroy(yyscanner);
+5 -4
View File
@@ -154,9 +154,10 @@ void Tree::BuildVirtualFolder(cmXMLWriter& xml) const
void Tree::BuildVirtualFolderImpl(std::string& virtualFolders,
std::string const& prefix) const
{
virtualFolders += "CMake Files\\" + prefix + this->path + "\\;";
virtualFolders += cmStrCat("CMake Files\\", prefix, this->path, "\\;");
for (Tree const& folder : this->folders) {
folder.BuildVirtualFolderImpl(virtualFolders, prefix + this->path + "\\");
folder.BuildVirtualFolderImpl(virtualFolders,
cmStrCat(prefix, this->path, '\\'));
}
}
@@ -452,7 +453,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
}
// Add CMakeLists.txt
tree.BuildUnit(xml, mf->GetHomeDirectory() + "/");
tree.BuildUnit(xml, mf->GetHomeDirectory() + '/');
xml.EndElement(); // Project
xml.EndElement(); // CodeBlocks_project_file
@@ -474,7 +475,7 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
fout << "# This is a dummy file for the OBJECT library "
<< target->GetName()
<< " for the CMake CodeBlocks project generator.\n"
<< "# Don't edit, this file will be overwritten.\n";
"# Don't edit, this file will be overwritten.\n";
/* clang-format on */
}
return filename;
+3 -4
View File
@@ -185,9 +185,8 @@ void cmExtraCodeLiteGenerator::CreateProjectFile(
{
std::string const& outputDir = lgs[0]->GetCurrentBinaryDirectory();
std::string projectName = lgs[0]->GetProjectName();
std::string filename = outputDir + "/";
std::string filename = cmStrCat(outputDir, '/', projectName, ".project");
filename += projectName + ".project";
this->CreateNewProjectFile(lgs, filename);
}
@@ -661,8 +660,8 @@ std::string cmExtraCodeLiteGenerator::GetCleanCommand(
std::string cmExtraCodeLiteGenerator::GetRebuildCommand(
cmMakefile const* mf, std::string const& targetName) const
{
return this->GetCleanCommand(mf, targetName) + " && " +
this->GetBuildCommand(mf, targetName);
return cmStrCat(this->GetCleanCommand(mf, targetName), " && ",
this->GetBuildCommand(mf, targetName));
}
std::string cmExtraCodeLiteGenerator::GetSingleFileBuildCommand(
+3 -1
View File
@@ -10,6 +10,8 @@
#include <sstream>
#include <utility>
#include <cmext/string_view>
#include "cmsys/RegularExpression.hxx"
#include "cmGeneratedFileStream.h"
@@ -1077,7 +1079,7 @@ std::string cmExtraEclipseCDT4Generator::GetPathBasename(
std::string cmExtraEclipseCDT4Generator::GenerateProjectName(
std::string const& name, std::string const& type, std::string const& path)
{
return name + (type.empty() ? "" : "-") + type + "@" + path;
return cmStrCat(name, (type.empty() ? ""_s : "-"_s), type, '@', path);
}
// Helper functions
+1 -1
View File
@@ -209,7 +209,7 @@ void cmExtraKateGenerator::AppendTarget(
<< make << " -C \\\"" << (this->UseNinja ? homeOutputDir : path)
<< "\\\" "
<< ((this->UseNinja && configs.size() > 1)
? std::string(" -f build-") + conf + ".ninja"
? cmStrCat(" -f build-", conf, ".ninja")
: std::string())
<< makeArgs << " " << target << "\"}\n";
+3 -2
View File
@@ -87,7 +87,7 @@ void cmExtraSublimeTextGenerator::CreateProjectFile(
std::string projectName = lgs[0]->GetProjectName();
std::string const filename =
outputDir + "/" + projectName + ".sublime-project";
cmStrCat(outputDir, '/', projectName, ".sublime-project");
this->CreateNewProjectFile(lgs, filename);
}
@@ -456,7 +456,8 @@ bool cmExtraSublimeTextGenerator::Open(std::string const& bindir,
return false;
}
std::string filename = bindir + "/" + projectName + ".sublime-project";
std::string filename =
cmStrCat(bindir, '/', projectName, ".sublime-project");
if (dryRun) {
return cmSystemTools::FileExists(filename, true);
}
+28 -27
View File
@@ -91,8 +91,8 @@ cmFastbuildNormalTargetGenerator::cmFastbuildNormalTargetGenerator(
"\"" FASTBUILD_DOLLAR_TAG "TargetOutputImplib" FASTBUILD_DOLLAR_TAG "\"");
for (auto const& lang : Languages) {
TargetIncludesByLanguage[lang] = this->GetIncludes(lang, Config);
LogMessage("targetIncludes for lang " + lang + " = " +
TargetIncludesByLanguage[lang]);
LogMessage(cmStrCat("targetIncludes for lang ", lang, " = ",
TargetIncludesByLanguage[lang]));
for (auto const& arch : this->GetArches()) {
auto& flags = CompileFlagsByLangAndArch[std::make_pair(lang, arch)];
@@ -1765,7 +1765,8 @@ void cmFastbuildNormalTargetGenerator::AppendTargetDep(
// Tested in "RunCMake.Framework - ImportedFrameworkConsumption".
std::string const decorated =
item.GetFormattedItem(item.Value.Value).Value;
LogMessage("Adding framework dep <" + decorated + "> to command line");
LogMessage(
cmStrCat("Adding framework dep <", decorated, "> to command line"));
linkerNode.LinkerOptions += (" " + decorated);
return;
}
@@ -1802,8 +1803,9 @@ void cmFastbuildNormalTargetGenerator::AppendTargetDep(
// It moves the dep outside of FASTBuild control, so the binary won't
// be re-built if the shared lib has changed.
// Tested in "BuildDepends" test.
LogMessage("LINK_DEPENDS_NO_SHARED is set on the target, adding dep" +
item.Value.Value + " as is");
LogMessage(
cmStrCat("LINK_DEPENDS_NO_SHARED is set on the target, adding dep",
item.Value.Value, " as is"));
linkerNode.LinkerOptions +=
(" " + cmGlobalFastbuildGenerator::QuoteIfHasSpaces(item.Value.Value));
return;
@@ -1838,7 +1840,7 @@ void cmFastbuildNormalTargetGenerator::AppendTargetDep(
// inject any properties in between). Tested in
// "RunCMake.target_link_libraries-LINK_LIBRARY" test.
if (isFeature) {
LogMessage("AppendTargetDep: " + dep + " as prebuild");
LogMessage(cmStrCat("AppendTargetDep: ", dep, " as prebuild"));
linkerNode.PreBuildDependencies.emplace(dep);
return;
}
@@ -1879,7 +1881,7 @@ void cmFastbuildNormalTargetGenerator::AppendPrebuildDeps(
linkerNode.PreBuildDependencies.insert(std::move(fastbuildTargetName));
} else {
if (!cmIsNOTFOUND(linkDep)) {
LogMessage("Adding dep " + linkDep + " for sorting");
LogMessage(cmStrCat("Adding dep ", linkDep, " for sorting"));
linkerNode.PreBuildDependencies.insert(linkDep);
}
}
@@ -1927,7 +1929,8 @@ void cmFastbuildNormalTargetGenerator::AppendCommandLineDep(
}
formatted = this->ConvertToFastbuildPath(formatted);
LogMessage("Unknown link dep: " + formatted + ", adding to command line");
LogMessage(
cmStrCat("Unknown link dep: ", formatted, ", adding to command line"));
// Only add real artifacts to .Libraries2, otherwise Fastbuild will always
// consider the target out-of-date (since its input doesn't exist).
@@ -1949,7 +1952,7 @@ void cmFastbuildNormalTargetGenerator::AppendToLibraries2IfApplicable(
// target out-of-date (since it never exists).
if (this->GeneratorTarget->IsApple() &&
cmSystemTools::StringStartsWith(dep, "-framework")) {
LogMessage("Not adding framework: " + dep + " to .Libraries2");
LogMessage(cmStrCat("Not adding framework: ", dep, " to .Libraries2"));
return;
}
@@ -1959,13 +1962,13 @@ void cmFastbuildNormalTargetGenerator::AppendToLibraries2IfApplicable(
if (this->GeneratorTarget->IsApple() && target &&
!target->LinkerNode.empty() &&
target->LinkerNode[0].Type == FastbuildLinkerNode::EXECUTABLE) {
LogMessage("Not adding DLL/Executable(" + linkerNode.Name +
" to .Libraries2");
LogMessage(cmStrCat("Not adding DLL/Executable(", linkerNode.Name,
" to .Libraries2"));
return;
}
// Additing to .Libraries2 for tracking.
LogMessage("Adding " + dep + " .Libraries2");
// Adding to .Libraries2 for tracking.
LogMessage(cmStrCat("Adding ", dep, " .Libraries2"));
linkerNode.Libraries2.emplace_back(std::move(dep));
}
@@ -1989,8 +1992,8 @@ void cmFastbuildNormalTargetGenerator::AppendLINK_DEPENDS(
void cmFastbuildNormalTargetGenerator::AppendLinkDep(
FastbuildLinkerNode& linkerNode, std::string dep) const
{
LogMessage("AppendLinkDep: " + dep +
" to .LibrarianAdditionalInputs/.Libraries");
LogMessage(cmStrCat("AppendLinkDep: ", dep,
" to .LibrarianAdditionalInputs/.Libraries"));
linkerNode.LibrarianAdditionalInputs.emplace_back(std::move(dep));
}
@@ -2073,8 +2076,8 @@ void cmFastbuildNormalTargetGenerator::AppendLinkDeps(
linkerNode.LibrarianAdditionalInputs.emplace_back(std::move(dep));
}
} else if (linkerNode.Type == FastbuildLinkerNode::STATIC_LIBRARY) {
LogMessage("Skipping linking to STATIC_LIBRARY (" + linkerNode.Name +
")");
LogMessage(cmStrCat("Skipping linking to STATIC_LIBRARY (",
linkerNode.Name, ')'));
continue;
}
// We're linked to exact target.
@@ -2120,8 +2123,8 @@ void cmFastbuildNormalTargetGenerator::AddLipoCommand(FastbuildTarget& target)
for (auto const& ArchSpecificTarget : target.LinkerNode) {
exec.ExecInput.emplace_back(ArchSpecificTarget.LinkerOutput);
}
exec.ExecArguments +=
"-create -output " + target.RealOutput + " " + cmJoin(exec.ExecInput, " ");
exec.ExecArguments += cmStrCat("-create -output ", target.RealOutput, " ",
cmJoin(exec.ExecInput, " "));
target.PostBuildExecNodes.Alias.PreBuildDependencies.emplace(
exec.ExecOutput);
target.PostBuildExecNodes.Nodes.emplace_back(std::move(exec));
@@ -2211,9 +2214,7 @@ void cmFastbuildNormalTargetGenerator::GenerateLink(
std::string outpath = GeneratorTarget->GetDirectory(Config);
this->OSXBundleGenerator->CreateAppBundle(targetNames.Output, outpath,
Config);
targetOutputReal = outpath;
targetOutputReal += "/";
targetOutputReal += outputReal;
targetOutputReal = cmStrCat(outpath, '/', outputReal);
targetOutputReal = this->ConvertToFastbuildPath(targetOutputReal);
} else if (GeneratorTarget->IsFrameworkOnApple()) {
// Create the library framework.
@@ -2305,17 +2306,17 @@ cmFastbuildNormalTargetGenerator::GetSymlinkExecs() const
if (from.empty() || to.empty() || from == to) {
return;
}
LogMessage("Symlinking " + from + " -> " + to);
LogMessage(cmStrCat("Symlinking ", from, " -> ", to));
FastbuildExecNode postBuildExecNode;
postBuildExecNode.Name = "cmake_symlink_" + to;
postBuildExecNode.ExecOutput =
cmJoin({ GeneratorTarget->GetDirectory(Config), to }, "/");
postBuildExecNode.ExecExecutable = cmSystemTools::GetCMakeCommand();
postBuildExecNode.ExecArguments =
"-E cmake_symlink_executable " +
cmGlobalFastbuildGenerator::QuoteIfHasSpaces(from) + " " +
postBuildExecNode.ExecArguments = cmStrCat(
"-E cmake_symlink_executable ",
cmGlobalFastbuildGenerator::QuoteIfHasSpaces(from), ' ',
cmGlobalFastbuildGenerator::QuoteIfHasSpaces(
this->ConvertToFastbuildPath(postBuildExecNode.ExecOutput));
this->ConvertToFastbuildPath(postBuildExecNode.ExecOutput)));
res.emplace_back(std::move(postBuildExecNode));
};
generateSymlinkCommand(targetNames.Real, targetNames.Output);
+19 -17
View File
@@ -306,8 +306,8 @@ void cmFastbuildTargetGenerator::AddOutput(cmCustomCommandGenerator const& ccg,
exec.ExecOutput = this->ConvertToFastbuildPath(dummyOutput);
for (auto const& output : exec.OutputsAlias.PreBuildDependencies) {
OutputsToReplace[output.Name] = exec.ExecOutput;
LogMessage("Adding replace from " + output.Name + " to " +
exec.ExecOutput);
LogMessage(cmStrCat("Adding replace from ", output.Name, " to ",
exec.ExecOutput));
}
};
@@ -372,15 +372,16 @@ void cmFastbuildTargetGenerator::GetDepends(
auto const targetInfo = this->LocalGenerator->GetSourcesWithOutput(dep);
if (targetInfo.Target) {
LogMessage("dep: " + dep + ", target: " + targetInfo.Target->GetName());
LogMessage(
cmStrCat("dep: ", dep, ", target: ", targetInfo.Target->GetName()));
auto const& target = targetInfo.Target;
auto const processCCs = [this, &currentCCName, &targetDep,
dep](std::vector<cmCustomCommand> const& ccs,
FastbuildBuildStep step) {
for (auto const& cc : ccs) {
for (auto const& output : cc.GetOutputs()) {
LogMessage("dep: " + dep + ", post output: " +
this->ConvertToFastbuildPath(output));
LogMessage(cmStrCat("dep: ", dep, ", post output: ",
this->ConvertToFastbuildPath(output)));
if (this->ConvertToFastbuildPath(output) == dep) {
auto ccName = this->GetCustomCommandTargetName(cc, step);
if (ccName != currentCCName) {
@@ -390,8 +391,8 @@ void cmFastbuildTargetGenerator::GetDepends(
}
}
for (auto const& byproduct : cc.GetByproducts()) {
LogMessage("dep: " + dep + ", post byproduct: " +
this->ConvertToFastbuildPath(byproduct));
LogMessage(cmStrCat("dep: ", dep, ", post byproduct: ",
this->ConvertToFastbuildPath(byproduct)));
if (this->ConvertToFastbuildPath(byproduct) == dep) {
auto ccName = this->GetCustomCommandTargetName(cc, step);
if (ccName != currentCCName) {
@@ -409,8 +410,8 @@ void cmFastbuildTargetGenerator::GetDepends(
continue;
}
if (!targetInfo.Source) {
LogMessage("dep: " + dep + ", no source, byproduct: " +
std::to_string(targetInfo.SourceIsByproduct));
LogMessage(cmStrCat("dep: ", dep, ", no source, byproduct: ",
targetInfo.SourceIsByproduct));
// Tested in "OutDir" test.
if (!cmSystemTools::FileIsFullPath(orig)) {
targetDep.emplace(std::move(orig));
@@ -418,7 +419,7 @@ void cmFastbuildTargetGenerator::GetDepends(
continue;
}
if (!targetInfo.Source->GetCustomCommand()) {
LogMessage("dep: " + dep + ", no GetCustomCommand");
LogMessage(cmStrCat("dep: ", dep, ", no GetCustomCommand"));
continue;
}
if (targetInfo.Source && targetInfo.Source->GetCustomCommand()) {
@@ -491,7 +492,7 @@ FastbuildExecNode cmFastbuildTargetGenerator::GetAppleTextStubCommand() const
return res;
}
res.Name = "create_" + names.ImportOutput + "_text_stub";
res.Name = cmStrCat("create_", names.ImportOutput, "_text_stub");
res.ExecExecutable = std::move(executable);
res.ExecArguments = std::move(args);
res.ExecWorkingDir = this->LocalCommonGenerator->GetCurrentBinaryDirectory();
@@ -510,7 +511,7 @@ FastbuildExecNode cmFastbuildTargetGenerator::GetDepsCheckExec(
exec.ExecOutput = depender.ExecOutput + ".deps-checker";
exec.ExecExecutable = cmSystemTools::GetCMakeCommand();
exec.ExecArguments += "-E cmake_fastbuild_check_depends ";
exec.ExecArguments += depender.ExecOutput + " ";
exec.ExecArguments += depender.ExecOutput + ' ';
char const* sep = "";
for (auto const& dep : depender.OutputsAlias.PreBuildDependencies) {
exec.ExecArguments += sep;
@@ -593,7 +594,7 @@ FastbuildExecNodes cmFastbuildTargetGenerator::GenerateCommands(
FastbuildExecNode execNode;
execNode.Name = execName;
// Add depncencies to "ExecInput" so that FASTBuild will re-run the Exec
// Add dependencies to "ExecInput" so that FASTBuild will re-run the Exec
// when needed, but also add to "PreBuildDependencies" for correct sorting.
// Tested in "ObjectLibrary / complexOneConfig" tests.
GetDepends(ccg, execName, execNode.ExecInput,
@@ -652,7 +653,7 @@ FastbuildExecNodes cmFastbuildTargetGenerator::GenerateCommands(
}
}
for (auto const& out : execNode.OutputsAlias.PreBuildDependencies) {
LogMessage("Adding replace from " + out.Name + " to " + execName);
LogMessage(cmStrCat("Adding replace from ", out.Name, " to ", execName));
OutputToExecName[out.Name] = execName;
}
execs.Nodes.emplace_back(std::move(execNode));
@@ -661,7 +662,8 @@ FastbuildExecNodes cmFastbuildTargetGenerator::GenerateCommands(
for (auto& inputFile : exec.ExecInput) {
auto const iter = OutputsToReplace.find(inputFile);
if (iter != OutputsToReplace.end()) {
LogMessage("Replacing input: " + inputFile + " with " + iter->second);
LogMessage(
cmStrCat("Replacing input: ", inputFile, " with ", iter->second));
inputFile = iter->second;
}
auto const depIter = std::find_if(
@@ -670,8 +672,8 @@ FastbuildExecNodes cmFastbuildTargetGenerator::GenerateCommands(
return !OutputToExecName[dep.Name].empty();
});
if (depIter != exec.PreBuildDependencies.end()) {
LogMessage("Replacing dep " + depIter->Name + " with " +
OutputToExecName[depIter->Name]);
LogMessage(cmStrCat("Replacing dep ", depIter->Name, " with ",
OutputToExecName[depIter->Name]));
exec.PreBuildDependencies.emplace(OutputToExecName[depIter->Name]);
exec.PreBuildDependencies.erase(depIter);
}
+2 -1
View File
@@ -16,6 +16,7 @@
#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmTarget.h"
#include "cmTargetDepend.h"
@@ -75,7 +76,7 @@ void cmFastbuildUtilityTargetGenerator::Generate()
}
}
if (this->GetGlobalGenerator()->IsExcluded(this->GetGeneratorTarget())) {
LogMessage("Excluding " + targetName + " from ALL");
LogMessage(cmStrCat("Excluding ", targetName, " from ALL"));
fastbuildTarget.ExcludeFromAll = true;
}
auto preBuild = GenerateCommands(FastbuildBuildStep::PRE_BUILD);
+4 -3
View File
@@ -391,7 +391,7 @@ bool cmFileAPI::ReadQuery(std::string const& query,
void cmFileAPI::ReadClient(std::string const& client)
{
// Load queries for the client.
std::string clientDir = this->APIv1 + "/query/" + client;
std::string clientDir = cmStrCat(this->APIv1, "/query/", client);
std::vector<std::string> queries = this->LoadDir(clientDir);
// Read the queries and save for later.
@@ -409,7 +409,8 @@ void cmFileAPI::ReadClient(std::string const& client)
void cmFileAPI::ReadClientQuery(std::string const& client, ClientQueryJson& q)
{
// Read the query.json file.
std::string queryFile = this->APIv1 + "/query/" + client + "/query.json";
std::string queryFile =
cmStrCat(this->APIv1, "/query/", client, "/query.json");
Json::Value query;
if (!this->ReadJsonFile(queryFile, query, q.Error)) {
return;
@@ -640,7 +641,7 @@ cmFileAPI::ClientRequest cmFileAPI::BuildClientRequest(
} else if (kindName == this->ObjectKindName(ObjectKind::InternalTest)) {
r.Kind = ObjectKind::InternalTest;
} else {
r.Error = "unknown request kind '" + kindName + "'";
r.Error = cmStrCat("unknown request kind '", kindName, '\'');
return r;
}
+2 -2
View File
@@ -97,8 +97,8 @@ bool handleQueryCommand(std::vector<std::string> const& args,
return true;
}
if (!unparsedArguments.empty()) {
status.SetError("QUERY given unknown argument \"" +
unparsedArguments.front() + "\".");
status.SetError(cmStrCat("QUERY given unknown argument \"",
unparsedArguments.front(), "\"."));
return false;
}
+15 -13
View File
@@ -93,8 +93,8 @@ bool HandleWriteImpl(std::vector<std::string> const& args, bool append,
i++;
if (!status.GetMakefile().CanIWriteThisFile(fileName)) {
std::string e =
"attempted to write a file: " + fileName + " into a source directory.";
std::string e = cmStrCat("attempted to write a file: ", fileName,
" into a source directory.");
status.SetError(e);
cmSystemTools::SetFatalErrorOccurred();
return false;
@@ -770,13 +770,13 @@ bool HandleGlobImpl(std::vector<std::string> const& args, bool recurse,
if (globMessage.type == cmsys::Glob::cyclicRecursion) {
status.GetMakefile().IssueMessage(
MessageType::AUTHOR_WARNING,
"Cyclic recursion detected while globbing for '" + *i + "':\n" +
globMessage.content);
cmStrCat("Cyclic recursion detected while globbing for '", *i,
"':\n", globMessage.content));
} else if (globMessage.type == cmsys::Glob::error) {
status.GetMakefile().IssueMessage(
MessageType::FATAL_ERROR,
"Error has occurred while globbing for '" + *i + "' - " +
globMessage.content);
cmStrCat("Error has occurred while globbing for '", *i, "' - ",
globMessage.content));
shouldExit = true;
} else if (cm->GetDebugOutput() || cm->GetTrace()) {
status.GetMakefile().IssueMessage(
@@ -929,8 +929,8 @@ bool HandleTouchImpl(std::vector<std::string> const& args, bool create,
cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', arg);
}
if (!status.GetMakefile().CanIWriteThisFile(tfile)) {
std::string e =
"attempted to touch a file: " + tfile + " in a source directory.";
std::string e = cmStrCat("attempted to touch a file: ", tfile,
" in a source directory.");
status.SetError(e);
cmSystemTools::SetFatalErrorOccurred();
return false;
@@ -3106,8 +3106,9 @@ bool HandleTimestampCommand(std::vector<std::string> const& args,
if (args[argsIndex] == "UTC") {
utcFlag = true;
} else {
std::string e = " TIMESTAMP sub-command does not recognize option " +
args[argsIndex] + ".";
std::string e =
cmStrCat(" TIMESTAMP sub-command does not recognize option ",
args[argsIndex], '.');
status.SetError(e);
return false;
}
@@ -3227,7 +3228,8 @@ bool HandleCreateLinkCommand(std::vector<std::string> const& args,
if (!arguments.Symbolic &&
(!cmSystemTools::PathExists(fileName) ||
(cmp0205 != cmPolicies::NEW && !cmSystemTools::FileExists(fileName)))) {
result = "Cannot hard link \'" + fileName + "\' as it does not exist.";
result =
cmStrCat("Cannot hard link \'", fileName, "\' as it does not exist.");
if (!arguments.Result.empty()) {
status.GetMakefile().AddDefinition(arguments.Result, result);
return true;
@@ -3469,7 +3471,7 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
deps.push_back(firstPath);
if (!parsedArgs.RPathPrefix.empty()) {
status.GetMakefile().AddDefinition(
parsedArgs.RPathPrefix + "_" + firstPath,
cmStrCat(parsedArgs.RPathPrefix, '_', firstPath),
cmList::to_string(archive.GetRPaths().at(firstPath)));
}
} else if (!parsedArgs.ConflictingDependenciesPrefix.empty()) {
@@ -3477,7 +3479,7 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
std::vector<std::string> paths;
paths.insert(paths.begin(), val.second.begin(), val.second.end());
std::string varName =
parsedArgs.ConflictingDependenciesPrefix + "_" + val.first;
cmStrCat(parsedArgs.ConflictingDependenciesPrefix, '_', val.first);
std::string pathsStr = cmList::to_string(paths);
status.GetMakefile().AddDefinition(varName, pathsStr);
} else {
+1 -1
View File
@@ -455,7 +455,7 @@ bool cmFileInstaller::HandleInstallDestination()
}
if (!cmSystemTools::FileIsDirectory(destination)) {
std::string errstring =
"INSTALL destination: " + destination + " is not a directory.";
cmStrCat("INSTALL destination: ", destination, " is not a directory.");
this->Status.SetError(errstring);
return false;
}
+4 -6
View File
@@ -224,13 +224,11 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
this->VariableDocumentation += "the (unknown) library be found";
} else if (this->Names.size() == 1) {
this->VariableDocumentation +=
"the " + this->Names.front() + " library be found";
cmStrCat("the ", this->Names.front(), " library be found");
} else {
this->VariableDocumentation += "one of the ";
this->VariableDocumentation +=
cmJoin(cmMakeRange(this->Names).retreat(1), ", ");
this->VariableDocumentation +=
" or " + this->Names.back() + " libraries be found";
this->VariableDocumentation += cmStrCat(
"one of the ", cmJoin(cmMakeRange(this->Names).retreat(1), ", "),
" or ", this->Names.back(), " libraries be found");
}
}
+1 -1
View File
@@ -86,7 +86,7 @@ std::size_t collectPathsForDebug(std::string& buffer,
return 0;
}
for (auto i = startIndex; i < paths.size(); i++) {
buffer += " " + paths[i].Path + "\n";
buffer += cmStrCat(" ", paths[i].Path, '\n');
}
return paths.size();
}
+2 -2
View File
@@ -338,8 +338,8 @@ std::string cmFindProgramCommand::GetBundleExecutable(
if (CFURLGetFileSystemRepresentation(executableURL, false, buffer,
MAX_OSX_PATH_SIZE)) {
executable = bundlePath + "/Contents/MacOS/" +
std::string(reinterpret_cast<char*>(buffer));
executable = cmStrCat(bundlePath, "/Contents/MacOS/",
reinterpret_cast<char const*>(buffer));
}
// Only release CFURLRef if it's not null
CFRelease(executableURL);
+1 -1
View File
@@ -382,7 +382,7 @@ void cmGeneratorExpression::Split(std::string const& input,
}
}
std::string::size_type const traversed = (c - cStart) + 1;
output.push_back(preGenex + "$<" + input.substr(pos, traversed));
output.push_back(cmStrCat(preGenex, "$<", input.substr(pos, traversed)));
pos += traversed;
lastPos = pos;
}
+21 -21
View File
@@ -2,16 +2,14 @@
file LICENSE.rst or https://cmake.org/licensing for details. */
#include "cmGeneratorExpressionEvaluator.h"
#include <sstream>
#ifndef CMAKE_BOOTSTRAP
# include <cm3p/json/value.h>
#endif
#include "cmGenExContext.h"
#include "cmGenExEvaluation.h"
#include "cmGeneratorExpressionNode.h"
#include "cmLocalGenerator.h"
#include "cmStringAlgorithms.h"
#include "cmake.h"
GeneratorExpressionContent::GeneratorExpressionContent(
@@ -96,8 +94,9 @@ std::string GeneratorExpressionContent::Evaluate(
if (node->NumExpectedParameters() == 1 &&
node->AcceptsArbitraryContentParameter()) {
if (this->ParamChildren.empty()) {
reportError(eval, this->GetOriginalExpression(),
"$<" + identifier + "> expression requires a parameter.");
reportError(
eval, this->GetOriginalExpression(),
cmStrCat("$<", identifier, "> expression requires a parameter."));
}
} else {
std::vector<std::string> parameters;
@@ -166,19 +165,20 @@ std::string GeneratorExpressionContent::EvaluateParameters(
if ((numExpected > cmGeneratorExpressionNode::DynamicParameters &&
static_cast<unsigned int>(numExpected) != parameters.size())) {
if (numExpected == 0) {
reportError(eval, this->GetOriginalExpression(),
"$<" + identifier + "> expression requires no parameters.");
reportError(
eval, this->GetOriginalExpression(),
cmStrCat("$<", identifier, "> expression requires no parameters."));
} else if (numExpected == 1) {
reportError(eval, this->GetOriginalExpression(),
"$<" + identifier +
"> expression requires "
"exactly one parameter.");
cmStrCat("$<", identifier,
"> expression requires "
"exactly one parameter."));
} else {
std::ostringstream e;
e << "$<" + identifier + "> expression requires " << numExpected
<< " comma separated parameters, but got " << parameters.size()
<< " instead.";
reportError(eval, this->GetOriginalExpression(), e.str());
std::string e =
cmStrCat("$<", identifier, "> expression requires ", numExpected,
" comma separated parameters, but got ", parameters.size(),
" instead.");
reportError(eval, this->GetOriginalExpression(), e);
}
return std::string();
}
@@ -186,18 +186,18 @@ std::string GeneratorExpressionContent::EvaluateParameters(
if (numExpected == cmGeneratorExpressionNode::OneOrMoreParameters &&
parameters.empty()) {
reportError(eval, this->GetOriginalExpression(),
"$<" + identifier +
"> expression requires at least one parameter.");
cmStrCat("$<", identifier,
"> expression requires at least one parameter."));
} else if (numExpected == cmGeneratorExpressionNode::TwoOrMoreParameters &&
parameters.size() < 2) {
reportError(eval, this->GetOriginalExpression(),
"$<" + identifier +
"> expression requires at least two parameters.");
cmStrCat("$<", identifier,
"> expression requires at least two parameters."));
} else if (numExpected == cmGeneratorExpressionNode::OneOrZeroParameters &&
parameters.size() > 1) {
reportError(eval, this->GetOriginalExpression(),
"$<" + identifier +
"> expression requires one or zero parameters.");
cmStrCat("$<", identifier,
"> expression requires one or zero parameters."));
}
return std::string();
}
+12 -10
View File
@@ -581,7 +581,7 @@ protected:
{
if (eval->HeadTarget) {
cmGeneratorExpressionDAGChecker dagChecker{
eval->HeadTarget, genexOperator + ":" + expression,
eval->HeadTarget, cmStrCat(genexOperator, ':', expression),
content, dagCheckerParent,
eval->Context, eval->Backtrace,
};
@@ -2646,7 +2646,7 @@ struct CompilerFrontendVariantNode : public cmGeneratorExpressionNode
{
std::string const& compilerFrontendVariant =
eval->Context.LG->GetMakefile()->GetSafeDefinition(
"CMAKE_" + lang + "_COMPILER_FRONTEND_VARIANT");
cmStrCat("CMAKE_", lang, "_COMPILER_FRONTEND_VARIANT"));
if (parameters.empty()) {
return compilerFrontendVariant;
}
@@ -4177,7 +4177,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
std::vector<std::string> const& langAvailable =
availableFeatures[lit.first];
cmValue standardDefault = eval->Context.LG->GetMakefile()->GetDefinition(
"CMAKE_" + lit.first + "_STANDARD_DEFAULT");
cmStrCat("CMAKE_", lit.first, "_STANDARD_DEFAULT"));
for (std::string const& it : lit.second) {
if (!cm::contains(langAvailable, it)) {
return "0";
@@ -4502,7 +4502,8 @@ struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag>
std::string language = target->GetLinkerLanguage(eval->Context.Config);
std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB";
std::string pdbSupportVar =
cmStrCat("CMAKE_", language, "_LINKER_SUPPORTS_PDB");
if (!eval->Context.LG->GetMakefile()->IsOn(pdbSupportVar)) {
::reportError(eval, content->GetOriginalExpression(),
@@ -4764,14 +4765,14 @@ protected:
eval->Context.LG->FindGeneratorTargetToUse(name);
if (!target) {
::reportError(eval, content->GetOriginalExpression(),
"No target \"" + name + "\"");
cmStrCat("No target \"", name, '"'));
return nullptr;
}
if (target->GetType() >= cmStateEnums::OBJECT_LIBRARY &&
target->GetType() != cmStateEnums::UNKNOWN_LIBRARY) {
::reportError(eval, content->GetOriginalExpression(),
"Target \"" + name +
"\" is not an executable or library.");
::reportError(
eval, content->GetOriginalExpression(),
cmStrCat("Target \"", name, "\" is not an executable or library."));
return nullptr;
}
if (dagChecker &&
@@ -5021,7 +5022,8 @@ struct TargetOutputNameArtifactResultGetter<ArtifactPdbTag>
std::string language = target->GetLinkerLanguage(eval->Context.Config);
std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB";
std::string pdbSupportVar =
cmStrCat("CMAKE_", language, "_LINKER_SUPPORTS_PDB");
if (!eval->Context.LG->GetMakefile()->IsOn(pdbSupportVar)) {
::reportError(
@@ -5398,7 +5400,7 @@ static const struct ShellPathNode : public cmGeneratorExpressionNode
for (auto const& in : list_in) {
if (!cmSystemTools::FileIsFullPath(in)) {
reportError(eval, content->GetOriginalExpression(),
"\"" + in + "\" is not an absolute path.");
cmStrCat('"', in, "\" is not an absolute path."));
return std::string();
}
list_out.emplace_back(converter.ConvertDirectorySeparatorsForShell(in));
@@ -169,7 +169,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender,
for (std::string const& p : props) {
std::string pname = cmSystemTools::HelpFileName(p);
std::string pfile = pdir + pname + ".rst";
std::string pfile = cmStrCat(pdir, pname, ".rst");
if (cmSystemTools::FileExists(pfile, true)) {
std::ostringstream e;
e << "Target \"" << dependee->GetName() << "\" has property \"" << p
@@ -55,7 +55,8 @@ std::string AddLangSpecificInterfaceIncludeDirectories(
switch (dagChecker.Check()) {
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
dagChecker.ReportError(
nullptr, "$<TARGET_PROPERTY:" + target->GetName() + ",propertyName");
nullptr,
cmStrCat("$<TARGET_PROPERTY:", target->GetName(), ",propertyName"));
CM_FALLTHROUGH;
case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE:
// No error. We just skip cyclic references.
@@ -195,15 +196,15 @@ void processIncludeDirectories(cmGeneratorTarget const* tgt,
if (uniqueIncludes.insert(entryInclude).second) {
includes.emplace_back(entryInclude, entry.Backtrace);
if (debugIncludes) {
usedIncludes += " * " + entryInclude + "\n";
usedIncludes += cmStrCat(" * ", entryInclude, "\n");
}
}
}
if (!usedIncludes.empty()) {
tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
MessageType::LOG,
std::string("Used includes for target ") + tgt->GetName() + ":\n" +
usedIncludes,
cmStrCat("Used includes for target ", tgt->GetName(), ":\n",
usedIncludes),
entry.Backtrace);
}
}
+2 -2
View File
@@ -227,7 +227,7 @@ bool cmGeneratorTarget::ComputeLinkClosure(std::string const& config,
// Now consider languages that propagate from linked targets.
for (std::string const& lang : languages) {
std::string propagates =
"CMAKE_" + lang + "_LINKER_PREFERENCE_PROPAGATES";
cmStrCat("CMAKE_", lang, "_LINKER_PREFERENCE_PROPAGATES");
if (this->Makefile->IsOn(propagates)) {
tsl.Consider(lang);
}
@@ -823,7 +823,7 @@ std::vector<cmLinkItem> cmGeneratorTarget::ComputeImplicitLanguageTargets(
std::string const& runtimeLibrary =
this->GetRuntimeLinkLibrary(lang, config);
if (cmValue runtimeLinkOptions = this->Makefile->GetDefinition(
"CMAKE_" + lang + "_RUNTIME_LIBRARIES_" + runtimeLibrary)) {
cmStrCat("CMAKE_", lang, "_RUNTIME_LIBRARIES_", runtimeLibrary))) {
cmList libsList{ *runtimeLinkOptions };
result.reserve(libsList.size());
+3 -3
View File
@@ -82,15 +82,15 @@ void processLinkDirectories(cmGeneratorTarget const* tgt,
if (uniqueDirectories.insert(entryDirectory).second) {
directories.emplace_back(entryDirectory, entry.Backtrace);
if (debugDirectories) {
usedDirectories += " * " + entryDirectory + "\n";
usedDirectories += cmStrCat(" * ", entryDirectory, '\n');
}
}
}
if (!usedDirectories.empty()) {
tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
MessageType::LOG,
std::string("Used link directories for target ") + tgt->GetName() +
":\n" + usedDirectories,
cmStrCat("Used link directories for target ", tgt->GetName(), ":\n",
usedDirectories),
entry.Backtrace);
}
}
+2 -2
View File
@@ -522,10 +522,10 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
if (this->IsDeviceLink()) {
// wrap host link options
std::string const wrapper(this->Makefile->GetSafeDefinition(
"CMAKE_" + language + "_DEVICE_COMPILER_WRAPPER_FLAG"));
cmStrCat("CMAKE_", language, "_DEVICE_COMPILER_WRAPPER_FLAG")));
cmList wrapperFlag{ wrapper };
std::string const wrapperSep(this->Makefile->GetSafeDefinition(
"CMAKE_" + language + "_DEVICE_COMPILER_WRAPPER_FLAG_SEP"));
cmStrCat("CMAKE_", language, "_DEVICE_COMPILER_WRAPPER_FLAG_SEP")));
bool concatFlagAndArgs = true;
if (!wrapperFlag.empty() && wrapperFlag.back() == " ") {
concatFlagAndArgs = false;
+8 -5
View File
@@ -36,6 +36,7 @@
#include "cmSourceFileLocation.h"
#include "cmSourceGroup.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmValue.h"
@@ -59,10 +60,12 @@ void AddObjectEntries(cmGeneratorTarget const* headTarget,
std::string uniqueName =
headTarget->GetGlobalGenerator()->IndexGeneratorTargetUniquely(
lib.Target);
std::string genex = "$<TARGET_OBJECTS:" + std::move(uniqueName) + ">";
std::string genex =
cmStrCat("$<TARGET_OBJECTS:", std::move(uniqueName), '>');
cmGeneratorExpression ge(*headTarget->Makefile->GetCMakeInstance(),
lib.Backtrace);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(std::move(genex));
cge->SetEvaluateForBuildsystem(true);
EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace);
@@ -212,15 +215,15 @@ bool processSources(cmGeneratorTarget const* tgt,
if (uniqueSrcs.insert(src).second) {
srcs.emplace_back(src, entry.Backtrace);
if (debugSources) {
usedSources += " * " + src + "\n";
usedSources += cmStrCat(" * ", src, '\n');
}
}
}
if (!usedSources.empty()) {
tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
MessageType::LOG,
std::string("Used sources for target ") + tgt->GetName() + ":\n" +
usedSources,
cmStrCat("Used sources for target ", tgt->GetName(), ":\n",
usedSources),
entry.Backtrace);
}
}
@@ -123,7 +123,7 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty(
switch (dagChecker.Check()) {
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
dagChecker.ReportError(
eval, "$<TARGET_PROPERTY:" + this->GetName() + "," + prop + ">");
eval, cmStrCat("$<TARGET_PROPERTY:", this->GetName(), ',', prop, '>'));
return result;
case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE:
// No error. We just skip cyclic references.
+9 -7
View File
@@ -734,7 +734,8 @@ bool cmake::SetCacheArgs(std::vector<std::string> const& args)
cmSystemTools::Error("No file name specified for -C");
return false;
}
cmSystemTools::Stdout("loading initial cache file " + value + "\n");
cmSystemTools::Stdout(
cmStrCat("loading initial cache file ", value, '\n'));
// Resolve script path specified on command line
// relative to $PWD.
auto path = cmSystemTools::ToNormalizedPathOnDisk(value);
@@ -1986,10 +1987,10 @@ int cmake::AddCMakePaths()
(cmSystemTools::GetCMakeRoot() + "/Modules/CMake.cmake"))) {
// couldn't find modules
cmSystemTools::Error(
"Could not find CMAKE_ROOT !!!\n"
"CMake has most likely not been installed correctly.\n"
"Modules directory not found in\n" +
cmSystemTools::GetCMakeRoot());
cmStrCat("Could not find CMAKE_ROOT !!!\n"
"CMake has most likely not been installed correctly.\n"
"Modules directory not found in\n",
cmSystemTools::GetCMakeRoot()));
return 0;
}
this->AddCacheEntry("CMAKE_ROOT", cmSystemTools::GetCMakeRoot(),
@@ -4028,8 +4029,9 @@ int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets,
// actually starting the build. If not done separately from the build
// itself, there is the risk of building an out-of-date solution file due
// to limitations of the underlying build system.
std::string const stampList = cachePath + "/" + "CMakeFiles/" +
cmGlobalVisualStudio14Generator::GetGenerateStampList();
std::string const stampList =
cmStrCat(cachePath, "/CMakeFiles/",
cmGlobalVisualStudio14Generator::GetGenerateStampList());
// Note that the stampList file only exists for VS generators.
if (cmSystemTools::FileExists(stampList) &&
+6 -4
View File
@@ -265,14 +265,15 @@ int main()
// The object will not actually be written.
cmSystemTools::ReplaceString(clrest, "/fo ", " ");
cmSystemTools::ReplaceString(clrest, "-fo ", " ");
cmSystemTools::ReplaceString(clrest, objfile, "-Fo" + objfile + ".obj");
cmSystemTools::ReplaceString(clrest, objfile,
cmStrCat("-Fo", objfile, ".obj"));
cl = "\"" + cl + "\" /P /DRC_INVOKED /nologo /showIncludes /TC ";
cl = cmStrCat('"', cl, "\" /P /DRC_INVOKED /nologo /showIncludes /TC ");
// call cl in object dir so the .i is generated there
std::string objdir;
{
pos = objfile.rfind("\\");
pos = objfile.rfind('\\');
if (pos != std::string::npos) {
objdir = objfile.substr(0, pos);
}
@@ -282,8 +283,9 @@ int main()
int exit_code =
process(srcfilename, dfile, objfile, prefix, cl + clrest, objdir, true);
if (exit_code != 0)
if (exit_code != 0) {
return exit_code;
}
// compile rc file with rc.exe
std::string rc = cmStrCat('"', binpath, '"');