Source: migrate ostringstream usage to cmStrCat

This commit is contained in:
AJIOB committed 2026-10-01 11:41:51 +00:00
1 parent 5fba25c052
commit 509514e475
50 files changed
+924 -1110

No files matched your search

+9 -18
View File
@@ -4,7 +4,6 @@
#include <cstddef>
#include <map>
#include <sstream>
#include <utility>
#include <cm/string_view>
@@ -646,19 +645,19 @@ void cmCPackIFWPackage::GeneratePackageFile()
}
// Write dependencies
if (!compDepSet.empty()) {
std::ostringstream dependencies;
auto it = compDepSet.begin();
warnUnsupportedNames |=
hyphensInNamesUnsupported && it->Name.find('-') != std::string::npos;
dependencies << it->NameWithCompare();
std::string dependencies = it->NameWithCompare();
++it;
while (it != compDepSet.end()) {
warnUnsupportedNames |=
hyphensInNamesUnsupported && it->Name.find('-') != std::string::npos;
dependencies << "," << it->NameWithCompare();
dependencies =
cmStrCat(std::move(dependencies), ',', it->NameWithCompare());
++it;
}
xout.Element("Dependencies", dependencies.str());
xout.Element("Dependencies", dependencies);
}
// Automatic dependency on
@@ -668,19 +667,19 @@ void cmCPackIFWPackage::GeneratePackageFile()
}
// Write automatic dependency on
if (!compAutoDepSet.empty()) {
std::ostringstream dependencies;
auto it = compAutoDepSet.begin();
warnUnsupportedNames |=
hyphensInNamesUnsupported && it->Name.find('-') != std::string::npos;
dependencies << it->NameWithCompare();
std::string dependencies = it->NameWithCompare();
++it;
while (it != compAutoDepSet.end()) {
warnUnsupportedNames |=
hyphensInNamesUnsupported && it->Name.find('-') != std::string::npos;
dependencies << "," << it->NameWithCompare();
dependencies =
cmStrCat(std::move(dependencies), ',', it->NameWithCompare());
++it;
}
xout.Element("AutoDependOn", dependencies.str());
xout.Element("AutoDependOn", dependencies);
}
if (warnUnsupportedNames) {
@@ -716,15 +715,7 @@ void cmCPackIFWPackage::GeneratePackageFile()
// Replaces
if (!this->Replaces.empty()) {
std::ostringstream replaces;
auto it = this->Replaces.begin();
replaces << *it;
++it;
while (it != this->Replaces.end()) {
replaces << "," << *it;
++it;
}
xout.Element("Replaces", replaces.str());
xout.Element("Replaces", cmJoin(this->Replaces, ","));
}
if (!this->RequiresAdminRights.empty()) {
+2 -7
View File
@@ -359,9 +359,7 @@ bool cmCPackWIXGenerator::PackageWithWix3()
std::string uniqueBaseName = baseName;
while (usedBaseNames.find(uniqueBaseName) != usedBaseNames.end()) {
std::ostringstream tmp;
tmp << baseName << ++counter;
uniqueBaseName = tmp.str();
uniqueBaseName = cmStrCat(baseName, ++counter);
}
usedBaseNames.insert(uniqueBaseName);
@@ -530,10 +528,7 @@ void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source,
std::string const& name,
std::string const& value)
{
std::ostringstream tmp;
tmp << name << "=\"" << value << '"';
source.AddProcessingInstruction("define", tmp.str());
source.AddProcessingInstruction("define", cmStrCat(name, "=\"", value, '"'));
}
bool cmCPackWIXGenerator::CreateWiXSourceFiles()
+14 -28
View File
@@ -82,31 +82,19 @@ int cmCPackBundleGenerator::ConstructBundle()
// The staging directory contains everything that will end-up inside the
// final disk image ...
std::string const staging = toplevel;
std::string const& staging = toplevel;
std::ostringstream contents;
contents << staging << "/" << cpack_bundle_name
<< ".app/"
"Contents";
std::string const contents =
cmStrCat(staging, '/', cpack_bundle_name, ".app/Contents");
std::ostringstream application;
application << contents.str()
<< "/"
"MacOS";
std::string const application = cmStrCat(contents, "/MacOS");
std::ostringstream resources;
resources << contents.str()
<< "/"
"Resources";
std::string const resources = cmStrCat(contents, "/Resources");
// Install a required, user-provided bundle metadata file ...
std::ostringstream plist_source;
plist_source << cpack_bundle_plist;
std::string const plist_source = cpack_bundle_plist;
std::ostringstream plist_target;
plist_target << contents.str()
<< "/"
"Info.plist";
std::string const plist_target = cmStrCat(contents, "/Info.plist");
if (!this->CopyFile(plist_source, plist_target)) {
cmCPackLogger(
@@ -118,11 +106,10 @@ int cmCPackBundleGenerator::ConstructBundle()
}
// Install a user-provided bundle icon ...
std::ostringstream icon_source;
icon_source << cpack_bundle_icon;
std::string const icon_source = cpack_bundle_icon;
std::ostringstream icon_target;
icon_target << resources.str() << "/" << cpack_bundle_name << ".icns";
std::string const icon_target =
cmStrCat(resources, '/', cpack_bundle_name, ".icns");
if (!this->CopyFile(icon_source, icon_target)) {
cmCPackLogger(
@@ -136,11 +123,10 @@ int cmCPackBundleGenerator::ConstructBundle()
// Optionally a user-provided startup command (could be an
// executable or a script) ...
if (!cpack_bundle_startup_command->empty()) {
std::ostringstream command_source;
command_source << cpack_bundle_startup_command;
std::string const& command_source = cpack_bundle_startup_command;
std::ostringstream command_target;
command_target << application.str() << "/" << cpack_bundle_name;
std::string const command_target =
cmStrCat(application, '/', cpack_bundle_name);
if (!this->CopyFile(command_source, command_target)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -151,7 +137,7 @@ int cmCPackBundleGenerator::ConstructBundle()
return 0;
}
cmSystemTools::SetPermissions(command_target.str().c_str(), 0777);
cmSystemTools::SetPermissions(command_target.c_str(), 0777);
}
return 1;
+25 -32
View File
@@ -224,13 +224,12 @@ int cmCPackDragNDropGenerator::PackageFiles()
return 1;
}
bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source,
std::ostringstream& target)
bool cmCPackDragNDropGenerator::CopyFile(std::string const& source,
std::string const& target)
{
if (!cmSystemTools::CopyFileIfDifferent(source.str(), target.str())) {
if (!cmSystemTools::CopyFileIfDifferent(source, target)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error copying " << source.str() << " to " << target.str()
<< std::endl);
"Error copying " << source << " to " << target << std::endl);
return false;
}
@@ -238,10 +237,10 @@ bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source,
return true;
}
bool cmCPackDragNDropGenerator::CreateEmptyFile(std::ostringstream& target,
bool cmCPackDragNDropGenerator::CreateEmptyFile(std::string const& target,
size_t size)
{
cmsys::ofstream fout(target.str().c_str(), std::ios::out | std::ios::binary);
cmsys::ofstream fout(target.c_str(), std::ios::out | std::ios::binary);
if (!fout) {
return false;
}
@@ -327,24 +326,21 @@ int cmCPackDragNDropGenerator::CreateDMG(std::string const& src_dir,
// The staging directory contains everything that will end-up inside the
// final disk image ...
std::ostringstream staging;
staging << src_dir;
std::string const& staging = src_dir;
// Add a symlink to /Applications so users can drag-and-drop the bundle
// into it unless this behavior was disabled
if (!cpack_dmg_disable_applications_symlink) {
std::ostringstream application_link;
application_link << staging.str() << "/Applications";
cmSystemTools::CreateSymlink("/Applications", application_link.str());
std::string const application_link = cmStrCat(staging, "/Applications");
cmSystemTools::CreateSymlink("/Applications", application_link);
}
// Optionally add a custom volume icon ...
if (!cpack_package_icon->empty()) {
std::ostringstream package_icon_source;
package_icon_source << cpack_package_icon;
std::string const& package_icon_source = cpack_package_icon;
std::ostringstream package_icon_destination;
package_icon_destination << staging.str() << "/.VolumeIcon.icns";
std::string const package_icon_destination =
cmStrCat(staging, "/.VolumeIcon.icns");
if (!this->CopyFile(package_icon_source, package_icon_destination)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -359,11 +355,10 @@ int cmCPackDragNDropGenerator::CreateDMG(std::string const& src_dir,
// Optionally add a custom .DS_Store file
// (e.g. for setting background/layout) ...
if (!cpack_dmg_ds_store->empty()) {
std::ostringstream package_settings_source;
package_settings_source << cpack_dmg_ds_store;
std::string const& package_settings_source = cpack_dmg_ds_store;
std::ostringstream package_settings_destination;
package_settings_destination << staging.str() << "/.DS_Store";
std::string const package_settings_destination =
cmStrCat(staging, "/.DS_Store");
if (!this->CopyFile(package_settings_source,
package_settings_destination)) {
@@ -380,14 +375,12 @@ int cmCPackDragNDropGenerator::CreateDMG(std::string const& src_dir,
// Make sure the background file type is the same as the custom image
// and that the file is hidden so it doesn't show up.
if (!cpack_dmg_background_image->empty()) {
std::string const extension =
std::string extension =
cmSystemTools::GetFilenameLastExtension(cpack_dmg_background_image);
std::ostringstream package_background_source;
package_background_source << cpack_dmg_background_image;
std::string const& package_background_source = cpack_dmg_background_image;
std::ostringstream package_background_destination;
package_background_destination << staging.str()
<< "/.background/background" << extension;
std::string const package_background_destination =
cmStrCat(staging, "/.background/background", std::move(extension));
if (!this->CopyFile(package_background_source,
package_background_destination)) {
@@ -408,8 +401,8 @@ int cmCPackDragNDropGenerator::CreateDMG(std::string const& src_dir,
// Create 1 MB dummy padding file in staging area when we need to remount
// image, so we have enough space for storing changes ...
if (remount_image) {
std::ostringstream dummy_padding;
dummy_padding << staging.str() << "/.dummy-padding-file";
std::string const dummy_padding =
cmStrCat(staging, "/.dummy-padding-file");
if (!this->CreateEmptyFile(dummy_padding, 1048576)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error creating dummy padding file." << std::endl);
@@ -439,7 +432,7 @@ int cmCPackDragNDropGenerator::CreateDMG(std::string const& src_dir,
" create"
" -ov"
" -srcfolder \"",
staging.str(),
staging,
"\""
" -volname \"",
cpack_dmg_volume_name,
@@ -484,9 +477,9 @@ int cmCPackDragNDropGenerator::CreateDMG(std::string const& src_dir,
temp_mount.substr(cmStrLen("/Volumes/"));
// Remove dummy padding file so we have enough space on RW image ...
std::ostringstream dummy_padding;
dummy_padding << temp_mount << "/.dummy-padding-file";
if (!cmSystemTools::RemoveFile(dummy_padding.str())) {
std::string const dummy_padding =
cmStrCat(temp_mount, "/.dummy-padding-file");
if (!cmSystemTools::RemoveFile(dummy_padding)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error removing dummy padding file." << std::endl);
+2 -3
View File
@@ -5,7 +5,6 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <cstddef>
#include <sstream>
#include <string>
#include <vector>
@@ -31,8 +30,8 @@ protected:
int PackageFiles() override;
bool SupportsComponentInstallation() const override;
bool CopyFile(std::ostringstream& source, std::ostringstream& target);
bool CreateEmptyFile(std::ostringstream& target, size_t size);
bool CopyFile(std::string const& source, std::string const& target);
bool CreateEmptyFile(std::string const& target, size_t size);
bool RunCommand(std::string const& command, std::string* output = nullptr);
std::string GetComponentInstallSuffix(
+46 -40
View File
@@ -730,13 +730,13 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
if (component->IsRequired) {
componentCode += " SectionIn RO\n";
} else if (!component->InstallationTypes.empty()) {
std::ostringstream out;
std::string indexes;
for (cmCPackInstallationType const* installType :
component->InstallationTypes) {
out << " " << installType->Index;
indexes = cmStrCat(std::move(indexes), ' ', installType->Index);
}
componentCode =
cmStrCat(std::move(componentCode), " SectionIn", out.str(), '\n');
cmStrCat(std::move(componentCode), " SectionIn", indexes, '\n');
}
std::string const componentOutputDir =
@@ -750,10 +750,9 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
// Compute the name of the archive.
std::string packagesDir =
cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), ".dummy");
std::ostringstream out;
out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-"
<< component->Name << ".zip";
component->ArchiveFile = out.str();
component->ArchiveFile =
cmStrCat(cmSystemTools::GetFilenameWithoutLastExtension(packagesDir),
'-', component->Name, ".zip");
}
// Create the directory for the upload area
@@ -856,19 +855,20 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
if (totalSizeInKbytes == 0) {
totalSizeInKbytes = 1;
}
std::ostringstream out;
/* clang-format off */
out << " AddSize " << totalSizeInKbytes << "\n"
<< " Push \"" << component->ArchiveFile << "\"\n"
<< " Call DownloadFile\n"
<< " ZipDLL::extractall \"$INSTDIR\\"
<< component->ArchiveFile << "\" \"$INSTDIR\"\n"
<< " Pop $2 ; error message\n"
" StrCmp $2 \"success\" +2 0\n"
" MessageBox MB_OK \"Failed to unzip $2\"\n"
" Delete $INSTDIR\\$0\n";
/* clang-format on */
componentCode += out.str();
componentCode =
cmStrCat(std::move(componentCode), " AddSize ", totalSizeInKbytes,
"\n"
" Push \"",
component->ArchiveFile,
"\"\n"
" Call DownloadFile\n"
" ZipDLL::extractall \"$INSTDIR\\",
component->ArchiveFile,
"\" \"$INSTDIR\"\n"
" Pop $2 ; error message\n"
" StrCmp $2 \"success\" +2 0\n"
" MessageBox MB_OK \"Failed to unzip $2\"\n"
" Delete $INSTDIR\\$0\n");
} else {
componentCode =
cmStrCat(std::move(componentCode), " File /r \"${INST_DIR}\\",
@@ -921,19 +921,22 @@ std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription(
}
visited.insert(component);
std::ostringstream out;
std::string out;
for (cmCPackComponent* depend : component->Dependencies) {
// Write NSIS code to select this dependency
out << " SectionGetFlags ${" << depend->Name << "} $0\n";
out << " IntOp $0 $0 | ${SF_SELECTED}\n";
out << " SectionSetFlags ${" << depend->Name << "} $0\n";
out << " IntOp $" << depend->Name << "_selected 0 + ${SF_SELECTED}\n";
// Recurse
out
<< this->CreateSelectionDependenciesDescription(depend, visited).c_str();
out =
cmStrCat(std::move(out), " SectionGetFlags ${", depend->Name,
"} $0\n"
" IntOp $0 $0 | ${SF_SELECTED}\n"
" SectionSetFlags ${",
depend->Name,
"} $0\n"
" IntOp $",
depend->Name, "_selected 0 + ${SF_SELECTED}\n",
this->CreateSelectionDependenciesDescription(depend, visited));
}
return out.str();
return out;
}
std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription(
@@ -945,21 +948,24 @@ std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription(
}
visited.insert(component);
std::ostringstream out;
std::string out;
for (cmCPackComponent* depend : component->ReverseDependencies) {
// Write NSIS code to deselect this dependency
out << " SectionGetFlags ${" << depend->Name << "} $0\n";
out << " IntOp $1 ${SF_SELECTED} ~\n";
out << " IntOp $0 $0 & $1\n";
out << " SectionSetFlags ${" << depend->Name << "} $0\n";
out << " IntOp $" << depend->Name << "_selected 0 + 0\n";
// Recurse
out << this->CreateDeselectionDependenciesDescription(depend, visited)
.c_str();
out = cmStrCat(
std::move(out), " SectionGetFlags ${", depend->Name,
"} $0\n"
" IntOp $1 ${SF_SELECTED} ~\n"
" IntOp $0 $0 & $1\n"
" SectionSetFlags ${",
depend->Name,
"} $0\n"
" IntOp $",
depend->Name, "_selected 0 + 0\n",
// Recurse
this->CreateDeselectionDependenciesDescription(depend, visited));
}
return out.str();
return out;
}
std::string cmCPackNSISGenerator::CreateComponentGroupDescription(
+9 -13
View File
@@ -393,9 +393,8 @@ int cmCTestCoverageHandler::ProcessHandler()
cmsys::ifstream ifs(fullFileName.c_str());
if (!ifs) {
std::ostringstream ostr;
ostr << "Cannot open source file: " << fullFileName;
errorsWhileAccumulating.push_back(ostr.str());
errorsWhileAccumulating.push_back(
cmStrCat("Cannot open source file: ", fullFileName));
error++;
continue;
}
@@ -412,10 +411,9 @@ int cmCTestCoverageHandler::ProcessHandler()
for (cc = 0; cc < fcov.size(); cc++) {
if (!cmSystemTools::GetLineFromStream(ifs, line) &&
cc != fcov.size() - 1) {
std::ostringstream ostr;
ostr << "Problem reading source file: " << fullFileName
<< " line:" << cc << " out total: " << fcov.size() - 1;
errorsWhileAccumulating.push_back(ostr.str());
errorsWhileAccumulating.push_back(
cmStrCat("Problem reading source file: ", fullFileName, " line:", cc,
" out total: ", fcov.size() - 1));
error++;
break;
}
@@ -439,9 +437,8 @@ int cmCTestCoverageHandler::ProcessHandler()
}
}
if (cmSystemTools::GetLineFromStream(ifs, line)) {
std::ostringstream ostr;
ostr << "Looks like there are more lines in the file: " << fullFileName;
errorsWhileAccumulating.push_back(ostr.str());
errorsWhileAccumulating.push_back(cmStrCat(
"Looks like there are more lines in the file: ", fullFileName));
}
float cper = 0;
float cmet = 0;
@@ -483,9 +480,8 @@ int cmCTestCoverageHandler::ProcessHandler()
cmsys::ifstream ifs(fullPath.c_str());
if (!ifs) {
std::ostringstream ostr;
ostr << "Cannot open source file: " << fullPath;
errorsWhileAccumulating.push_back(ostr.str());
errorsWhileAccumulating.push_back(
cmStrCat("Cannot open source file: ", fullPath));
error++;
covLogXML.EndElement(); // Report
covLogXML.EndElement(); // File
+4 -5
View File
@@ -64,14 +64,13 @@ public:
this->ParseError(atts);
}
// Create the log
std::ostringstream ostr;
ostr << name << ":\n";
std::string ostr = cmStrCat(std::move(this->Log), name, ":\n");
int i = 0;
for (; atts[i]; i += 2) {
ostr << " " << atts[i] << " - " << atts[i + 1] << "\n";
ostr =
cmStrCat(std::move(ostr), " ", atts[i], " - ", atts[i + 1], '\n');
}
ostr << "\n";
this->Log += ostr.str();
this->Log = cmStrCat(std::move(ostr), '\n');
}
void EndElement(std::string const& /*name*/) override {}
+4 -8
View File
@@ -5,7 +5,6 @@
#include <cstdlib>
#include <functional>
#include <map>
#include <sstream>
#include <utility>
#include <cm/memory>
@@ -30,6 +29,7 @@
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmUVProcessChain.h"
#include "cmake.h"
@@ -143,13 +143,9 @@ int cmCTestScriptHandler::ExecuteScript(std::string const& total_script_arg)
failed = true;
}
if (failed) {
std::ostringstream message;
message << "Error running command: [";
message << static_cast<int>(result.first) << "] ";
for (std::string const& arg : argv) {
message << arg << " ";
}
cmCTestLog(this->CTest, ERROR_MESSAGE, message.str(), '\n');
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error running command: [",
static_cast<int>(result.first), "] ", cmWrap("", argv, " ", ""),
'\n');
return -1;
}
return retVal;
+7 -8
View File
@@ -3,7 +3,6 @@
#include "cmCTestSubmitCommand.h"
#include <set>
#include <sstream>
#include <utility>
#include <cm/memory>
@@ -19,6 +18,7 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmRange.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmValue.h"
@@ -219,9 +219,8 @@ void cmCTestSubmitCommand::CheckArguments(HandlerArguments& arguments,
cm::erase_if(*(args.Parts), [this, &mf](std::string const& arg) -> bool {
cmCTest::Part p = this->CTest->GetPartFromName(arg);
if (p == cmCTest::PartCount) {
std::ostringstream e;
e << "Part name \"" << arg << "\" is invalid.";
mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
mf.IssueMessage(MessageType::FATAL_ERROR,
cmStrCat("Part name \"", arg, "\" is invalid."));
return true;
}
return false;
@@ -231,10 +230,10 @@ void cmCTestSubmitCommand::CheckArguments(HandlerArguments& arguments,
if (args.Files) {
cm::erase_if(*(args.Files), [&mf](std::string const& arg) -> bool {
if (!cmSystemTools::FileExists(arg)) {
std::ostringstream e;
e << "File \"" << arg << "\" does not exist. Cannot submit "
<< "a non-existent file.";
mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
mf.IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("File \"", arg,
"\" does not exist. Cannot submit a non-existent file."));
return true;
}
return false;
+3 -8
View File
@@ -4,11 +4,12 @@
#include <cstdio>
#include <ctime>
#include <sstream>
#include <ostream>
#include <vector>
#include "cmCTest.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmUVProcessChain.h"
#include "cmXMLWriter.h"
@@ -85,13 +86,7 @@ bool cmCTestVC::RunChild(std::vector<std::string> const& cmd,
std::string cmCTestVC::ComputeCommandLine(std::vector<std::string> const& cmd)
{
std::ostringstream line;
char const* sep = "";
for (auto const& arg : cmd) {
line << sep << "\"" << arg << "\"";
sep = " ";
}
return line.str();
return cmWrap('"', cmd, '"', " ");
}
bool cmCTestVC::RunUpdateCommand(std::vector<std::string> const& cmd,
+13 -16
View File
@@ -3,12 +3,12 @@
#include "cmCMakeMinimumRequired.h"
#include <cstdio>
#include <sstream>
#include "cmDiagnostics.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
@@ -60,10 +60,9 @@ bool cmCMakeMinimumRequired(std::vector<std::string> const& args,
: std::string();
if (dd != std::string::npos &&
(version_min.empty() || version_max.empty())) {
std::ostringstream e;
e << "VERSION \"" << version_string
<< R"(" does not have a version on both sides of "...".)";
status.SetError(e.str());
status.SetError(
cmStrCat("VERSION \"", version_string,
R"(" does not have a version on both sides of "...".)"));
return false;
}
@@ -85,9 +84,8 @@ bool cmCMakeMinimumRequired(std::vector<std::string> const& args,
unsigned int required_tweak = 0;
if (sscanf(version_min.c_str(), "%u.%u.%u.%u", &required_major,
&required_minor, &required_patch, &required_tweak) < 2) {
std::ostringstream e;
e << "could not parse VERSION \"" << version_min << "\".";
status.SetError(e.str());
status.SetError(
cmStrCat("could not parse VERSION \"", version_min, "\"."));
return false;
}
@@ -99,11 +97,11 @@ bool cmCMakeMinimumRequired(std::vector<std::string> const& args,
(current_major == required_major && current_minor == required_minor &&
current_patch == required_patch && current_tweak < required_tweak)) {
// The current version is too low.
std::ostringstream e;
e << "CMake " << version_min
<< " or higher is required. You are running version "
<< cmVersion::GetCMakeVersion();
status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
status.GetMakefile().IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("CMake ", version_min,
" or higher is required. You are running version ",
cmVersion::GetCMakeVersion()));
cmSystemTools::SetFatalErrorOccurred();
return true;
}
@@ -158,9 +156,8 @@ bool EnforceUnknownArguments(std::string const& version_max,
}
}
std::ostringstream e;
e << "called with unknown argument \"" << unknown_arguments[0] << "\".";
status.SetError(e.str());
status.SetError(
cmStrCat("called with unknown argument \"", unknown_arguments[0], "\"."));
return false;
}
}
+2 -3
View File
@@ -454,9 +454,8 @@ int cmCallVisualStudioMacro::CallMacro(std::string const& slnFile,
#endif
if (err && LogErrorsAsMessages) {
std::ostringstream oss;
oss << "cmCallVisualStudioMacro::CallMacro failed, err = " << err;
cmSystemTools::Message(oss.str());
cmSystemTools::Message(
cmStrCat("cmCallVisualStudioMacro::CallMacro failed, err = ", err));
}
return 0;
+30 -31
View File
@@ -6,7 +6,6 @@
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <utility>
#include <cm/string_view>
@@ -491,10 +490,11 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
// do not allow recursive try Compiles
if (this->BinaryDirectory == this->Makefile->GetHomeOutputDirectory()) {
std::ostringstream e;
e << "Attempt at a recursive or nested TRY_COMPILE in directory\n"
<< " " << this->BinaryDirectory << "\n";
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Attempt at a recursive or nested TRY_COMPILE in directory\n"
" ",
this->BinaryDirectory, '\n'));
return cm::nullopt;
}
@@ -580,19 +580,19 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
if (!lang.empty()) {
testLangs.insert(std::string(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 ";
std::vector<std::string> langs;
gg->GetEnabledLanguages(langs);
err << cmJoin(langs, " ");
err << "\nSee project() command to enable other languages.";
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, err.str());
this->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Unknown extension \"", ext,
"\" for file\n"
" ",
si,
"\n"
"try_compile() works only for enabled languages. "
"Currently these are:\n ",
cmJoin(langs, " "),
"\nSee project() command to enable other languages."));
return cm::nullopt;
}
}
@@ -1038,13 +1038,12 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
}
if (!warnCMP0067Variables.empty()) {
std::ostringstream w;
w << "For compatibility with older versions of CMake, try_compile is "
"not honoring language standard variables in the test project:\n"_s;
for (std::string const& vi : warnCMP0067Variables) {
w << " " << vi << "\n";
}
this->Makefile->IssuePolicyWarning(cmPolicies::CMP0067, {}, w.str());
this->Makefile->IssuePolicyWarning(
cmPolicies::CMP0067, {},
cmStrCat("For compatibility with older versions of CMake, try_compile "
"is not honoring language standard variables in the test "
"project:\n",
cmWrap(" ", warnCMP0067Variables, "\n", "")));
}
for (auto const& p : arguments.LangProps) {
@@ -1425,10 +1424,10 @@ void cmCoreTryCompile::FindOutputFile(std::string const& targetName)
std::string command = cmStrCat(this->BinaryDirectory, tmpOutputFile);
if (!cmSystemTools::FileExists(command)) {
std::ostringstream emsg;
emsg << "Unable to find the recorded try_compile output location:\n";
emsg << cmStrCat(" ", command, '\n');
this->FindErrorMessage = emsg.str();
this->FindErrorMessage =
cmStrCat("Unable to find the recorded try_compile output location:\n"
" ",
command, '\n');
return;
}
@@ -1436,10 +1435,10 @@ void cmCoreTryCompile::FindOutputFile(std::string const& targetName)
cmsys::ifstream ifs(command.c_str());
cmSystemTools::GetLineFromStream(ifs, outputFileLocation);
if (!cmSystemTools::FileExists(outputFileLocation)) {
std::ostringstream emsg;
emsg << "Recorded try_compile output location doesn't exist:\n";
emsg << cmStrCat(" ", outputFileLocation, '\n');
this->FindErrorMessage = emsg.str();
this->FindErrorMessage =
cmStrCat("Recorded try_compile output location doesn't exist:\n"
" ",
outputFileLocation, '\n');
return;
}
+4 -5
View File
@@ -7,7 +7,6 @@
#include <iostream>
#include <map>
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
@@ -531,12 +530,12 @@ bool cmExecuteProcessCommand(std::vector<std::string> const& args,
}
}
if (!failureIndices.empty()) {
std::ostringstream oss;
oss << "failed command indexes:\n";
std::string oss = "failed command indexes:\n";
for (auto const& e : failureIndices) {
oss << " " << e.first + 1 << ": \"" << e.second << "\"\n";
oss = cmStrCat(std::move(oss), " ", e.first + 1, ": \"", e.second,
"\"\n");
}
status.SetError(oss.str());
status.SetError(oss);
ret = false;
}
}
+2 -3
View File
@@ -242,9 +242,8 @@ void cmExportBuildFileGenerator::ComplainAboutMissingTarget(
void cmExportBuildFileGenerator::ComplainAboutDuplicateTarget(
std::string const& targetName) const
{
std::ostringstream e;
e << "given target \"" << targetName << "\" more than once.";
this->ReportError(e.str());
this->ReportError(
cmStrCat("given target \"", targetName, "\" more than once."));
}
void cmExportBuildFileGenerator::IssueMessage(MessageType type,
+15 -19
View File
@@ -5,7 +5,6 @@
#include <array>
#include <cstddef>
#include <functional>
#include <sstream>
#include <utility>
#include <cm/memory>
@@ -72,9 +71,8 @@ bool cmExportFileGenerator::GenerateImportFile()
}
if (!foutPtr || !*foutPtr) {
std::string se = cmSystemTools::GetLastSystemError();
std::ostringstream e;
e << "cannot write to file \"" << this->MainImportFile << "\": " << se;
cmSystemTools::Error(e.str());
cmSystemTools::Error(
cmStrCat("cannot write to file \"", this->MainImportFile, "\": ", se));
return false;
}
@@ -292,11 +290,11 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget const* target,
if (!info) {
cmLocalGenerator* lg = target->GetLocalGenerator();
std::ostringstream e;
e << "Exporting the target \"" << target->GetName()
<< "\" is not "
"allowed since its linker language cannot be determined";
lg->IssueMessage(MessageType::FATAL_ERROR, e.str());
lg->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Exporting the target \"", target->GetName(),
"\" is not allowed since its linker language cannot be "
"determined"));
return;
}
@@ -842,11 +840,10 @@ bool cmExportFileGenerator::PopulateExportProperties(
/* Black list reserved properties */
if (cmHasLiteralPrefix(prop, "IMPORTED_") ||
cmHasLiteralPrefix(prop, "INTERFACE_")) {
std::ostringstream e;
e << "Target \"" << gte->Target->GetName() << "\" contains property \""
<< prop << "\" in EXPORT_PROPERTIES but IMPORTED_* and INTERFACE_* "
<< "properties are reserved.";
errorMessage = e.str();
errorMessage = cmStrCat(
"Target \"", gte->Target->GetName(), "\" contains property \"", prop,
"\" in EXPORT_PROPERTIES but IMPORTED_* and INTERFACE_* "
"properties are reserved.");
return false;
}
cmValue propertyValue = targetProperties.GetPropertyValue(prop);
@@ -858,11 +855,10 @@ bool cmExportFileGenerator::PopulateExportProperties(
std::string evaluatedValue = cmGeneratorExpression::Preprocess(
*propertyValue, cmGeneratorExpression::StripAllGeneratorExpressions);
if (evaluatedValue != *propertyValue) {
std::ostringstream e;
e << "Target \"" << gte->Target->GetName() << "\" contains property \""
<< prop << "\" in EXPORT_PROPERTIES but this property contains a "
<< "generator expression. This is not allowed.";
errorMessage = e.str();
errorMessage = cmStrCat(
"Target \"", gte->Target->GetName(), "\" contains property \"", prop,
"\" in EXPORT_PROPERTIES but this property contains a "
"generator expression. This is not allowed.");
return false;
}
properties[prop] = *propertyValue;
+32 -39
View File
@@ -123,9 +123,8 @@ bool cmExportInstallFileGenerator::GenerateImportFileConfig(
cmGeneratedFileStream exportFileStream(fileName, true);
if (!exportFileStream) {
std::string se = cmSystemTools::GetLastSystemError();
std::ostringstream e;
e << "cannot write to file \"" << fileName << "\": " << se;
cmSystemTools::Error(e.str());
cmSystemTools::Error(
cmStrCat("cannot write to file \"", fileName, "\": ", se));
return false;
}
exportFileStream.SetCopyIfDifferent(true);
@@ -303,11 +302,10 @@ void cmExportInstallFileGenerator::ComplainAboutMissingTarget(
void cmExportInstallFileGenerator::ComplainAboutDuplicateTarget(
std::string const& targetName) const
{
std::ostringstream e;
e << "install(" << this->IEGen->InstallSubcommand() << " \""
<< this->GetExportName() << "\" ...) " << "includes target \""
<< targetName << "\" more than once in the export set.";
this->ReportError(e.str());
this->ReportError(cmStrCat("install(", this->IEGen->InstallSubcommand(),
" \"", this->GetExportName(),
"\" ...) includes target \"", targetName,
"\" more than once in the export set."));
}
void cmExportInstallFileGenerator::IssueMessage(
@@ -446,14 +444,12 @@ bool cmExportInstallFileGenerator::CheckInterfaceDirs(
hadFatalError = true;
}
if (!cmSystemTools::FileIsFullPath(li)) {
std::ostringstream e;
/* clang-format off */
e << "Target \"" << target->GetName() << "\" " << prop <<
" property contains relative path:\n"
" \"" << li << "\"";
/* clang-format on */
target->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
e.str());
target->GetLocalGenerator()->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Target \"", target->GetName(), "\" ", prop,
" property contains relative path:\n"
" \"",
li, '"'));
}
bool inBinary = isSubDirectory(li, topBinaryDir);
bool inSource = isSubDirectory(li, topSourceDir);
@@ -468,24 +464,21 @@ bool cmExportInstallFileGenerator::CheckInterfaceDirs(
}
}
if (inBinary) {
std::ostringstream e;
/* clang-format off */
e << "Target \"" << target->GetName() << "\" " << prop <<
" property contains path:\n"
" \"" << li << "\"\nwhich is prefixed in the build directory.";
/* clang-format on */
target->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
e.str());
target->GetLocalGenerator()->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Target \"", target->GetName(), "\" ", prop,
" property contains path:\n"
" \"",
li, "\"\nwhich is prefixed in the build directory."));
}
if (!inSourceBuild) {
if (inSource) {
std::ostringstream e;
e << "Target \"" << target->GetName() << "\" " << prop
<< " property contains path:\n"
" \""
<< li << "\"\nwhich is prefixed in the source directory.";
target->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
e.str());
target->GetLocalGenerator()->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Target \"", target->GetName(), "\" ", prop,
" property contains path:\n"
" \"",
li, "\"\nwhich is prefixed in the source directory."));
}
}
}
@@ -580,14 +573,14 @@ void cmExportInstallFileGenerator::PopulateIncludeDirectoriesInterface(
if (cge->GetHadContextSensitiveCondition()) {
cmLocalGenerator* lg = target->GetLocalGenerator();
std::ostringstream e;
e << "Target \"" << target->GetName()
<< "\" is installed with "
"INCLUDES DESTINATION set to a context sensitive path. Paths which "
"depend on the configuration, policy values or the link interface "
"are "
"not supported. Consider using target_include_directories instead.";
lg->IssueMessage(MessageType::FATAL_ERROR, e.str());
lg->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Target \"", target->GetName(),
"\" is installed with "
"INCLUDES DESTINATION set to a context sensitive path. Paths "
"which depend on the configuration, policy values or the link "
"interface are not supported. Consider using "
"target_include_directories instead."));
return;
}
+6 -9
View File
@@ -647,14 +647,11 @@ std::string cmExtraCodeLiteGenerator::GetCleanCommand(
cmMakefile const* mf, std::string const& targetName) const
{
std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
std::ostringstream ss;
std::string buildcommand = this->GetBuildCommand(mf, "");
if (!targetName.empty() && generator == "Ninja") {
ss << buildcommand << " -t clean " << targetName;
} else {
ss << buildcommand << " clean";
return cmStrCat(std::move(buildcommand), " -t clean ", targetName);
}
return ss.str();
return cmStrCat(std::move(buildcommand), " clean");
}
std::string cmExtraCodeLiteGenerator::GetRebuildCommand(
@@ -671,13 +668,13 @@ std::string cmExtraCodeLiteGenerator::GetSingleFileBuildCommand(
std::string const& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
std::string const& generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
if (generator == "Unix Makefiles" || generator == "MinGW Makefiles") {
std::ostringstream ss;
#if defined(_WIN32)
ss << make << " -f$(ProjectPath)/Makefile -B $(CurrentFileFullName).obj";
buildCommand = cmStrCat(
make, " -f$(ProjectPath)/Makefile -B $(CurrentFileFullName).obj");
#else
ss << make << " -f$(ProjectPath)/Makefile -B $(CurrentFileFullName).o";
buildCommand =
cmStrCat(make, " -f$(ProjectPath)/Makefile -B $(CurrentFileFullName).o");
#endif
buildCommand = ss.str();
}
return buildCommand;
}
+2 -7
View File
@@ -9,7 +9,6 @@
#include <functional>
#include <iterator>
#include <map>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
@@ -376,15 +375,11 @@ bool cmFastbuildNormalTargetGenerator::DetectBaseLinkerCommand(
std::string targetVersionMajor;
std::string targetVersionMinor;
{
std::ostringstream majorStream;
std::ostringstream minorStream;
int major;
int minor;
this->GeneratorTarget->GetTargetVersion(major, minor);
majorStream << major;
minorStream << minor;
targetVersionMajor = majorStream.str();
targetVersionMinor = minorStream.str();
targetVersionMajor = std::to_string(major);
targetVersionMinor = std::to_string(minor);
}
vars.TargetVersionMajor = targetVersionMajor.c_str();
vars.TargetVersionMinor = targetVersionMinor.c_str();
+4 -5
View File
@@ -792,15 +792,14 @@ bool cmFileAPI::ReadRequestVersion(Json::Value const& version, bool inArray,
std::string cmFileAPI::NoSupportedVersion(
std::vector<RequestVersion> const& versions)
{
std::ostringstream msg;
msg << "no supported version specified";
std::string msg = "no supported version specified";
if (!versions.empty()) {
msg << " among:";
msg += " among:";
for (RequestVersion const& v : versions) {
msg << " " << v.Major << "." << v.Minor;
msg = cmStrCat(std::move(msg), ' ', v.Major, '.', v.Minor);
}
}
return msg.str();
return msg;
}
// The "codemodel" object kind.
+6 -12
View File
@@ -3529,12 +3529,9 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
std::string pathsStr = cmList::to_string(paths);
status.GetMakefile().AddDefinition(varName, pathsStr);
} else {
std::ostringstream e;
e << "Multiple conflicting paths found for " << val.first << ":";
for (auto const& path : val.second) {
e << "\n " << path;
}
status.SetError(e.str());
status.SetError(cmStrCat("Multiple conflicting paths found for ",
val.first, ':',
cmWrap("\n ", val.second, "", "")));
cmSystemTools::SetFatalErrorOccurred();
return false;
}
@@ -3545,12 +3542,9 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
archive.GetUnresolvedPaths().begin(),
archive.GetUnresolvedPaths().end());
} else {
std::ostringstream e;
e << "Could not resolve runtime dependencies:";
for (auto const& path : archive.GetUnresolvedPaths()) {
e << "\n " << path;
}
status.SetError(e.str());
status.SetError(
cmStrCat("Could not resolve runtime dependencies:",
cmWrap("\n ", archive.GetUnresolvedPaths(), "", "")));
cmSystemTools::SetFatalErrorOccurred();
return false;
}
+28 -43
View File
@@ -23,7 +23,6 @@
# include <cerrno>
#endif
#include <sstream>
#include <utility>
using namespace cmFSPermissions;
@@ -88,10 +87,9 @@ bool cmFileCopier::SetPermissions(std::string const& toFile,
auto perm_status = cmSystemTools::SetPermissions(toFile, permissions);
if (!perm_status) {
std::ostringstream e;
e << this->Name << " cannot set permissions on \"" << toFile
<< "\": " << perm_status.GetString() << ".";
this->Status.SetError(e.str());
this->Status.SetError(cmStrCat(this->Name,
" cannot set permissions on \"", toFile,
"\": ", perm_status.GetString(), '.'));
return false;
}
}
@@ -103,9 +101,8 @@ bool cmFileCopier::CheckPermissions(std::string const& arg,
mode_t& permissions)
{
if (!cmFSPermissions::stringToModeT(arg, permissions)) {
std::ostringstream e;
e << this->Name << " given invalid permission \"" << arg << "\".";
this->Status.SetError(e.str());
this->Status.SetError(
cmStrCat(this->Name, " given invalid permission \"", arg, "\"."));
return false;
}
return true;
@@ -127,17 +124,15 @@ bool cmFileCopier::ReportMissing(std::string const& fromFile)
void cmFileCopier::NotBeforeMatch(std::string const& arg)
{
std::ostringstream e;
e << "option " << arg << " may not appear before PATTERN or REGEX.";
this->Status.SetError(e.str());
this->Status.SetError(
cmStrCat("option ", arg, " may not appear before PATTERN or REGEX."));
this->Doing = DoingError;
}
void cmFileCopier::NotAfterMatch(std::string const& arg)
{
std::ostringstream e;
e << "option " << arg << " may not appear after PATTERN or REGEX.";
this->Status.SetError(e.str());
this->Status.SetError(
cmStrCat("option ", arg, " may not appear after PATTERN or REGEX."));
this->Doing = DoingError;
}
@@ -191,9 +186,8 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args)
for (unsigned int i = 1; i < args.size(); ++i) {
// Check this argument.
if (!this->CheckKeyword(args[i]) && !this->CheckValue(args[i])) {
std::ostringstream e;
e << "called with unknown argument \"" << args[i] << "\".";
this->Status.SetError(e.str());
this->Status.SetError(
cmStrCat("called with unknown argument \"", args[i], "\"."));
return false;
}
@@ -205,9 +199,7 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args)
// Require a destination.
if (this->Destination.empty()) {
std::ostringstream e;
e << this->Name << " given no DESTINATION";
this->Status.SetError(e.str());
this->Status.SetError(cmStrCat(this->Name, " given no DESTINATION"));
return false;
}
@@ -337,9 +329,8 @@ bool cmFileCopier::CheckValue(std::string const& arg)
if (this->CurrentMatchRule->Regex.is_valid()) {
this->Doing = DoingNone;
} else {
std::ostringstream e;
e << "could not compile PATTERN \"" << arg << "\".";
this->Status.SetError(e.str());
this->Status.SetError(
cmStrCat("could not compile PATTERN \"", arg, "\"."));
this->Doing = DoingError;
}
} break;
@@ -349,9 +340,8 @@ bool cmFileCopier::CheckValue(std::string const& arg)
if (this->CurrentMatchRule->Regex.is_valid()) {
this->Doing = DoingNone;
} else {
std::ostringstream e;
e << "could not compile REGEX \"" << arg << "\".";
this->Status.SetError(e.str());
this->Status.SetError(
cmStrCat("could not compile REGEX \"", arg, "\"."));
this->Doing = DoingError;
}
break;
@@ -528,11 +518,9 @@ bool cmFileCopier::InstallSymlink(std::string const& fromFile,
auto read_symlink_status =
cmSystemTools::ReadSymlink(fromFile, symlinkTarget);
if (!read_symlink_status) {
std::ostringstream e;
e << this->Name << " cannot read symlink \"" << fromFile
<< "\" to duplicate at \"" << toFile
<< "\": " << read_symlink_status.GetString() << ".";
this->Status.SetError(e.str());
this->Status.SetError(cmStrCat(
this->Name, " cannot read symlink \"", fromFile, "\" to duplicate at \"",
toFile, "\": ", read_symlink_status.GetString(), '.'));
return false;
}
@@ -604,10 +592,9 @@ bool cmFileCopier::InstallFile(std::string const& fromFile,
if (copy) {
auto copy_status = cmSystemTools::CopyAFile(fromFile, toFile);
if (!copy_status) {
std::ostringstream e;
e << this->Name << " cannot copy file \"" << fromFile << "\" to \""
<< toFile << "\": " << copy_status.GetString() << ".";
this->Status.SetError(e.str());
this->Status.SetError(cmStrCat(this->Name, " cannot copy file \"",
fromFile, "\" to \"", toFile,
"\": ", copy_status.GetString(), '.'));
return false;
}
}
@@ -622,10 +609,9 @@ bool cmFileCopier::InstallFile(std::string const& fromFile,
}
auto copy_status = cmFileTimes::Copy(fromFile, toFile);
if (!copy_status) {
std::ostringstream e;
e << this->Name << " cannot set modification time on \"" << toFile
<< "\": " << copy_status.GetString() << ".";
this->Status.SetError(e.str());
this->Status.SetError(
cmStrCat(this->Name, " cannot set modification time on \"", toFile,
"\": ", copy_status.GetString(), '.'));
return false;
}
}
@@ -664,10 +650,9 @@ bool cmFileCopier::InstallDirectory(std::string const& source,
auto makedir_status =
cmSystemTools::MakeDirectory(destination, default_dir_mode);
if (!makedir_status) {
std::ostringstream e;
e << this->Name << " cannot make directory \"" << destination
<< "\": " << makedir_status.GetString() << ".";
this->Status.SetError(e.str());
this->Status.SetError(cmStrCat(this->Name, " cannot make directory \"",
destination,
"\": ", makedir_status.GetString(), '.'));
return false;
}
+7 -9
View File
@@ -4,7 +4,6 @@
#include "cmFileInstaller.h"
#include <map>
#include <sstream>
#include <utility>
#include <vector>
@@ -323,11 +322,11 @@ bool cmFileInstaller::CheckKeyword(std::string const& arg)
}
} else if (arg == "COMPONENTS" || arg == "CONFIGURATIONS" ||
arg == "PROPERTIES") {
std::ostringstream e;
e << "INSTALL called with old-style " << arg << " argument. "
<< "This script was generated with an older version of CMake. "
<< "Re-run this cmake version on your build tree.";
this->Status.SetError(e.str());
this->Status.SetError(
cmStrCat("INSTALL called with old-style ", arg,
" argument. "
"This script was generated with an older version of CMake. "
"Re-run this cmake version on your build tree."));
this->Doing = DoingError;
} else {
return this->cmFileCopier::CheckKeyword(arg);
@@ -369,9 +368,8 @@ bool cmFileInstaller::GetTargetTypeFromString(std::string const& stype)
} else if (stype == "DIRECTORY") {
this->InstallType = cmInstallType_DIRECTORY;
} else {
std::ostringstream e;
e << "Option TYPE given unknown value \"" << stype << "\".";
this->Status.SetError(e.str());
this->Status.SetError(
cmStrCat("Option TYPE given unknown value \"", stype, "\"."));
return false;
}
return true;
+6 -7
View File
@@ -933,17 +933,16 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
this->UseCpsFiles = false;
}
if (!this->UseFindModules && !this->UseConfigFiles) {
std::ostringstream e;
e << "given options exclusive to Module mode:\n";
std::string e = "given options exclusive to Module mode:\n";
for (auto si : moduleArgs) {
e << " " << args[si] << "\n";
e = cmStrCat(std::move(e), " ", args[si], '\n');
}
e << "and options exclusive to Config mode:\n";
e = cmStrCat(std::move(e), "and options exclusive to Config mode:\n");
for (auto si : configArgs) {
e << " " << args[si] << "\n";
e = cmStrCat(std::move(e), " ", args[si], '\n');
}
e << "The options are incompatible.";
this->SetError(e.str());
e = cmStrCat(std::move(e), "The options are incompatible.");
this->SetError(e);
return false;
}
+21 -20
View File
@@ -2,7 +2,6 @@
file LICENSE.rst or https://cmake.org/licensing for details. */
#include "cmGeneratorExpressionDAGChecker.h"
#include <sstream>
#include <utility>
#include <cm/optional>
@@ -76,36 +75,38 @@ void cmGeneratorExpressionDAGChecker::ReportError(cm::GenEx::Evaluation* eval,
cmGeneratorExpressionDAGChecker const* parent = this->Parent;
if (parent && !parent->Parent) {
std::ostringstream e;
e << "Error evaluating generator expression:\n"
<< " " << expr << "\n"
<< "Self reference on target \"" << eval->HeadTarget->GetName()
<< "\".\n";
eval->Context.LG->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR, e.str(), parent->Backtrace);
MessageType::FATAL_ERROR,
cmStrCat("Error evaluating generator expression:\n"
" ",
expr,
"\n"
"Self reference on target \"",
eval->HeadTarget->GetName(), "\".\n"),
parent->Backtrace);
return;
}
{
std::ostringstream e;
/* clang-format off */
e << "Error evaluating generator expression:\n"
<< " " << expr << "\n"
<< "Dependency loop found.";
/* clang-format on */
eval->Context.LG->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR, e.str(), eval->Backtrace);
MessageType::FATAL_ERROR,
cmStrCat("Error evaluating generator expression:\n"
" ",
expr,
"\n"
"Dependency loop found."),
eval->Backtrace);
}
int loopStep = 1;
while (parent) {
std::ostringstream e;
e << "Loop step " << loopStep << "\n"
<< " "
<< (parent->Content ? parent->Content->GetOriginalExpression() : expr)
<< "\n";
eval->Context.LG->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR, e.str(), parent->Backtrace);
MessageType::FATAL_ERROR,
cmStrCat("Loop step ", loopStep, "\n ",
parent->Content ? parent->Content->GetOriginalExpression()
: expr,
'\n'),
parent->Backtrace);
parent = parent->Parent;
++loopStep;
}
+14 -16
View File
@@ -56,12 +56,10 @@ void cmGeneratorExpressionEvaluationFile::Generate(
return;
}
if (condResult != "1") {
std::ostringstream e;
e << "Evaluation file condition \"" << rawCondition
<< "\" did "
"not evaluate to valid content. Got \""
<< condResult << "\".";
lg->IssueMessage(MessageType::FATAL_ERROR, e.str());
lg->IssueMessage(MessageType::FATAL_ERROR,
cmStrCat("Evaluation file condition \"", rawCondition,
"\" did not evaluate to valid content. Got \"",
condResult, "\"."));
return;
}
}
@@ -76,13 +74,13 @@ void cmGeneratorExpressionEvaluationFile::Generate(
if (it->second == outputContent) {
return;
}
std::ostringstream e;
e << "Evaluation file to be written multiple times with different "
"content. "
"This is generally caused by the content evaluating the "
"configuration type, language, or location of object files:\n "
<< outputFileName;
lg->IssueMessage(MessageType::FATAL_ERROR, e.str());
lg->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Evaluation file to be written multiple times with different "
"content. "
"This is generally caused by the content evaluating the "
"configuration type, language, or location of object files:\n ",
outputFileName));
return;
}
@@ -158,9 +156,9 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
}
cmsys::ifstream fin(inputFileName.c_str());
if (!fin) {
std::ostringstream e;
e << "Evaluation file \"" << inputFileName << "\" cannot be read.";
lg->IssueMessage(MessageType::FATAL_ERROR, e.str());
lg->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Evaluation file \"", inputFileName, "\" cannot be read."));
return;
}
+62 -71
View File
@@ -12,7 +12,6 @@
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <stdexcept>
#include <unordered_map>
#include <utility>
@@ -70,14 +69,12 @@ bool HasKnownObjectFileLocation(cm::GenEx::Evaluation* eval,
std::string reason;
if (!eval->EvaluateForBuildsystem &&
!target->Target->HasKnownObjectFileLocation(&reason)) {
std::ostringstream e;
e << "The evaluation of the " << genex
<< " generator expression "
"is only suitable for consumption by CMake (limited"
<< reason
<< "). "
"It is not suitable for writing out elsewhere.";
reportError(eval, content->GetOriginalExpression(), e.str());
reportError(
eval, content->GetOriginalExpression(),
cmStrCat("The evaluation of the ", genex,
" generator expression is only suitable for consumption by "
"CMake (limited",
reason, "). It is not suitable for writing out elsewhere."));
return false;
}
return true;
@@ -310,10 +307,9 @@ struct BooleanOpNode : public cmGeneratorExpressionNode
return this->failureVal;
}
if (param != this->successVal) {
std::ostringstream e;
e << "Parameters to $<" << this->op;
e << "> must resolve to either '0' or '1'.";
reportError(eval, content->GetOriginalExpression(), e.str());
reportError(eval, content->GetOriginalExpression(),
cmStrCat("Parameters to $<", this->op,
"> must resolve to either '0' or '1'."));
return std::string();
}
}
@@ -764,10 +760,9 @@ static const struct TargetGenexEvalNode : public GenexEvaluator
auto const* target =
eval->Context.LG->FindGeneratorTargetToUse(targetName);
if (!target) {
std::ostringstream e;
e << "$<TARGET_GENEX_EVAL:tgt, ...> target \"" << targetName
<< "\" not found.";
reportError(eval, content->GetOriginalExpression(), e.str());
reportError(eval, content->GetOriginalExpression(),
cmStrCat("$<TARGET_GENEX_EVAL:tgt, ...> target \"",
targetName, "\" not found."));
return std::string();
}
@@ -3003,11 +2998,11 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
cmGeneratorExpressionDAGChecker* dagChecker) const override
{
if (!eval->HeadTarget) {
std::ostringstream e;
e << "$<" << this->CompilerLanguage
<< "_COMPILER_ID> may only be used with binary targets. It may "
"not be used with add_custom_command or add_custom_target.";
reportError(eval, content->GetOriginalExpression(), e.str());
reportError(
eval, content->GetOriginalExpression(),
cmStrCat("$<", this->CompilerLanguage,
"_COMPILER_ID> may only be used with binary targets. It may "
"not be used with add_custom_command or add_custom_target."));
return {};
}
return this->EvaluateWithLanguage(parameters, eval, content, dagChecker,
@@ -3068,11 +3063,11 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
cmGeneratorExpressionDAGChecker* dagChecker) const override
{
if (!eval->HeadTarget) {
std::ostringstream e;
e << "$<" << this->CompilerLanguage
<< "_COMPILER_VERSION> may only be used with binary targets. It "
"may not be used with add_custom_command or add_custom_target.";
reportError(eval, content->GetOriginalExpression(), e.str());
reportError(eval, content->GetOriginalExpression(),
cmStrCat("$<", this->CompilerLanguage,
"_COMPILER_VERSION> may only be used with binary "
"targets. It may not be used with "
"add_custom_command or add_custom_target."));
return {};
}
return this->EvaluateWithLanguage(parameters, eval, content, dagChecker,
@@ -3132,11 +3127,12 @@ struct CompilerFrontendVariantNode : public cmGeneratorExpressionNode
cmGeneratorExpressionDAGChecker* dagChecker) const override
{
if (!eval->HeadTarget) {
std::ostringstream e;
e << "$<" << this->CompilerLanguage
<< "_COMPILER_FRONTEND_VARIANT> may only be used with binary targets. "
" It may not be used with add_custom_command or add_custom_target.";
reportError(eval, content->GetOriginalExpression(), e.str());
reportError(
eval, content->GetOriginalExpression(),
cmStrCat("$<", this->CompilerLanguage,
"_COMPILER_FRONTEND_VARIANT> may only be used with binary "
"targets. It may not be used with add_custom_command or "
"add_custom_target."));
return {};
}
return this->EvaluateWithLanguage(parameters, eval, content, dagChecker,
@@ -3329,14 +3325,15 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
}
// for backwards compat invalid config names are only errors as
// the first parameter
std::ostringstream e;
/* clang-format off */
e << "Warning evaluating generator expression:\n"
<< " " << content->GetOriginalExpression() << "\n"
<< "The config name of \"" << param << "\" is invalid";
/* clang-format on */
eval->Context.LG->GetCMakeInstance()->IssueMessage(
MessageType::WARNING, e.str(), eval->Backtrace);
MessageType::WARNING,
cmStrCat("Warning evaluating generator expression:\n"
" ",
content->GetOriginalExpression(),
"\n"
"The config name of \"",
param, "\" is invalid"),
eval->Backtrace);
}
firstParam = false;
}
@@ -4659,9 +4656,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
target = lg->FindGeneratorTargetToUse(targetName);
if (!target) {
std::ostringstream e;
e << "Target \"" << targetName << "\" not found.";
reportError(eval, content->GetOriginalExpression(), e.str());
reportError(eval, content->GetOriginalExpression(),
cmStrCat("Target \"", targetName, "\" not found."));
return std::string();
}
eval->AllTargets.insert(target);
@@ -4910,9 +4906,8 @@ static const struct targetIntermediateDirNode
target = lg->FindGeneratorTargetToUse(targetName);
if (!target) {
std::ostringstream e;
e << "Target \"" << targetName << "\" not found.";
reportError(eval, content->GetOriginalExpression(), e.str());
reportError(eval, content->GetOriginalExpression(),
cmStrCat("Target \"", targetName, "\" not found."));
return std::string();
}
eval->AllTargets.insert(target);
@@ -4971,10 +4966,9 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
cmGeneratorTarget* gt =
eval->Context.LG->FindGeneratorTargetToUse(tgtName);
if (!gt) {
std::ostringstream e;
e << "Objects of target \"" << tgtName
<< "\" referenced but no such target exists.";
reportError(eval, content->GetOriginalExpression(), e.str());
reportError(eval, content->GetOriginalExpression(),
cmStrCat("Objects of target \"", tgtName,
"\" referenced but no such target exists."));
return std::string();
}
cm::TargetType type = gt->GetType();
@@ -4983,11 +4977,11 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
type != cm::TargetType::SHARED_LIBRARY &&
type != cm::TargetType::MODULE_LIBRARY &&
type != cm::TargetType::OBJECT_LIBRARY) {
std::ostringstream e;
e << "Objects of target \"" << tgtName
<< "\" referenced but is not one of the allowed target types "
<< "(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT).";
reportError(eval, content->GetOriginalExpression(), e.str());
reportError(
eval, content->GetOriginalExpression(),
cmStrCat("Objects of target \"", tgtName,
"\" referenced but is not one of the allowed target types "
"(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT)."));
return std::string();
}
cmGlobalGenerator const* gg = eval->Context.LG->GetGlobalGenerator();
@@ -5100,21 +5094,20 @@ struct TargetRuntimeDllsBaseNode : public cmGeneratorExpressionNode
cmGeneratorTarget* gt =
eval->Context.LG->FindGeneratorTargetToUse(tgtName);
if (!gt) {
std::ostringstream e;
e << "Objects of target \"" << tgtName
<< "\" referenced but no such target exists.";
reportError(eval, content->GetOriginalExpression(), e.str());
reportError(eval, content->GetOriginalExpression(),
cmStrCat("Objects of target \"", tgtName,
"\" referenced but no such target exists."));
return std::vector<std::string>();
}
cm::TargetType type = gt->GetType();
if (type != cm::TargetType::EXECUTABLE &&
type != cm::TargetType::SHARED_LIBRARY &&
type != cm::TargetType::MODULE_LIBRARY) {
std::ostringstream e;
e << "Objects of target \"" << tgtName
<< "\" referenced but is not one of the allowed target types "
<< "(EXECUTABLE, SHARED, MODULE).";
reportError(eval, content->GetOriginalExpression(), e.str());
reportError(
eval, content->GetOriginalExpression(),
cmStrCat("Objects of target \"", tgtName,
"\" referenced but is not one of the allowed target types "
"(EXECUTABLE, SHARED, MODULE)."));
return std::vector<std::string>();
}
@@ -6640,12 +6633,10 @@ void reportError(cm::GenEx::Evaluation* eval, std::string const& expr,
return;
}
std::ostringstream e;
/* clang-format off */
e << "Error evaluating generator expression:\n"
<< " " << expr << "\n"
<< result;
/* clang-format on */
eval->Context.LG->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
e.str(), eval->Backtrace);
eval->Context.LG->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Error evaluating generator expression:\n"
" ",
expr, '\n', result),
eval->Backtrace);
}
+5 -8
View File
@@ -4,7 +4,6 @@
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <utility>
@@ -524,14 +523,12 @@ void cmGeneratorFileSet::EvaluateFileEntry(
}
}
if (baseDir.empty()) {
std::ostringstream e;
e << "File:\n " << file
<< "\nmust be in one of the file set's base directories:";
for (auto const& dir : dirs) {
e << "\n " << dir;
}
context.LG->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR, e.str(), cge->GetBacktrace());
MessageType::FATAL_ERROR,
cmStrCat("File:\n ", file,
"\nmust be in one of the file set's base directories:",
cmWrap("\n ", dirs, "", "")),
cge->GetBacktrace());
return;
}
+28 -34
View File
@@ -8,7 +8,7 @@
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <ostream>
#include <string>
#include <unordered_set>
#include <utility>
@@ -206,10 +206,9 @@ std::string cmGeneratorTarget::GetExportName() const
if (cmNonempty(exportName)) {
if (!cmGeneratorExpression::IsValidTargetName(*exportName)) {
std::ostringstream e;
e << "EXPORT_NAME property \"" << *exportName << "\" for \""
<< this->GetName() << "\": is not valid.";
cmSystemTools::Error(e.str());
cmSystemTools::Error(cmStrCat("EXPORT_NAME property \"", *exportName,
"\" for \"", this->GetName(),
"\": is not valid."));
return "";
}
return *exportName;
@@ -1431,19 +1430,16 @@ bool cmGeneratorTarget::NeedRelinkBeforeInstall(
bool is_ninja = this->LocalGenerator->GetGlobalGenerator()->IsNinja();
if (have_rpath && is_ninja) {
std::ostringstream w;
/* clang-format off */
w <<
"The install of the " << this->GetName() << " target requires changing "
"an RPATH from the build tree, but this is not supported with the Ninja "
"generator unless on an ELF-based or XCOFF-based platform. "
"The CMAKE_BUILD_WITH_INSTALL_RPATH variable may be set to avoid this "
"relinking step."
;
/* clang-format on */
cmake* cm = this->LocalGenerator->GetCMakeInstance();
cm->IssueMessage(MessageType::FATAL_ERROR, w.str(), this->GetBacktrace());
cm->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("The install of the ", this->GetName(),
" target requires changing an RPATH from the build tree, but "
"this is not supported with the Ninja generator unless on an "
"ELF-based or XCOFF-based platform. The "
"CMAKE_BUILD_WITH_INSTALL_RPATH variable may be set to avoid "
"this relinking step."),
this->GetBacktrace());
}
return have_rpath;
@@ -1580,19 +1576,16 @@ bool cmGeneratorTarget::DetermineHasMacOSXRpathInstallNameDir(
}
if (!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG")) {
std::ostringstream w;
w << "Attempting to use ";
if (macosx_rpath) {
w << "MACOSX_RPATH";
} else {
w << "@rpath";
}
w << " without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being set.";
w << " This could be because you are using a Mac OS X version";
w << " less than 10.5 or because CMake's platform configuration is";
w << " corrupt.";
cmake* cm = this->LocalGenerator->GetCMakeInstance();
cm->IssueMessage(MessageType::FATAL_ERROR, w.str(), this->GetBacktrace());
cm->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Attempting to use ",
macosx_rpath ? "MACOSX_RPATH"_s : "@rpath"_s,
" without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being set."
" This could be because you are using a Mac OS X version"
" less than 10.5 or because CMake's platform configuration is"
" corrupt."),
this->GetBacktrace());
}
return true;
@@ -5240,11 +5233,12 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
}
if (lib != item) {
cmake* cm = this->LocalGenerator->GetCMakeInstance();
std::ostringstream e;
e << "Target \"" << this->GetName() << "\" links to item \"" << item
<< "\" which has leading or trailing whitespace. "
<< "This is now an error according to policy CMP0004.";
cm->IssueMessage(MessageType::FATAL_ERROR, e.str(), this->GetBacktrace());
cm->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Target \"", this->GetName(), "\" links to item \"", item,
"\" which has leading or trailing whitespace. "
"This is now an error according to policy CMP0004."),
this->GetBacktrace());
}
return lib;
}
@@ -13,7 +13,6 @@
#include <iterator>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
@@ -171,15 +170,14 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender,
std::string pname = cmSystemTools::HelpFileName(p);
std::string pfile = cmStrCat(pdir, pname, ".rst");
if (cmSystemTools::FileExists(pfile, true)) {
std::ostringstream e;
e << "Target \"" << dependee->GetName() << "\" has property \"" << p
<< "\" listed in its " << propName
<< " property. "
"This is not allowed. Only user-defined properties may appear "
"listed in the "
<< propName << " property.";
depender->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
e.str());
depender->GetLocalGenerator()->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Target \"", dependee->GetName(), "\" has property \"", p,
"\" listed in its ", propName,
" property. "
"This is not allowed. Only user-defined properties may "
"appear listed in the ",
propName, " property."));
return;
}
if (emitted.insert(p).second) {
@@ -315,15 +313,14 @@ void cmGeneratorTarget::CheckPropertyCompatibility(
std::string propsString = cmStrCat(
cmJoin(cmMakeRange(props).retreat(1), ", "), " and the ", props.back());
std::ostringstream e;
e << "Property \"" << prop << "\" appears in both the " << propsString
<< " property in the dependencies of target \"" << this->GetName()
<< "\". This is not allowed. A property may only require "
"compatibility "
"in a boolean interpretation, a numeric minimum, a numeric maximum "
"or a "
"string interpretation, but not a mixture.";
this->LocalGenerator->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->LocalGenerator->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Property \"", prop, "\" appears in both the ", propsString,
" property in the dependencies of target \"", this->GetName(),
"\". This is not allowed. A property may only require "
"compatibility in a boolean interpretation, a numeric "
"minimum, a numeric maximum or a string interpretation, but "
"not a mixture."));
}
}
@@ -634,15 +631,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
report += reportEntry;
report += compatibilityAgree(t, propContent != consistent.second);
if (!consistent.first) {
std::ostringstream e;
e << "Property " << p << " on target \"" << tgt->GetName()
<< "\" does\nnot match the "
"INTERFACE_"
<< p
<< " property requirement\nof "
"dependency \""
<< theTarget->GetName() << "\".\n";
cmSystemTools::Error(e.str());
cmSystemTools::Error(
cmStrCat("Property ", p, " on target \"", tgt->GetName(),
"\" does\nnot match the INTERFACE_", p,
" property requirement\nof dependency \"",
theTarget->GetName(), "\".\n"));
break;
}
propContent = consistent.second;
@@ -660,14 +653,13 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
report += reportEntry;
report += compatibilityAgree(t, propContent != consistent.second);
if (!consistent.first) {
std::ostringstream e;
e << "Property " << p << " on target \"" << tgt->GetName()
<< "\" is\nimplied to be " << defaultValue
<< " because it was used to determine the link libraries\n"
"already. The INTERFACE_"
<< p << " property on\ndependency \"" << theTarget->GetName()
<< "\" is in conflict.\n";
cmSystemTools::Error(e.str());
cmSystemTools::Error(
cmStrCat("Property ", p, " on target \"", tgt->GetName(),
"\" is\nimplied to be ", defaultValue,
" because it was used to determine the link libraries\n"
"already. The INTERFACE_",
p, " property on\ndependency \"", theTarget->GetName(),
"\" is in conflict.\n"));
break;
}
propContent = consistent.second;
@@ -684,11 +676,10 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
cmStrCat(std::move(report), reportEntry,
compatibilityAgree(t, propContent != consistent.second));
if (!consistent.first) {
std::ostringstream e;
e << "The INTERFACE_" << p << " property of \""
<< theTarget->GetName() << "\" does\nnot agree with the value of "
<< p << " already determined\nfor \"" << tgt->GetName() << "\".\n";
cmSystemTools::Error(e.str());
cmSystemTools::Error(cmStrCat(
"The INTERFACE_", p, " property of \"", theTarget->GetName(),
"\" does\nnot agree with the value of ", p,
" already determined\nfor \"", tgt->GetName(), "\".\n"));
break;
}
propContent = consistent.second;
+12 -11
View File
@@ -7,7 +7,6 @@
#include "cmConfigure.h"
#include <set>
#include <sstream>
#include <string>
#include <unordered_set>
#include <utility>
@@ -170,20 +169,22 @@ void processIncludeDirectories(cmGeneratorTarget const* tgt,
}
if (!cmSystemTools::FileIsFullPath(entryInclude)) {
std::ostringstream e;
MessageType messageType = MessageType::FATAL_ERROR;
if (!targetName.empty()) {
/* clang-format off */
e << "Target \"" << targetName << "\" contains relative "
"path in its INTERFACE_INCLUDE_DIRECTORIES:\n"
" \"" << entryInclude << "\"";
/* clang-format on */
tgt->GetLocalGenerator()->IssueMessage(
messageType,
cmStrCat("Target \"", targetName,
"\" contains relative path in its "
"INTERFACE_INCLUDE_DIRECTORIES:\n"
" \"",
entryInclude, '"'));
} else {
e << "Found relative path while evaluating include directories of "
"\""
<< tgt->GetName() << "\":\n \"" << entryInclude << "\"\n";
tgt->GetLocalGenerator()->IssueMessage(
messageType,
cmStrCat("Found relative path while evaluating include "
"directories of \"",
tgt->GetName(), "\":\n \"", entryInclude, "\"\n"));
}
tgt->GetLocalGenerator()->IssueMessage(messageType, e.str());
if (messageType == MessageType::FATAL_ERROR) {
return;
}
+21 -26
View File
@@ -9,7 +9,6 @@
#include <cstdio>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
@@ -176,17 +175,15 @@ public:
return "";
}
if (this->Preferred.size() > 1) {
std::ostringstream e;
e << "Target " << this->Target->GetName()
<< " contains multiple languages with the highest linker preference"
<< " (" << this->Preference << "):\n";
for (std::string const& li : this->Preferred) {
e << " " << li << "\n";
}
e << "Set the LINKER_LANGUAGE property for this target.";
cmake* cm = this->Target->GetLocalGenerator()->GetCMakeInstance();
cm->IssueMessage(MessageType::FATAL_ERROR, e.str(),
this->Target->GetBacktrace());
cm->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat(
"Target ", this->Target->GetName(),
" contains multiple languages with the highest linker preference (",
this->Preference, "):\n", cmWrap(" ", this->Preferred, "\n", ""),
"Set the LINKER_LANGUAGE property for this target."),
this->Target->GetBacktrace());
}
return *this->Preferred.begin();
}
@@ -270,12 +267,11 @@ void cmGeneratorTarget::ComputeLinkClosure(std::string const& config,
// linker language must not be changed between the two passes
if (this->LinkerLanguage != lc.LinkerLanguage) {
std::ostringstream e;
e << "Evaluation of $<LINK_LANGUAGE:...> or $<LINK_LAND_AND_ID:...> "
"changes\nthe linker language for target \""
<< this->GetName() << "\" (from '" << this->LinkerLanguage << "' to '"
<< lc.LinkerLanguage << "') which is invalid.";
cmSystemTools::Error(e.str());
cmSystemTools::Error(cmStrCat(
"Evaluation of $<LINK_LANGUAGE:...> or $<LINK_LAND_AND_ID:...> "
"changes\nthe linker language for target \"",
this->GetName(), "\" (from '", this->LinkerLanguage, "' to '",
lc.LinkerLanguage, "') which is invalid."));
}
}
}
@@ -1293,15 +1289,14 @@ cmLinkItem cmGeneratorTarget::ResolveLinkItem(
// Check deprecation, issue message with `bt` backtrace.
if (resolved.Target->IsDeprecated()) {
std::ostringstream w;
/* clang-format off */
w <<
"The library that is being linked to, " << resolved.Target->GetName() <<
", is marked as being deprecated by the owner. The message provided by "
"the developer is: \n" << resolved.Target->GetDeprecation() << "\n";
/* clang-format on */
this->LocalGenerator->IssueDiagnostic(cmDiagnostics::CMD_AUTHOR, w.str(),
bt);
this->LocalGenerator->IssueDiagnostic(
cmDiagnostics::CMD_AUTHOR,
cmStrCat("The library that is being linked to, ",
resolved.Target->GetName(),
", is marked as being deprecated by the owner. The message "
"provided by the developer is: \n",
resolved.Target->GetDeprecation(), '\n'),
bt);
}
// Skip targets that will not really be linked. This is probably a
+24 -20
View File
@@ -12,7 +12,6 @@
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <unordered_set>
#include <utility>
@@ -137,17 +136,19 @@ bool processSources(cmGeneratorTarget const* tgt, std::string const& config,
}
if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src)) {
std::ostringstream err;
if (!targetName.empty()) {
err << "Target \"" << targetName
<< "\" contains relative path in its INTERFACE_SOURCES:\n \""
<< src << "\"";
tgt->GetLocalGenerator()->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Target \"", targetName,
"\" contains relative path in its INTERFACE_SOURCES:\n "
"\"",
src, '"'));
} else {
err << "Found relative path while evaluating sources of \""
<< tgt->GetName() << "\":\n \"" << src << "\"\n";
tgt->GetLocalGenerator()->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Found relative path while evaluating sources of \"",
tgt->GetName(), "\":\n \"", src, "\"\n"));
}
tgt->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
err.str());
return contextDependent;
}
src = fullPath;
@@ -376,12 +377,12 @@ cmGeneratorTarget::KindedSources const& cmGeneratorTarget::GetKindedSources(
auto it = this->KindedSourcesMap.find(key);
if (it != this->KindedSourcesMap.end()) {
if (!it->second.Initialized) {
std::ostringstream e;
e << "The SOURCES of \"" << this->GetName()
<< "\" use a generator expression that depends on the "
"SOURCES themselves.";
this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR, e.str(), this->GetBacktrace());
MessageType::FATAL_ERROR,
cmStrCat("The SOURCES of \"", this->GetName(),
"\" use a generator expression that depends on the "
"SOURCES themselves."),
this->GetBacktrace());
static KindedSources empty;
return empty;
}
@@ -501,15 +502,18 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
}
if (!badObjLib.empty()) {
std::ostringstream e;
e << "OBJECT library \"" << this->GetName() << "\" contains:\n";
std::string e =
cmStrCat("OBJECT library \"", this->GetName(), "\" contains:\n");
for (cmSourceFile* i : badObjLib) {
e << " " << i->GetLocation().GetName() << "\n";
e = cmStrCat(std::move(e), " ", i->GetLocation().GetName(), '\n');
}
e << "but may contain only sources that compile, header files, and "
"other files that would not affect linking of a normal library.";
e =
cmStrCat(std::move(e),
"but may contain only sources that compile, header files, and "
"other files that would not affect linking of a normal "
"library.");
this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR, e.str(), this->GetBacktrace());
MessageType::FATAL_ERROR, e, this->GetBacktrace());
}
}
+92 -102
View File
@@ -188,16 +188,17 @@ bool cmGlobalGenerator::SetGeneratorInstance(std::string const& i,
return true;
}
std::ostringstream e;
/* clang-format off */
e <<
"Generator\n"
" " << this->GetName() << "\n"
"does not support instance specification, but instance\n"
" " << i << "\n"
"was specified.";
/* clang-format on */
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
mf->IssueMessage(MessageType::FATAL_ERROR,
cmStrCat("Generator\n"
" ",
this->GetName(),
"\n"
"does not support instance specification, but "
"instance\n"
" ",
i,
"\n"
"was specified."));
return false;
}
@@ -208,16 +209,17 @@ bool cmGlobalGenerator::SetGeneratorPlatform(std::string const& p,
return true;
}
std::ostringstream e;
/* clang-format off */
e <<
"Generator\n"
" " << this->GetName() << "\n"
"does not support platform specification, but platform\n"
" " << p << "\n"
"was specified.";
/* clang-format on */
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
mf->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Generator\n"
" ",
this->GetName(),
"\n"
"does not support platform specification, but platform\n"
" ",
p,
"\n"
"was specified."));
return false;
}
@@ -227,16 +229,17 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts, bool,
if (ts.empty()) {
return true;
}
std::ostringstream e;
/* clang-format off */
e <<
"Generator\n"
" " << this->GetName() << "\n"
"does not support toolset specification, but toolset\n"
" " << ts << "\n"
"was specified.";
/* clang-format on */
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
mf->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Generator\n"
" ",
this->GetName(),
"\n"
"does not support toolset specification, but toolset\n"
" ",
ts,
"\n"
"was specified."));
return false;
}
@@ -416,10 +419,10 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const
}
if (target->GetAllConfigSources().empty()) {
std::ostringstream e;
e << "No SOURCES given to target: " << target->GetName();
this->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR, e.str(), target->GetBacktrace());
MessageType::FATAL_ERROR,
cmStrCat("No SOURCES given to target: ", target->GetName()),
target->GetBacktrace());
failed = true;
}
}
@@ -529,12 +532,11 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
}
}
if (mf->GetDefinition("CMAKE_MAKE_PROGRAM").IsOff()) {
std::ostringstream err;
err << "CMake was unable to find a build program corresponding to \""
<< this->GetName()
<< "\". CMAKE_MAKE_PROGRAM is not set. You "
"probably need to select a different build tool.";
cmSystemTools::Error(err.str());
cmSystemTools::Error(
cmStrCat("CMake was unable to find a build program corresponding to \"",
this->GetName(),
"\". CMAKE_MAKE_PROGRAM is not set. You "
"probably need to select a different build tool."));
cmSystemTools::SetFatalErrorOccurred();
return false;
}
@@ -642,11 +644,10 @@ void cmGlobalGenerator::EnableLanguage(
std::set<std::string> cur_languages(languages.begin(), languages.end());
for (std::string const& li : cur_languages) {
if (!this->LanguagesInProgress.insert(li).second) {
std::ostringstream e;
e << "Language '" << li
<< "' is currently being enabled. "
"Recursive call not allowed.";
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
mf->IssueMessage(MessageType::FATAL_ERROR,
cmStrCat("Language '", li,
"' is currently being enabled. "
"Recursive call not allowed."));
cmSystemTools::SetFatalErrorOccurred();
return;
}
@@ -659,11 +660,10 @@ void cmGlobalGenerator::EnableLanguage(
this->SetLanguageEnabled("NONE", mf);
} else {
if (!cm::contains(this->LanguagesReadyForTryCompile, lang)) {
std::ostringstream e;
e << "The test project needs language " << lang
<< " which is not enabled.";
this->TryCompileOuterMakefile->IssueMessage(MessageType::FATAL_ERROR,
e.str());
this->TryCompileOuterMakefile->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("The test project needs language ", lang,
" which is not enabled."));
cmSystemTools::SetFatalErrorOccurred();
return;
}
@@ -1593,16 +1593,15 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const
}
// This generator does not support duplicate custom targets.
std::ostringstream e;
// clang-format off
e << "This project has enabled the ALLOW_DUPLICATE_CUSTOM_TARGETS "
"global property. "
"The \"" << this->GetName() << "\" generator does not support "
"duplicate custom targets. "
"Consider using a Makefiles generator or fix the project to not "
"use duplicate target names.";
// clang-format on
cmSystemTools::Error(e.str());
cmSystemTools::Error(
cmStrCat("This project has enabled the ALLOW_DUPLICATE_CUSTOM_TARGETS "
"global property. "
"The \"",
this->GetName(),
"\" generator does not support "
"duplicate custom targets. "
"Consider using a Makefiles generator or fix the project to not "
"use duplicate target names."));
return false;
}
@@ -1625,17 +1624,17 @@ bool cmGlobalGenerator::UnsupportedVariableIsDefined(std::string const& name,
bool supported) const
{
if (!supported && this->Makefiles.front()->GetDefinition(name)) {
std::ostringstream e;
/* clang-format off */
e <<
"Generator\n"
" " << this->GetName() << "\n"
"does not support variable\n"
" " << name << "\n"
"but it has been specified."
;
/* clang-format on */
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Generator\n"
" ",
this->GetName(),
"\n"
"does not support variable\n"
" ",
name,
"\n"
"but it has been specified."));
return true;
}
@@ -1967,36 +1966,26 @@ void cmGlobalGenerator::Generate()
this->CheckTargetLinkLibraries();
if (!this->CMP0068WarnTargets.empty()) {
std::ostringstream w;
/* clang-format off */
w <<
cmPolicies::GetPolicyWarning(cmPolicies::CMP0068) << "\n"
"For compatibility with older versions of CMake, the install_name "
"fields for the following targets are still affected by RPATH "
"settings:\n"
;
/* clang-format on */
for (std::string const& t : this->CMP0068WarnTargets) {
w << ' ' << t << '\n';
}
this->GetCMakeInstance()->IssueDiagnostic(cmDiagnostics::CMD_POLICY,
w.str());
this->GetCMakeInstance()->IssueDiagnostic(
cmDiagnostics::CMD_POLICY,
cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0068),
"\n"
"For compatibility with older versions of CMake, the "
"install_name "
"fields for the following targets are still affected by RPATH "
"settings:\n",
cmWrap(" ", this->CMP0068WarnTargets, "\n", "")));
}
if (!this->CMP0224WarnTests.empty()) {
std::ostringstream w;
/* clang-format off */
w <<
cmPolicies::GetPolicyWarning(cmPolicies::CMP0224) << "\n"
"For compatibility with older versions of CMake, the fixtures of the "
"following tests will use EACH_TEST_SEPARATELY mode:\n"
;
/* clang-format on */
for (std::string const& t : this->CMP0224WarnTests) {
w << ' ' << t << '\n';
}
this->GetCMakeInstance()->IssueDiagnostic(cmDiagnostics::CMD_POLICY,
w.str());
this->GetCMakeInstance()->IssueDiagnostic(
cmDiagnostics::CMD_POLICY,
cmStrCat(
cmPolicies::GetPolicyWarning(cmPolicies::CMP0224),
"\n"
"For compatibility with older versions of CMake, the fixtures of the "
"following tests will use EACH_TEST_SEPARATELY mode:\n",
cmWrap(" ", this->CMP0224WarnTests, "\n", "")));
}
}
@@ -2998,11 +2987,12 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator const* root,
// Check whether the genex expansion of the property agrees in all
// configurations.
if (trueCount > 0 && falseCount > 0) {
std::ostringstream e;
e << "The EXCLUDE_FROM_ALL property of target \"" << target->GetName()
<< "\" varies by configuration. This is not supported by the \""
<< root->GetGlobalGenerator()->GetName() << "\" generator.";
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
mf->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("The EXCLUDE_FROM_ALL property of target \"",
target->GetName(),
"\" varies by configuration. This is not supported by the \"",
root->GetGlobalGenerator()->GetName(), "\" generator."));
}
return trueCount;
}
+68 -73
View File
@@ -619,12 +619,11 @@ void cmGlobalNinjaGenerator::Generate()
// Check minimum Ninja version.
if (cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion,
RequiredNinjaVersion())) {
std::ostringstream msg;
msg << "The detected version of Ninja (" << this->NinjaVersion;
msg << ") is less than the version of Ninja required by CMake (";
msg << cmGlobalNinjaGenerator::RequiredNinjaVersion() << ").";
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
msg.str());
this->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("The detected version of Ninja (", this->NinjaVersion,
") is less than the version of Ninja required by CMake (",
cmGlobalNinjaGenerator::RequiredNinjaVersion(), ")."));
return;
}
this->InitOutputPathPrefix();
@@ -919,18 +918,17 @@ bool cmGlobalNinjaGenerator::CheckCxxModuleSupport(CxxModuleSupportQuery query)
!this->CMakeInstance->GetIsInTryCompile() &&
query == CxxModuleSupportQuery::Expected;
if (diagnose) {
std::ostringstream e;
/* clang-format off */
e <<
"The Ninja generator does not support C++20 modules "
"using Ninja version \n"
" " << this->NinjaVersion << "\n"
"due to lack of required features. "
"Ninja " << RequiredNinjaVersionForDyndepsCxx() <<
" or higher is required."
;
/* clang-format on */
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("The Ninja generator does not support C++20 modules "
"using Ninja version \n"
" ",
this->NinjaVersion,
"\n"
"due to lack of required features. "
"Ninja ",
RequiredNinjaVersionForDyndepsCxx(),
" or higher is required."));
cmSystemTools::SetFatalErrorOccurred();
}
return false;
@@ -942,17 +940,17 @@ bool cmGlobalNinjaGenerator::CheckFortran(cmMakefile* mf) const
return true;
}
std::ostringstream e;
/* clang-format off */
e <<
"The Ninja generator does not support Fortran using Ninja version\n"
" " << this->NinjaVersion << "\n"
"due to lack of required features. "
"Ninja " << RequiredNinjaVersionForDyndepsFortran() <<
" or higher is required."
;
/* clang-format on */
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
mf->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("The Ninja generator does not support Fortran using Ninja "
"version\n"
" ",
this->NinjaVersion,
"\n"
"due to lack of required features. "
"Ninja ",
RequiredNinjaVersionForDyndepsFortran(),
" or higher is required."));
cmSystemTools::SetFatalErrorOccurred();
return false;
}
@@ -963,17 +961,16 @@ bool cmGlobalNinjaGenerator::CheckISPC(cmMakefile* mf) const
return true;
}
std::ostringstream e;
/* clang-format off */
e <<
"The Ninja generator does not support ISPC using Ninja version\n"
" " << this->NinjaVersion << "\n"
"due to lack of required features. "
"Ninja " << RequiredNinjaVersionForMultipleOutputs() <<
" or higher is required."
;
/* clang-format on */
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
mf->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("The Ninja generator does not support ISPC using Ninja version\n"
" ",
this->NinjaVersion,
"\n"
"due to lack of required features. "
"Ninja ",
RequiredNinjaVersionForMultipleOutputs(),
" or higher is required."));
cmSystemTools::SetFatalErrorOccurred();
return false;
}
@@ -2019,19 +2016,21 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
reBuild.ExplicitDeps.push_back(verifyStampFile);
} else if (!this->SupportsManifestRestat() &&
cm->DoWriteGlobVerifyTarget()) {
std::ostringstream msg;
msg << "The detected version of Ninja:\n"
<< " " << this->NinjaVersion << "\n"
<< "is less than the version of Ninja required by CMake for adding "
"restat dependencies to the build.ninja manifest regeneration "
"target:\n"
<< " "
<< cmGlobalNinjaGenerator::RequiredNinjaVersionForManifestRestat()
<< "\n";
msg << "Any pre-check scripts, such as those generated for file(GLOB "
"CONFIGURE_DEPENDS), will not be run by Ninja.";
this->GetCMakeInstance()->IssueDiagnostic(cmDiagnostics::CMD_AUTHOR,
msg.str());
this->GetCMakeInstance()->IssueDiagnostic(
cmDiagnostics::CMD_AUTHOR,
cmStrCat(
"The detected version of Ninja:\n"
" ",
this->NinjaVersion,
"\n"
"is less than the version of Ninja required by CMake for adding "
"restat dependencies to the build.ninja manifest regeneration "
"target:\n"
" ",
cmGlobalNinjaGenerator::RequiredNinjaVersionForManifestRestat(),
"\n"
"Any pre-check scripts, such as those generated for file(GLOB "
"CONFIGURE_DEPENDS), will not be run by Ninja."));
}
std::sort(reBuild.ImplicitDeps.begin(), reBuild.ImplicitDeps.end());
@@ -3502,12 +3501,12 @@ bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables()
this->DefaultFileConfig = configsList.front();
}
if (!configs.count(this->DefaultFileConfig)) {
std::ostringstream msg;
msg << "The configuration specified by "
<< "CMAKE_DEFAULT_BUILD_TYPE (" << this->DefaultFileConfig
<< ") is not present in CMAKE_CONFIGURATION_TYPES";
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
msg.str());
this->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("The configuration specified by "
"CMAKE_DEFAULT_BUILD_TYPE (",
this->DefaultFileConfig,
") is not present in CMAKE_CONFIGURATION_TYPES"));
return false;
}
@@ -3515,11 +3514,9 @@ bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables()
"CMAKE_CROSS_CONFIGS") };
auto crossConfigs = ListSubsetWithAll(configs, configs, crossConfigsList);
if (!crossConfigs) {
std::ostringstream msg;
msg << "CMAKE_CROSS_CONFIGS is not a subset of "
<< "CMAKE_CONFIGURATION_TYPES";
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
msg.str());
this->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
"CMAKE_CROSS_CONFIGS is not a subset of CMAKE_CONFIGURATION_TYPES");
return false;
}
this->CrossConfigs = *crossConfigs;
@@ -3532,11 +3529,10 @@ bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables()
if (!defaultConfigsString.empty() &&
defaultConfigsString != this->DefaultFileConfig &&
(this->DefaultFileConfig.empty() || this->CrossConfigs.empty())) {
std::ostringstream msg;
msg << "CMAKE_DEFAULT_CONFIGS cannot be used without "
<< "CMAKE_DEFAULT_BUILD_TYPE or CMAKE_CROSS_CONFIGS";
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
msg.str());
this->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
"CMAKE_DEFAULT_CONFIGS cannot be used without "
"CMAKE_DEFAULT_BUILD_TYPE or CMAKE_CROSS_CONFIGS");
return false;
}
@@ -3546,10 +3542,9 @@ bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables()
ListSubsetWithAll(this->GetCrossConfigs(this->DefaultFileConfig),
this->CrossConfigs, defaultConfigsList);
if (!defaultConfigs) {
std::ostringstream msg;
msg << "CMAKE_DEFAULT_CONFIGS is not a subset of CMAKE_CROSS_CONFIGS";
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
msg.str());
this->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
"CMAKE_DEFAULT_CONFIGS is not a subset of CMAKE_CROSS_CONFIGS");
return false;
}
this->DefaultConfigs = *defaultConfigs;
+8 -15
View File
@@ -795,26 +795,19 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
{
// TODO: Convert the total progress count to a make variable.
std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
// # in target
progCmd << lg.ConvertToOutputFormat(progress.Dir,
cmOutputConverter::SHELL);
//
std::set<cmGeneratorTarget const*> emitted;
progCmd << " "
<< this->CountProgressMarksInTarget(gtarget.get(), emitted);
commands.push_back(progCmd.str());
commands.push_back(cmStrCat(
"$(CMAKE_COMMAND) -E cmake_progress_start ",
lg.ConvertToOutputFormat(progress.Dir, cmOutputConverter::SHELL),
' ', this->CountProgressMarksInTarget(gtarget.get(), emitted)));
}
std::string tmp = "CMakeFiles/Makefile2";
commands.push_back(lg.GetRecursiveMakeCall(tmp, localName));
{
std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
progCmd << lg.ConvertToOutputFormat(progress.Dir,
cmOutputConverter::SHELL);
progCmd << " 0";
commands.push_back(progCmd.str());
commands.push_back(cmStrCat(
"$(CMAKE_COMMAND) -E cmake_progress_start ",
lg.ConvertToOutputFormat(progress.Dir, cmOutputConverter::SHELL),
" 0"));
}
depends.clear();
if (regenerate) {
+33 -33
View File
@@ -121,47 +121,47 @@ bool cmGlobalVisualStudio8Generator::ParseGeneratorPlatform(
for (; fi != fields.end(); ++fi) {
std::string::size_type pos = fi->find('=');
if (pos == fi->npos) {
std::ostringstream e;
/* clang-format off */
e <<
"Generator\n"
" " << this->GetName() << "\n"
"given platform specification\n"
" " << p << "\n"
"that contains a field after the first ',' with no '='."
;
/* clang-format on */
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
mf->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Generator\n"
" ",
this->GetName(),
"\n"
"given platform specification\n"
" ",
p,
"\n"
"that contains a field after the first ',' with no '='."));
return false;
}
std::string const key = fi->substr(0, pos);
std::string const value = fi->substr(pos + 1);
if (!handled.insert(key).second) {
std::ostringstream e;
/* clang-format off */
e <<
"Generator\n"
" " << this->GetName() << "\n"
"given platform specification\n"
" " << p << "\n"
"that contains duplicate field key '" << key << "'."
;
/* clang-format on */
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
mf->IssueMessage(MessageType::FATAL_ERROR,
cmStrCat("Generator\n"
" ",
this->GetName(),
"\n"
"given platform specification\n"
" ",
p,
"\n"
"that contains duplicate field key '",
key, "'."));
return false;
}
if (!this->ProcessGeneratorPlatformField(key, value)) {
std::ostringstream e;
/* clang-format off */
e <<
"Generator\n"
" " << this->GetName() << "\n"
"given platform specification\n"
" " << p << "\n"
"that contains invalid field '" << *fi << "'."
;
/* clang-format on */
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
mf->IssueMessage(MessageType::FATAL_ERROR,
cmStrCat("Generator\n"
" ",
this->GetName(),
"\n"
"given platform specification\n"
" ",
p,
"\n"
"that contains invalid field '",
*fi, "'."));
return false;
}
}
+5 -4
View File
@@ -220,10 +220,11 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
int res;
if (!cmSystemTools::FileTimeCompare(src, dst, &res) || res > 0) {
if (!cmSystemTools::CopyFileAlways(src, dst)) {
std::ostringstream oss;
oss << "Could not copy from: " << src << std::endl
<< " to: " << dst << std::endl;
cmSystemTools::Message(oss.str(), "Warning");
cmSystemTools::Message(cmStrCat("Could not copy from: ", src,
"\n"
" to: ",
dst, '\n'),
"Warning");
}
}
+13 -15
View File
@@ -1754,20 +1754,19 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget(
this->CreateString("2147483647"));
copyFilesBuildPhase->AddAttribute("dstSubfolderSpec",
this->CreateString("6"));
std::ostringstream ostr;
std::string ostr;
if (gtgt->IsFrameworkOnApple()) {
// dstPath in frameworks is relative to Versions/<version>
ostr << keySources.first;
ostr = keySources.first;
} else if (keySources.first != "MacOS"_s) {
if (gtgt->Target->GetMakefile()->PlatformIsAppleEmbedded()) {
ostr << keySources.first;
ostr = keySources.first;
} else {
// dstPath in bundles is relative to Contents/MacOS
ostr << "../" << keySources.first;
ostr = cmStrCat("../", keySources.first);
}
}
copyFilesBuildPhase->AddAttribute("dstPath",
this->CreateString(ostr.str()));
copyFilesBuildPhase->AddAttribute("dstPath", this->CreateString(ostr));
copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
this->CreateString("0"));
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
@@ -2491,9 +2490,8 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
makefileStream << "\\\n\t" << ConvertToMakefilePath(output);
}
} else {
std::ostringstream str;
str << "_buildpart_" << count++;
tname[&ccg.GetCC()] = cmStrCat(target->GetName(), str.str());
tname[&ccg.GetCC()] =
cmStrCat(target->GetName(), "_buildpart_", count++);
makefileStream << "\\\n\t" << tname[&ccg.GetCC()];
}
}
@@ -3300,26 +3298,26 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// MACHO_CURRENT_VERSION or VERSION -> current_version
gtgt->GetTargetVersionFallback("MACHO_CURRENT_VERSION", "VERSION", major,
minor, patch);
std::ostringstream v;
std::string v;
// Xcode always wants at least 1.0.0 or nothing
if (!(major == 0 && minor == 0 && patch == 0)) {
v << major << '.' << minor << '.' << patch;
v = cmStrCat(major, '.', minor, '.', patch);
}
buildSettings->AddAttribute("DYLIB_CURRENT_VERSION",
this->CreateString(v.str()));
this->CreateString(v));
// MACHO_COMPATIBILITY_VERSION or SOVERSION -> compatibility_version
gtgt->GetTargetVersionFallback("MACHO_COMPATIBILITY_VERSION", "SOVERSION",
major, minor, patch);
std::ostringstream vso;
std::string vso;
// Xcode always wants at least 1.0.0 or nothing
if (!(major == 0 && minor == 0 && patch == 0)) {
vso << major << '.' << minor << '.' << patch;
vso = cmStrCat(major, '.', minor, '.', patch);
}
buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
this->CreateString(vso.str()));
this->CreateString(vso));
}
// Precompile Headers
+20 -16
View File
@@ -762,15 +762,17 @@ void cmInstallTargetGenerator::AddChrpathPatchRule(
ss >> darwin_major_version;
if (!ss.fail() && darwin_major_version <= 9 &&
(!oldRuntimeDirs.empty() || !newRuntimeDirs.empty())) {
std::ostringstream msg;
msg
<< "WARNING: Target \"" << this->Target->GetName()
<< "\" has runtime paths which cannot be changed during install. "
<< "To change runtime paths, OS X version 10.6 or newer is required. "
<< "Therefore, runtime paths will not be changed when installing. "
<< "CMAKE_BUILD_WITH_INSTALL_RPATH may be used to work around"
" this limitation.";
mf->IssueMessage(MessageType::WARNING, msg.str());
mf->IssueMessage(
MessageType::WARNING,
cmStrCat("WARNING: Target \"", this->Target->GetName(),
"\" has runtime paths which cannot be changed during "
"install. "
"To change runtime paths, OS X version 10.6 or newer is "
"required. "
"Therefore, runtime paths will not be changed when "
"installing. "
"CMAKE_BUILD_WITH_INSTALL_RPATH may be used to work around"
" this limitation."));
} else {
// To be consistent with older versions, runpath changes must be ordered,
// deleted first, then added, *and* the same path must only appear once.
@@ -979,12 +981,14 @@ void cmInstallTargetGenerator::IssueCMP0095Warning(
if (potentially_affected) {
cmake const* const cm =
this->Target->GetGlobalGenerator()->GetCMakeInstance();
std::ostringstream w;
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0095) << "\n";
w << "RPATH entries for target '" << this->Target->GetName() << "' "
<< "will not be escaped in the intermediary "
<< "cmake_install.cmake script.";
cm->IssueDiagnostic(cmDiagnostics::CMD_POLICY, w.str(),
this->GetBacktrace());
cm->IssueDiagnostic(
cmDiagnostics::CMD_POLICY,
cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0095),
"\n"
"RPATH entries for target '",
this->Target->GetName(),
"' will not be escaped in the intermediary "
"cmake_install.cmake script."),
this->GetBacktrace());
}
}
+82 -82
View File
@@ -281,18 +281,18 @@ void cmLocalGenerator::ComputeObjectMaxPath()
if (pmax >= 128) {
this->ObjectPathMax = pmax;
} else {
std::ostringstream w;
w << "CMAKE_OBJECT_PATH_MAX is set to " << pmax
<< ", which is less than the minimum of 128. "
"The value will be ignored.";
this->IssueDiagnostic(cmDiagnostics::CMD_AUTHOR, w.str());
this->IssueDiagnostic(
cmDiagnostics::CMD_AUTHOR,
cmStrCat("CMAKE_OBJECT_PATH_MAX is set to ", pmax,
", which is less than the minimum of 128. "
"The value will be ignored."));
}
} else {
std::ostringstream w;
w << "CMAKE_OBJECT_PATH_MAX is set to \"" << *plen
<< "\", which fails to parse as a positive integer. "
"The value will be ignored.";
this->IssueDiagnostic(cmDiagnostics::CMD_AUTHOR, w.str());
this->IssueDiagnostic(
cmDiagnostics::CMD_AUTHOR,
cmStrCat("CMAKE_OBJECT_PATH_MAX is set to \"", *plen,
"\", which fails to parse as a positive integer. "
"The value will be ignored."));
}
}
this->ObjectMaxPathViolations.clear();
@@ -1177,20 +1177,21 @@ void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags,
continue;
}
if (standardResolver.IsLaterStandard(it.first, *standard, it.second)) {
std::ostringstream e;
e << "The COMPILE_FEATURES property of target \"" << target->GetName()
<< "\" was evaluated when computing the link "
"implementation, and the \""
<< it.first << "_STANDARD\" was \"" << it.second
<< "\" for that computation. Computing the "
"COMPILE_FEATURES based on the link implementation resulted in a "
"higher \""
<< it.first << "_STANDARD\" \"" << *standard
<< "\". "
"This is not permitted. The COMPILE_FEATURES may not both depend "
"on "
"and be depended on by the link implementation.\n";
this->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("The COMPILE_FEATURES property of target \"",
target->GetName(),
"\" was evaluated when computing the link "
"implementation, and the \"",
it.first, "_STANDARD\" was \"", it.second,
"\" for that computation. Computing the "
"COMPILE_FEATURES based on the link implementation resulted "
"in a higher \"",
it.first, "_STANDARD\" \"", *standard,
"\". "
"This is not permitted. The COMPILE_FEATURES may not both "
"depend on "
"and be depended on by the link implementation.\n"));
return;
}
}
@@ -2550,12 +2551,11 @@ static void AddVisibilityCompileOption(std::string& flags,
}
if ((*prop != "hidden") && (*prop != "default") && (*prop != "protected") &&
(*prop != "internal")) {
std::ostringstream e;
e << "Target " << target->GetName() << " uses unsupported value \""
<< *prop << "\" for " << flagDefine << "."
<< " The supported values are: default, hidden, protected, and "
"internal.";
cmSystemTools::Error(e.str());
cmSystemTools::Error(
cmStrCat("Target ", target->GetName(), " uses unsupported value \"",
*prop, "\" for ", flagDefine,
". The supported values are: default, hidden, protected, and "
"internal."));
return;
}
std::string option = *opt + *prop;
@@ -3015,11 +3015,11 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
std::string err;
pchHeader_sf->ResolveFullPath(&err);
if (!err.empty()) {
std::ostringstream msg;
msg << "Unable to resolve full path of PCH-header '" << pchHeader
<< "' assigned to target " << target->GetName()
<< ", although its path is supposed to be known!";
this->IssueMessage(MessageType::FATAL_ERROR, msg.str());
this->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Unable to resolve full path of PCH-header '",
pchHeader, "' assigned to target ", target->GetName(),
", although its path is supposed to be known!"));
}
target->AddSource(pchHeader);
}
@@ -4020,13 +4020,12 @@ void cmLocalGenerator::AppendIncludeDirectories(
for (std::string const& include : includes_vec) {
if (!cmSystemTools::FileIsFullPath(include)) {
std::ostringstream e;
e << "Found relative path while evaluating include directories of "
"\""
<< sourceFile.GetLocation().GetName() << "\":\n \"" << include
<< "\"\n";
this->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Found relative path while evaluating include directories of "
"\"",
sourceFile.GetLocation().GetName(), "\":\n \"", include,
"\"\n"));
return;
}
@@ -4486,20 +4485,25 @@ std::string& cmLocalGenerator::CreateSafeUniqueObjectFileName(
this->ObjectPathMax)) {
// Warn if this is the first time the path has been seen.
if (this->ObjectMaxPathViolations.insert(dir_max).second) {
std::ostringstream m;
/* clang-format off */
m << "The object file directory\n"
<< " " << dir_max << "\n"
<< "has " << dir_max.size() << " characters. "
<< "The maximum full path to an object file is "
<< this->ObjectPathMax << " characters "
<< "(see CMAKE_OBJECT_PATH_MAX). "
<< "Object file\n"
<< " " << ssin << "\n"
<< "cannot be safely placed under this directory. "
<< "The build may not work correctly.";
/* clang-format on */
this->IssueMessage(MessageType::WARNING, m.str());
this->IssueMessage(
MessageType::WARNING,
cmStrCat("The object file directory\n"
" ",
dir_max,
"\n"
"has ",
dir_max.size(),
" characters. "
"The maximum full path to an object file is ",
this->ObjectPathMax,
" characters "
"(see CMAKE_OBJECT_PATH_MAX). "
"Object file\n"
" ",
ssin,
"\n"
"cannot be safely placed under this directory. "
"The build may not work correctly."));
}
}
@@ -4990,30 +4994,28 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const
std::string::size_type pos = define.find_first_of("(=");
if (pos != std::string::npos) {
if (define[pos] == '(') {
std::ostringstream e;
/* clang-format off */
e << "WARNING: Function-style preprocessor definitions may not be "
"passed on the compiler command line because many compilers "
"do not support it.\n"
"CMake is dropping a preprocessor definition: " << define << "\n"
"Consider defining the macro in a (configured) header file.\n";
/* clang-format on */
cmSystemTools::Message(e.str());
cmSystemTools::Message(cmStrCat(
"WARNING: Function-style preprocessor definitions may not be "
"passed on the compiler command line because many compilers "
"do not support it.\n"
"CMake is dropping a preprocessor definition: ",
define,
"\n"
"Consider defining the macro in a (configured) header file.\n"));
return false;
}
}
// Many compilers do not support # in the value so we disable it.
if (define.find_first_of('#') != std::string::npos) {
std::ostringstream e;
/* clang-format off */
e << "WARNING: Preprocessor definitions containing '#' may not be "
"passed on the compiler command line because many compilers "
"do not support it.\n"
"CMake is dropping a preprocessor definition: " << define << "\n"
"Consider defining the macro in a (configured) header file.\n";
/* clang-format on */
cmSystemTools::Message(e.str());
cmSystemTools::Message(cmStrCat(
"WARNING: Preprocessor definitions containing '#' may not be "
"passed on the compiler command line because many compilers "
"do not support it.\n"
"CMake is dropping a preprocessor definition: ",
define,
"\n"
"Consider defining the macro in a (configured) header file.\n"));
return false;
}
@@ -5043,10 +5045,9 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
}
}
if (!cmSystemTools::FileExists(inFile, true)) {
std::ostringstream e;
e << "Target " << target->GetName() << " Info.plist template \"" << inFile
<< "\" could not be found.";
cmSystemTools::Error(e.str());
cmSystemTools::Error(cmStrCat("Target ", target->GetName(),
" Info.plist template \"", inFile,
"\" could not be found."));
return;
}
@@ -5082,10 +5083,9 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(
}
}
if (!cmSystemTools::FileExists(inFile, true)) {
std::ostringstream e;
e << "Target " << target->GetName() << " Info.plist template \"" << inFile
<< "\" could not be found.";
cmSystemTools::Error(e.str());
cmSystemTools::Error(cmStrCat("Target ", target->GetName(),
" Info.plist template \"", inFile,
"\" could not be found."));
return;
}
@@ -3,7 +3,6 @@
#include "cmMakefileExecutableTargetGenerator.h"
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
@@ -575,15 +574,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
std::string targetVersionMajor;
std::string targetVersionMinor;
{
std::ostringstream majorStream;
std::ostringstream minorStream;
int major;
int minor;
this->GeneratorTarget->GetTargetVersion(major, minor);
majorStream << major;
minorStream << minor;
targetVersionMajor = majorStream.str();
targetVersionMinor = minorStream.str();
targetVersionMajor = std::to_string(major);
targetVersionMinor = std::to_string(minor);
}
vars.TargetVersionMajor = targetVersionMajor.c_str();
vars.TargetVersionMinor = targetVersionMinor.c_str();
+2 -7
View File
@@ -4,7 +4,6 @@
#include <cstddef>
#include <set>
#include <sstream>
#include <utility>
#include <vector>
@@ -786,15 +785,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
std::string targetVersionMajor;
std::string targetVersionMinor;
{
std::ostringstream majorStream;
std::ostringstream minorStream;
int major;
int minor;
this->GeneratorTarget->GetTargetVersion(major, minor);
majorStream << major;
minorStream << minor;
targetVersionMajor = majorStream.str();
targetVersionMinor = minorStream.str();
targetVersionMajor = std::to_string(major);
targetVersionMinor = std::to_string(minor);
}
vars.TargetVersionMajor = targetVersionMajor.c_str();
vars.TargetVersionMinor = targetVersionMinor.c_str();
+7 -8
View File
@@ -626,11 +626,11 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
if (this->ObjectFiles.find(obj) == this->ObjectFiles.end()) {
this->ObjectFiles.insert(obj);
} else {
std::ostringstream err;
err << "Warning: Source file \"" << source.GetFullPath()
<< "\" is listed multiple times for target \""
<< this->GeneratorTarget->GetName() << "\".";
cmSystemTools::Message(err.str(), "Warning");
cmSystemTools::Message(
cmStrCat("Warning: Source file \"", source.GetFullPath(),
"\" is listed multiple times for target \"",
this->GeneratorTarget->GetName(), "\"."),
"Warning");
return;
}
@@ -1847,9 +1847,8 @@ void cmMakefileTargetGenerator::MakeEchoProgress(
{
progress.Dir =
cmStrCat(this->LocalGenerator->GetBinaryDirectory(), "/CMakeFiles");
std::ostringstream progressArg;
progressArg << "$(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")";
progress.Arg = progressArg.str();
progress.Arg =
cmStrCat("$(CMAKE_PROGRESS_", this->NumberOfProgressActions, ')');
}
void cmMakefileTargetGenerator::WriteObjectsVariable(
+2 -7
View File
@@ -3,7 +3,6 @@
#include "cmSetPropertyCommand.h"
#include <set>
#include <sstream>
#include <unordered_set>
#include <cm/optional>
@@ -925,12 +924,8 @@ bool HandleTestMode(cmExecutionStatus& status, std::set<std::string>& names,
// Names that are still left were not found.
if (!names.empty()) {
std::ostringstream e;
e << "given TEST names that do not exist:\n";
for (std::string const& name : names) {
e << " " << name << "\n";
}
status.SetError(e.str());
status.SetError(cmStrCat("given TEST names that do not exist:\n",
cmWrap(" ", names, "\n", "")));
return false;
}
return true;
+40 -61
View File
@@ -6,7 +6,6 @@
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <sstream>
#include <stdexcept>
#include <unordered_map>
#include <utility>
@@ -149,19 +148,17 @@ struct StandardLevelComputer
cmValue opt = target->Target->GetMakefile()->GetDefinition(option_flag);
if (!opt) {
std::ostringstream e;
e << "Target \"" << target->GetName()
<< "\" requires the language "
"dialect \""
<< this->Language << *standardProp << "\" "
<< (ext ? "(with compiler extensions)" : "")
<< ". But the current compiler \""
<< makefile->GetSafeDefinition(
cmStrCat("CMAKE_", this->Language, "_COMPILER_ID"))
<< "\" does not support this, or "
"CMake does not know the flags to enable it.";
makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
makefile->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Target \"", target->GetName(),
"\" requires the language dialect \"", this->Language,
*standardProp, "\" ",
ext ? "(with compiler extensions)" : "",
". But the current compiler \"",
makefile->GetSafeDefinition(
cmStrCat("CMAKE_", this->Language, "_COMPILER_ID")),
"\" does not support this, or "
"CMake does not know the flags to enable it."));
}
return option_flag;
}
@@ -607,19 +604,18 @@ bool cmStandardLevelResolver::CheckCompileFeaturesAvailable(
cmList availableFeatures{ features };
if (!cm::contains(availableFeatures, feature)) {
std::ostringstream e;
e << "The compiler feature \"" << feature << "\" is not known to " << lang
<< " compiler\n\""
<< this->Makefile->GetSafeDefinition(
cmStrCat("CMAKE_", lang, "_COMPILER_ID"))
<< "\"\nversion "
<< this->Makefile->GetSafeDefinition(
cmStrCat("CMAKE_", lang, "_COMPILER_VERSION"))
<< '.';
std::string e = cmStrCat("The compiler feature \"", feature,
"\" is not known to ", lang, " compiler\n\"",
this->Makefile->GetSafeDefinition(
cmStrCat("CMAKE_", lang, "_COMPILER_ID")),
"\"\nversion ",
this->Makefile->GetSafeDefinition(
cmStrCat("CMAKE_", lang, "_COMPILER_VERSION")),
'.');
if (error) {
*error = e.str();
*error = std::move(e);
} else {
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e);
}
return false;
}
@@ -661,20 +657,13 @@ bool cmStandardLevelResolver::CompileFeatureKnown(
lang = "HIP";
return true;
}
std::ostringstream e;
std::string e =
cmStrCat(error ? "specified" : "Specified", " unknown feature \"", feature,
"\" for target \"", targetName, "\".");
if (error) {
e << "specified";
*error = std::move(e);
} else {
e << "Specified";
}
e << " unknown feature \"" << feature
<< "\" for "
"target \""
<< targetName << "\".";
if (error) {
*error = e.str();
} else {
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e);
}
return false;
}
@@ -704,17 +693,12 @@ cmValue cmStandardLevelResolver::CompileFeaturesAvailable(
std::string const& lang, std::string* error) const
{
if (!this->Makefile->GetGlobalGenerator()->GetLanguageEnabled(lang)) {
std::ostringstream e;
std::string e = cmStrCat(error ? "cannot"_s : "Cannot"_s,
" use features from non-enabled language ", lang);
if (error) {
e << "cannot";
*error = std::move(e);
} else {
e << "Cannot";
}
e << " use features from non-enabled language " << lang;
if (error) {
*error = e.str();
} else {
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e);
}
return nullptr;
}
@@ -723,23 +707,18 @@ cmValue cmStandardLevelResolver::CompileFeaturesAvailable(
cmStrCat("CMAKE_", lang, "_COMPILE_FEATURES"));
if (!cmNonempty(featuresKnown)) {
std::ostringstream e;
std::string e = cmStrCat(error ? "no"_s : "No"_s, " known features for ",
lang, " compiler\n\"",
this->Makefile->GetSafeDefinition(
cmStrCat("CMAKE_", lang, "_COMPILER_ID")),
"\"\nversion ",
this->Makefile->GetSafeDefinition(
cmStrCat("CMAKE_", lang, "_COMPILER_VERSION")),
'.');
if (error) {
e << "no";
*error = std::move(e);
} else {
e << "No";
}
e << " known features for " << lang << " compiler\n\""
<< this->Makefile->GetSafeDefinition(
cmStrCat("CMAKE_", lang, "_COMPILER_ID"))
<< "\"\nversion "
<< this->Makefile->GetSafeDefinition(
cmStrCat("CMAKE_", lang, "_COMPILER_VERSION"))
<< '.';
if (error) {
*error = e.str();
} else {
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e);
}
return nullptr;
}
+19 -19
View File
@@ -86,7 +86,6 @@
#include <iostream>
#include <memory>
#include <random>
#include <sstream>
#include <utility>
#include <vector>
@@ -3580,15 +3579,16 @@ static cm::optional<bool> ChangeRPathELF(std::string const& file,
return true;
}
if (emsg2) {
std::ostringstream e;
/* clang-format off */
e << "The current " << se_name << " is:\n"
" " << inRPath << "\n"
"which does not contain:\n"
" " << oldRPath << "\n"
"as was expected.";
/* clang-format on */
*emsg2 = e.str();
*emsg2 = cmStrCat("The current ", se_name,
" is:\n"
" ",
inRPath,
"\n"
"which does not contain:\n"
" ",
oldRPath,
"\n"
"as was expected.");
}
return false;
}
@@ -3667,15 +3667,15 @@ static cm::optional<bool> ChangeRPathXCOFF(std::string const& file,
return true;
}
if (emsg) {
std::ostringstream e;
/* clang-format off */
e << "The current RPATH is:\n"
" " << libPath << "\n"
"which does not contain:\n"
" " << oldRPath << "\n"
"as was expected.";
/* clang-format on */
*emsg = e.str();
*emsg = cmStrCat("The current RPATH is:\n"
" ",
libPath,
"\n"
"which does not contain:\n"
" ",
oldRPath,
"\n"
"as was expected.");
}
return false;
}
+19 -19
View File
@@ -2284,10 +2284,11 @@ void cmTarget::SetProperty(std::string const& prop, cmValue value)
if (prop == propIMPORTED_GLOBAL) {
if (!value.IsOn()) {
std::ostringstream e;
e << "IMPORTED_GLOBAL property can't be set to FALSE on targets (\""
<< this->impl->Name << "\")\n";
this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->impl->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("IMPORTED_GLOBAL property can't be set to FALSE on targets "
"(\"",
this->impl->Name, "\")\n"));
return;
}
/* no need to change anything if value does not change */
@@ -2686,16 +2687,15 @@ void CheckINTERFACE_LINK_LIBRARIES(std::string const& value,
static cmsys::RegularExpression keys("(^|;)(debug|optimized|general)(;|$)");
if (keys.find(value)) {
// Report an error.
std::ostringstream e;
e << "Property INTERFACE_LINK_LIBRARIES may not contain link-type "
"keyword \""
<< keys.match(2)
<< "\". The INTERFACE_LINK_LIBRARIES "
"property may contain configuration-sensitive generator-expressions "
"which may be used to specify per-configuration rules.";
context->IssueMessage(MessageType::FATAL_ERROR, e.str());
context->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Property INTERFACE_LINK_LIBRARIES may not contain link-type "
"keyword \"",
keys.match(2),
"\". The INTERFACE_LINK_LIBRARIES "
"property may contain configuration-sensitive "
"generator-expressions "
"which may be used to specify per-configuration rules."));
}
}
@@ -2708,11 +2708,11 @@ void CheckIMPORTED_GLOBAL(cmTarget const* target, cmMakefile* context)
return target == importTarget.get();
});
if (it == targets.end()) {
std::ostringstream e;
e << "Attempt to promote imported target \"" << target->GetName()
<< "\" to global scope (by setting IMPORTED_GLOBAL) "
"which is not built in this directory.";
context->IssueMessage(MessageType::FATAL_ERROR, e.str());
context->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Attempt to promote imported target \"", target->GetName(),
"\" to global scope (by setting IMPORTED_GLOBAL) "
"which is not built in this directory."));
}
}
}
+11 -17
View File
@@ -903,14 +903,11 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
// make sure custom commands are executed before build (if necessary)
{
Elem e1(e0, "PropertyGroup");
std::ostringstream oss;
oss << "\n";
for (std::string const& i : this->CSharpCustomCommandNames) {
oss << " " << i << ";\n";
}
oss << " "
"$(BuildDependsOn)\n";
e1.Element("BuildDependsOn", oss.str());
e1.Element(
"BuildDependsOn",
cmStrCat('\n',
cmWrap(" ", this->CSharpCustomCommandNames, ";\n", ""),
" $(BuildDependsOn)\n"));
}
}
}
@@ -4460,13 +4457,13 @@ void cmVisualStudio10TargetGenerator::WriteManifestOptions(
if (!manifest_srcs.empty() || dpiAware) {
Elem e2(e1, "Manifest");
if (!manifest_srcs.empty()) {
std::ostringstream oss;
std::string oss;
for (cmSourceFile const* mi : manifest_srcs) {
std::string m = this->ConvertPath(mi->GetFullPath(), false);
ConvertToWindowsSlash(m);
oss << m << ";";
oss = cmStrCat(std::move(oss), std::move(m), ';');
}
e2.Element("AdditionalManifestFiles", oss.str());
e2.Element("AdditionalManifestFiles", oss);
}
if (dpiAware) {
if (*dpiAware == "PerMonitor"_s) {
@@ -4991,14 +4988,11 @@ void cmVisualStudio10TargetGenerator::WriteMidlOptions(
// on the CMake side?
std::vector<std::string> const includes =
this->GetIncludes(configName, "MIDL");
std::ostringstream oss;
for (std::string const& i : includes) {
oss << i << ";";
}
oss << "%(AdditionalIncludeDirectories)";
std::string const oss =
cmStrCat(cmWrap("", includes, ";", ""), "%(AdditionalIncludeDirectories)");
Elem e2(e1, "Midl");
e2.Element("AdditionalIncludeDirectories", oss.str());
e2.Element("AdditionalIncludeDirectories", oss);
e2.Element("OutputDirectory", "$(ProjectDir)/$(IntDir)");
e2.Element("HeaderFileName", "%(Filename).h");
e2.Element("TypeLibraryName", "%(Filename).tlb");