|
|
@@ -232,7 +232,7 @@ Arguments cmCoreTryCompile::ParseArgs(
|
|
|
!unparsedArguments.empty()) {
|
|
|
std::string m = "Unknown arguments:";
|
|
|
for (const auto& i : unparsedArguments) {
|
|
|
- m = cmStrCat(m, "\n \"", i, "\"");
|
|
|
+ m = cmStrCat(m, "\n \"", i, '"');
|
|
|
}
|
|
|
this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, m);
|
|
|
}
|
|
|
@@ -346,7 +346,7 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
this->Makefile->IssueMessage(
|
|
|
MessageType::FATAL_ERROR,
|
|
|
cmStrCat("<bindir> is not an absolute path:\n '",
|
|
|
- *arguments.BinaryDirectory, "'"));
|
|
|
+ *arguments.BinaryDirectory, '\''));
|
|
|
return cm::nullopt;
|
|
|
}
|
|
|
this->BinaryDirectory = *arguments.BinaryDirectory;
|
|
|
@@ -378,7 +378,7 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
cmStrCat("Only libraries may be used as try_compile or try_run "
|
|
|
"IMPORTED LINK_LIBRARIES. Got ",
|
|
|
tgt->GetName(), " of type ",
|
|
|
- cmState::GetTargetTypeName(tgt->GetType()), "."));
|
|
|
+ cmState::GetTargetTypeName(tgt->GetType()), '.'));
|
|
|
return cm::nullopt;
|
|
|
}
|
|
|
if (tgt->IsImported()) {
|
|
|
@@ -479,11 +479,11 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
|
|
|
std::map<std::string, std::string> cmakeVariables;
|
|
|
|
|
|
- std::string outFileName = this->BinaryDirectory + "/CMakeLists.txt";
|
|
|
+ std::string outFileName = cmStrCat(this->BinaryDirectory, "/CMakeLists.txt");
|
|
|
// which signature are we using? If we are using var srcfile bindir
|
|
|
if (this->SrcFileSignature) {
|
|
|
// remove any CMakeCache.txt files so we will have a clean test
|
|
|
- std::string ccFile = this->BinaryDirectory + "/CMakeCache.txt";
|
|
|
+ std::string ccFile = cmStrCat(this->BinaryDirectory, "/CMakeCache.txt");
|
|
|
cmSystemTools::RemoveFile(ccFile);
|
|
|
|
|
|
// Choose sources.
|
|
|
@@ -526,12 +526,12 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
|
|
|
if (!cmSystemTools::GetFilenamePath(dst).empty()) {
|
|
|
const auto& msg =
|
|
|
- cmStrCat("SOURCE_FROM_FILE given invalid filename \"", dst, "\"");
|
|
|
+ cmStrCat("SOURCE_FROM_FILE given invalid filename \"", dst, '"');
|
|
|
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, msg);
|
|
|
return cm::nullopt;
|
|
|
}
|
|
|
|
|
|
- auto dstPath = cmStrCat(this->BinaryDirectory, "/", dst);
|
|
|
+ auto dstPath = cmStrCat(this->BinaryDirectory, '/', dst);
|
|
|
auto const result = cmSystemTools::CopyFileAlways(src, dstPath);
|
|
|
if (!result.IsSuccess()) {
|
|
|
const auto& msg = cmStrCat("SOURCE_FROM_FILE failed to copy \"", src,
|
|
|
@@ -555,10 +555,13 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
testLangs.insert(lang);
|
|
|
} else {
|
|
|
std::ostringstream err;
|
|
|
- err << "Unknown extension \"" << ext << "\" for file\n"
|
|
|
- << " " << si << "\n"
|
|
|
- << "try_compile() works only for enabled languages. "
|
|
|
- << "Currently these are:\n ";
|
|
|
+ err << "Unknown extension \"" << ext
|
|
|
+ << "\" for file\n"
|
|
|
+ " "
|
|
|
+ << si
|
|
|
+ << "\n"
|
|
|
+ "try_compile() works only for enabled languages. "
|
|
|
+ "Currently these are:\n ";
|
|
|
std::vector<std::string> langs;
|
|
|
gg->GetEnabledLanguages(langs);
|
|
|
err << cmJoin(langs, " ");
|
|
|
@@ -587,7 +590,7 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
std::ostringstream e;
|
|
|
/* clang-format off */
|
|
|
e << "Failed to open\n"
|
|
|
- << " " << outFileName << "\n"
|
|
|
+ " " << outFileName << "\n"
|
|
|
<< cmSystemTools::GetLastSystemError();
|
|
|
/* clang-format on */
|
|
|
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
|
|
|
@@ -655,9 +658,9 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
|
|
|
std::string projectLangs;
|
|
|
for (std::string const& li : testLangs) {
|
|
|
- projectLangs += " " + li;
|
|
|
+ projectLangs += cmStrCat(' ', li);
|
|
|
std::string rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE";
|
|
|
- std::string rulesOverrideLang = cmStrCat(rulesOverrideBase, "_", li);
|
|
|
+ std::string rulesOverrideLang = cmStrCat(rulesOverrideBase, '_', li);
|
|
|
if (cmValue rulesOverridePath =
|
|
|
this->Makefile->GetDefinition(rulesOverrideLang)) {
|
|
|
fprintf(fout, "set(%s \"%s\")\n", rulesOverrideLang.c_str(),
|
|
|
@@ -690,7 +693,7 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
}
|
|
|
fprintf(fout, "set(CMAKE_VERBOSE_MAKEFILE 1)\n");
|
|
|
for (std::string const& li : testLangs) {
|
|
|
- std::string langFlags = "CMAKE_" + li + "_FLAGS";
|
|
|
+ std::string langFlags = cmStrCat("CMAKE_", li, "_FLAGS");
|
|
|
cmValue flags = this->Makefile->GetDefinition(langFlags);
|
|
|
fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li.c_str(),
|
|
|
cmOutputConverter::EscapeForCMake(*flags).c_str());
|
|
|
@@ -794,10 +797,10 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
}
|
|
|
|
|
|
if (!targets.empty()) {
|
|
|
- std::string fname = "/" + std::string(targetName) + "Targets.cmake";
|
|
|
+ std::string fname = cmStrCat('/', targetName, "Targets.cmake");
|
|
|
cmExportTryCompileFileGenerator tcfg(gg, targets, this->Makefile,
|
|
|
testLangs);
|
|
|
- tcfg.SetExportFile((this->BinaryDirectory + fname).c_str());
|
|
|
+ tcfg.SetExportFile(cmStrCat(this->BinaryDirectory, fname).c_str());
|
|
|
tcfg.SetConfig(tcConfig);
|
|
|
|
|
|
if (!tcfg.GenerateImportFile()) {
|
|
|
@@ -965,7 +968,7 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
if (arguments.LinkLibraries) {
|
|
|
std::string libsToLink = " ";
|
|
|
for (std::string const& i : *arguments.LinkLibraries) {
|
|
|
- libsToLink += "\"" + cmTrimWhitespace(i) + "\" ";
|
|
|
+ libsToLink += cmStrCat('"', cmTrimWhitespace(i), "\" ");
|
|
|
}
|
|
|
fprintf(fout, "target_link_libraries(%s %s)\n", targetName.c_str(),
|
|
|
libsToLink.c_str());
|
|
|
@@ -1064,7 +1067,7 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
if (cmValue tcArchs = this->Makefile->GetDefinition(
|
|
|
kCMAKE_TRY_COMPILE_OSX_ARCHITECTURES)) {
|
|
|
vars.erase(kCMAKE_OSX_ARCHITECTURES);
|
|
|
- std::string flag = "-DCMAKE_OSX_ARCHITECTURES=" + *tcArchs;
|
|
|
+ std::string flag = cmStrCat("-DCMAKE_OSX_ARCHITECTURES=", *tcArchs);
|
|
|
arguments.CMakeFlags.emplace_back(std::move(flag));
|
|
|
cmakeVariables.emplace("CMAKE_OSX_ARCHITECTURES", *tcArchs);
|
|
|
}
|
|
|
@@ -1082,7 +1085,7 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
|
|
|
for (std::string const& var : vars) {
|
|
|
if (cmValue val = this->Makefile->GetDefinition(var)) {
|
|
|
- std::string flag = "-D" + var + "=" + *val;
|
|
|
+ std::string flag = cmStrCat("-D", var, '=', *val);
|
|
|
arguments.CMakeFlags.emplace_back(std::move(flag));
|
|
|
cmakeVariables.emplace(var, *val);
|
|
|
}
|
|
|
@@ -1093,7 +1096,7 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
// Forward the GHS variables to the inner project cache.
|
|
|
for (std::string const& var : ghs_platform_vars) {
|
|
|
if (cmValue val = this->Makefile->GetDefinition(var)) {
|
|
|
- std::string flag = "-D" + var + "=" + "'" + *val + "'";
|
|
|
+ std::string flag = cmStrCat("-D", var, "=\'", *val, '\'');
|
|
|
arguments.CMakeFlags.emplace_back(std::move(flag));
|
|
|
cmakeVariables.emplace(var, *val);
|
|
|
}
|
|
|
@@ -1155,11 +1158,11 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|
|
}
|
|
|
/* clang-format off */
|
|
|
err = cmStrCat(
|
|
|
- "Cannot copy output executable\n",
|
|
|
- " '", this->OutputFile, "'\n",
|
|
|
- "to destination specified by COPY_FILE:\n",
|
|
|
- " '", copyFile, "'\n",
|
|
|
- "because:\n",
|
|
|
+ "Cannot copy output executable\n"
|
|
|
+ " '", this->OutputFile, "'\n"
|
|
|
+ "to destination specified by COPY_FILE:\n"
|
|
|
+ " '", copyFile, "'\n"
|
|
|
+ "because:\n"
|
|
|
" ", err, "\n",
|
|
|
this->FindErrorMessage);
|
|
|
/* clang-format on */
|
|
|
@@ -1204,10 +1207,10 @@ void cmCoreTryCompile::CleanupFiles(std::string const& binDir)
|
|
|
}
|
|
|
|
|
|
if (!IsTemporary(binDir)) {
|
|
|
- cmSystemTools::Error(
|
|
|
+ cmSystemTools::Error(cmStrCat(
|
|
|
"TRY_COMPILE attempt to remove -rf directory that does not contain "
|
|
|
- "CMakeTmp or CMakeScratch: \"" +
|
|
|
- binDir + "\"");
|
|
|
+ "CMakeTmp or CMakeScratch: \"",
|
|
|
+ binDir, '"'));
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -1220,8 +1223,7 @@ void cmCoreTryCompile::CleanupFiles(std::string const& binDir)
|
|
|
// Do not delete NFS temporary files.
|
|
|
!cmHasPrefix(fileName, ".nfs")) {
|
|
|
if (deletedFiles.insert(fileName).second) {
|
|
|
- std::string const fullPath =
|
|
|
- std::string(binDir).append("/").append(fileName);
|
|
|
+ std::string const fullPath = cmStrCat(binDir, '/', fileName);
|
|
|
if (cmSystemTools::FileIsSymlink(fullPath)) {
|
|
|
cmSystemTools::RemoveFile(fullPath);
|
|
|
} else if (cmSystemTools::FileIsDirectory(fullPath)) {
|
|
|
@@ -1305,12 +1307,12 @@ std::string cmCoreTryCompile::WriteSource(std::string const& filename,
|
|
|
{
|
|
|
if (!cmSystemTools::GetFilenamePath(filename).empty()) {
|
|
|
const auto& msg =
|
|
|
- cmStrCat(command, " given invalid filename \"", filename, "\"");
|
|
|
+ cmStrCat(command, " given invalid filename \"", filename, '"');
|
|
|
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, msg);
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
- auto filepath = cmStrCat(this->BinaryDirectory, "/", filename);
|
|
|
+ auto filepath = cmStrCat(this->BinaryDirectory, '/', filename);
|
|
|
cmsys::ofstream file{ filepath.c_str(), std::ios::out };
|
|
|
if (!file) {
|
|
|
const auto& msg =
|
|
|
@@ -1321,7 +1323,7 @@ std::string cmCoreTryCompile::WriteSource(std::string const& filename,
|
|
|
|
|
|
file << content;
|
|
|
if (!file) {
|
|
|
- const auto& msg = cmStrCat(command, " failed to write \"", filename, "\"");
|
|
|
+ const auto& msg = cmStrCat(command, " failed to write \"", filename, '"');
|
|
|
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, msg);
|
|
|
return {};
|
|
|
}
|