mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
cpack.cxx: Optimize calls to std::osteam::operator<<
This commit is contained in:
@@ -63,7 +63,7 @@ const cmDocumentationEntry cmDocumentationOptions[14] = {
|
|||||||
|
|
||||||
void cpackProgressCallback(const std::string& message, float /*unused*/)
|
void cpackProgressCallback(const std::string& message, float /*unused*/)
|
||||||
{
|
{
|
||||||
std::cout << "-- " << message << std::endl;
|
std::cout << "-- " << message << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<cmDocumentationEntry> makeGeneratorDocs(
|
std::vector<cmDocumentationEntry> makeGeneratorDocs(
|
||||||
@@ -113,8 +113,7 @@ int main(int argc, char const* const* argv)
|
|||||||
|
|
||||||
if (cmSystemTools::GetCurrentWorkingDirectory().empty()) {
|
if (cmSystemTools::GetCurrentWorkingDirectory().empty()) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Current working directory cannot be established."
|
"Current working directory cannot be established.\n");
|
||||||
<< std::endl);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,14 +140,14 @@ int main(int argc, char const* const* argv)
|
|||||||
auto const verboseLambda = [&log](const std::string&, cmake*,
|
auto const verboseLambda = [&log](const std::string&, cmake*,
|
||||||
cmMakefile*) -> bool {
|
cmMakefile*) -> bool {
|
||||||
log.SetVerbose(true);
|
log.SetVerbose(true);
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbose" << std::endl);
|
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbose\n");
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto const debugLambda = [&log](const std::string&, cmake*,
|
auto const debugLambda = [&log](const std::string&, cmake*,
|
||||||
cmMakefile*) -> bool {
|
cmMakefile*) -> bool {
|
||||||
log.SetDebug(true);
|
log.SetDebug(true);
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Debug" << std::endl);
|
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Debug\n");
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -206,24 +205,23 @@ int main(int argc, char const* const* argv)
|
|||||||
CommandArgument::setToValue(preset) },
|
CommandArgument::setToValue(preset) },
|
||||||
CommandArgument{ "--list-presets", CommandArgument::Values::Zero,
|
CommandArgument{ "--list-presets", CommandArgument::Values::Zero,
|
||||||
CommandArgument::setToTrue(listPresets) },
|
CommandArgument::setToTrue(listPresets) },
|
||||||
CommandArgument{
|
CommandArgument{ "-D", CommandArgument::Values::One,
|
||||||
"-D", CommandArgument::Values::One,
|
|
||||||
[&log, &definitions](const std::string& arg, cmake*,
|
[&log, &definitions](const std::string& arg, cmake*,
|
||||||
cmMakefile*) -> bool {
|
cmMakefile*) -> bool {
|
||||||
std::string value = arg;
|
std::string value = arg;
|
||||||
size_t pos = value.find_first_of('=');
|
size_t pos = value.find_first_of('=');
|
||||||
if (pos == std::string::npos) {
|
if (pos == std::string::npos) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(
|
||||||
"Please specify CPack definitions as: KEY=VALUE"
|
&log, cmCPackLog::LOG_ERROR,
|
||||||
<< std::endl);
|
"Please specify CPack definitions as: KEY=VALUE\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string key = value.substr(0, pos);
|
std::string key = value.substr(0, pos);
|
||||||
value.erase(0, pos + 1);
|
value.erase(0, pos + 1);
|
||||||
definitions[key] = value;
|
definitions[key] = value;
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_DEBUG,
|
cmCPack_Log(&log, cmCPackLog::LOG_DEBUG,
|
||||||
"Set CPack variable: " << key << " to \"" << value << "\""
|
"Set CPack variable: " << key << " to \""
|
||||||
<< std::endl);
|
<< value << "\"\n");
|
||||||
return true;
|
return true;
|
||||||
} },
|
} },
|
||||||
};
|
};
|
||||||
@@ -274,8 +272,7 @@ int main(int argc, char const* const* argv)
|
|||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Could not read presets from "
|
"Could not read presets from "
|
||||||
<< workingDirectory << ": "
|
<< workingDirectory << ": "
|
||||||
<< cmCMakePresetsGraph::ResultToString(result)
|
<< cmCMakePresetsGraph::ResultToString(result) << '\n');
|
||||||
<< std::endl);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +285,7 @@ int main(int argc, char const* const* argv)
|
|||||||
if (presetPair == presetsGraph.PackagePresets.end()) {
|
if (presetPair == presetsGraph.PackagePresets.end()) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"No such package preset in " << workingDirectory << ": \""
|
"No such package preset in " << workingDirectory << ": \""
|
||||||
<< preset << '"' << std::endl);
|
<< preset << "\"\n");
|
||||||
presetsGraph.PrintPackagePresetList(presetGeneratorsPresent);
|
presetsGraph.PrintPackagePresetList(presetGeneratorsPresent);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -296,8 +293,7 @@ int main(int argc, char const* const* argv)
|
|||||||
if (presetPair->second.Unexpanded.Hidden) {
|
if (presetPair->second.Unexpanded.Hidden) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Cannot use hidden package preset in "
|
"Cannot use hidden package preset in "
|
||||||
<< workingDirectory << ": \"" << preset << '"'
|
<< workingDirectory << ": \"" << preset << "\"\n");
|
||||||
<< std::endl);
|
|
||||||
presetsGraph.PrintPackagePresetList(presetGeneratorsPresent);
|
presetsGraph.PrintPackagePresetList(presetGeneratorsPresent);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -306,7 +302,7 @@ int main(int argc, char const* const* argv)
|
|||||||
if (!expandedPreset) {
|
if (!expandedPreset) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Could not evaluate package preset \""
|
"Could not evaluate package preset \""
|
||||||
<< preset << "\": Invalid macro expansion" << std::endl);
|
<< preset << "\": Invalid macro expansion\n");
|
||||||
presetsGraph.PrintPackagePresetList(presetGeneratorsPresent);
|
presetsGraph.PrintPackagePresetList(presetGeneratorsPresent);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -314,8 +310,7 @@ int main(int argc, char const* const* argv)
|
|||||||
if (!expandedPreset->ConditionResult) {
|
if (!expandedPreset->ConditionResult) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Cannot use disabled package preset in "
|
"Cannot use disabled package preset in "
|
||||||
<< workingDirectory << ": \"" << preset << '"'
|
<< workingDirectory << ": \"" << preset << "\"\n");
|
||||||
<< std::endl);
|
|
||||||
presetsGraph.PrintPackagePresetList(presetGeneratorsPresent);
|
presetsGraph.PrintPackagePresetList(presetGeneratorsPresent);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -332,7 +327,7 @@ int main(int argc, char const* const* argv)
|
|||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"No such configure preset in "
|
"No such configure preset in "
|
||||||
<< workingDirectory << ": \""
|
<< workingDirectory << ": \""
|
||||||
<< expandedPreset->ConfigurePreset << '"' << std::endl);
|
<< expandedPreset->ConfigurePreset << "\"\n");
|
||||||
presetsGraph.PrintConfigurePresetList();
|
presetsGraph.PrintConfigurePresetList();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -341,7 +336,7 @@ int main(int argc, char const* const* argv)
|
|||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Cannot use hidden configure preset in "
|
"Cannot use hidden configure preset in "
|
||||||
<< workingDirectory << ": \""
|
<< workingDirectory << ": \""
|
||||||
<< expandedPreset->ConfigurePreset << '"' << std::endl);
|
<< expandedPreset->ConfigurePreset << "\"\n");
|
||||||
presetsGraph.PrintConfigurePresetList();
|
presetsGraph.PrintConfigurePresetList();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -351,7 +346,7 @@ int main(int argc, char const* const* argv)
|
|||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Could not evaluate configure preset \""
|
"Could not evaluate configure preset \""
|
||||||
<< expandedPreset->ConfigurePreset
|
<< expandedPreset->ConfigurePreset
|
||||||
<< "\": Invalid macro expansion" << std::endl);
|
<< "\": Invalid macro expansion\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,7 +402,7 @@ int main(int argc, char const* const* argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
||||||
"Read CPack config file: " << cpackConfigFile << std::endl);
|
"Read CPack config file: " << cpackConfigFile << '\n');
|
||||||
|
|
||||||
bool cpackConfigFileSpecified = true;
|
bool cpackConfigFileSpecified = true;
|
||||||
if (cpackConfigFile.empty()) {
|
if (cpackConfigFile.empty()) {
|
||||||
@@ -435,7 +430,7 @@ int main(int argc, char const* const* argv)
|
|||||||
globalMF.GetModulesFile("CMakeDetermineSystem.cmake");
|
globalMF.GetModulesFile("CMakeDetermineSystem.cmake");
|
||||||
if (!globalMF.ReadListFile(systemFile)) {
|
if (!globalMF.ReadListFile(systemFile)) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Error reading CMakeDetermineSystem.cmake" << std::endl);
|
"Error reading CMakeDetermineSystem.cmake\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,8 +438,7 @@ int main(int argc, char const* const* argv)
|
|||||||
globalMF.GetModulesFile("CMakeSystemSpecificInformation.cmake");
|
globalMF.GetModulesFile("CMakeSystemSpecificInformation.cmake");
|
||||||
if (!globalMF.ReadListFile(systemFile)) {
|
if (!globalMF.ReadListFile(systemFile)) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Error reading CMakeSystemSpecificInformation.cmake"
|
"Error reading CMakeSystemSpecificInformation.cmake\n");
|
||||||
<< std::endl);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,17 +450,17 @@ int main(int argc, char const* const* argv)
|
|||||||
cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile);
|
cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile);
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
||||||
"Read CPack configuration file: " << cpackConfigFile
|
"Read CPack configuration file: " << cpackConfigFile
|
||||||
<< std::endl);
|
<< '\n');
|
||||||
if (!globalMF.ReadListFile(cpackConfigFile)) {
|
if (!globalMF.ReadListFile(cpackConfigFile)) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Problem reading CPack config file: \""
|
"Problem reading CPack config file: \"" << cpackConfigFile
|
||||||
<< cpackConfigFile << "\"" << std::endl);
|
<< "\"\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (cpackConfigFileSpecified) {
|
} else if (cpackConfigFileSpecified) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Cannot find CPack config file: \"" << cpackConfigFile
|
"Cannot find CPack config file: \"" << cpackConfigFile
|
||||||
<< "\"" << std::endl);
|
<< "\"\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,17 +509,17 @@ int main(int argc, char const* const* argv)
|
|||||||
cmValue genList = globalMF.GetDefinition("CPACK_GENERATOR");
|
cmValue genList = globalMF.GetDefinition("CPACK_GENERATOR");
|
||||||
if (!genList) {
|
if (!genList) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"CPack generator not specified" << std::endl);
|
"CPack generator not specified\n");
|
||||||
} else {
|
} else {
|
||||||
std::vector<std::string> generatorsVector = cmExpandedList(*genList);
|
std::vector<std::string> generatorsVector = cmExpandedList(*genList);
|
||||||
for (std::string const& gen : generatorsVector) {
|
for (std::string const& gen : generatorsVector) {
|
||||||
cmMakefile::ScopePushPop raii(&globalMF);
|
cmMakefile::ScopePushPop raii(&globalMF);
|
||||||
cmMakefile* mf = &globalMF;
|
cmMakefile* mf = &globalMF;
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
||||||
"Specified generator: " << gen << std::endl);
|
"Specified generator: " << gen << '\n');
|
||||||
if (!mf->GetDefinition("CPACK_PACKAGE_NAME")) {
|
if (!mf->GetDefinition("CPACK_PACKAGE_NAME")) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"CPack project name not specified" << std::endl);
|
"CPack project name not specified" << '\n');
|
||||||
parsed = false;
|
parsed = false;
|
||||||
}
|
}
|
||||||
if (parsed &&
|
if (parsed &&
|
||||||
@@ -534,13 +528,11 @@ int main(int argc, char const* const* argv)
|
|||||||
mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") &&
|
mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") &&
|
||||||
mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")))) {
|
mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")))) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"CPack project version not specified"
|
"CPack project version not specified\n"
|
||||||
<< std::endl
|
"Specify CPACK_PACKAGE_VERSION, or "
|
||||||
<< "Specify CPACK_PACKAGE_VERSION, or "
|
|
||||||
"CPACK_PACKAGE_VERSION_MAJOR, "
|
"CPACK_PACKAGE_VERSION_MAJOR, "
|
||||||
"CPACK_PACKAGE_VERSION_MINOR, and "
|
"CPACK_PACKAGE_VERSION_MINOR, and "
|
||||||
"CPACK_PACKAGE_VERSION_PATCH."
|
"CPACK_PACKAGE_VERSION_PATCH.\n");
|
||||||
<< std::endl);
|
|
||||||
parsed = false;
|
parsed = false;
|
||||||
}
|
}
|
||||||
if (parsed) {
|
if (parsed) {
|
||||||
@@ -551,8 +543,7 @@ int main(int argc, char const* const* argv)
|
|||||||
cpackGenerator->SetTraceExpand(cminst.GetTraceExpand());
|
cpackGenerator->SetTraceExpand(cminst.GetTraceExpand());
|
||||||
} else {
|
} else {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Could not create CPack generator: " << gen
|
"Could not create CPack generator: " << gen << '\n');
|
||||||
<< std::endl);
|
|
||||||
// Print out all the valid generators
|
// Print out all the valid generators
|
||||||
cmDocumentation generatorDocs;
|
cmDocumentation generatorDocs;
|
||||||
generatorDocs.SetSection("Generators",
|
generatorDocs.SetSection("Generators",
|
||||||
@@ -565,8 +556,7 @@ int main(int argc, char const* const* argv)
|
|||||||
|
|
||||||
if (parsed && !cpackGenerator->Initialize(gen, mf)) {
|
if (parsed && !cpackGenerator->Initialize(gen, mf)) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Cannot initialize the generator " << gen
|
"Cannot initialize the generator " << gen << '\n');
|
||||||
<< std::endl);
|
|
||||||
parsed = false;
|
parsed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,17 +569,16 @@ int main(int argc, char const* const* argv)
|
|||||||
"Please specify build tree of the project that uses CMake "
|
"Please specify build tree of the project that uses CMake "
|
||||||
"using CPACK_INSTALL_CMAKE_PROJECTS, specify "
|
"using CPACK_INSTALL_CMAKE_PROJECTS, specify "
|
||||||
"CPACK_INSTALL_COMMANDS, CPACK_INSTALL_SCRIPT, or "
|
"CPACK_INSTALL_COMMANDS, CPACK_INSTALL_SCRIPT, or "
|
||||||
"CPACK_INSTALLED_DIRECTORIES."
|
"CPACK_INSTALLED_DIRECTORIES.\n");
|
||||||
<< std::endl);
|
|
||||||
parsed = false;
|
parsed = false;
|
||||||
}
|
}
|
||||||
if (parsed) {
|
if (parsed) {
|
||||||
cmValue projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
|
cmValue projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
||||||
"Use generator: " << cpackGenerator->GetNameOfClass()
|
"Use generator: " << cpackGenerator->GetNameOfClass()
|
||||||
<< std::endl);
|
<< '\n');
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
||||||
"For project: " << *projName << std::endl);
|
"For project: " << *projName << '\n');
|
||||||
|
|
||||||
cmValue projVersion = mf->GetDefinition("CPACK_PACKAGE_VERSION");
|
cmValue projVersion = mf->GetDefinition("CPACK_PACKAGE_VERSION");
|
||||||
if (!projVersion) {
|
if (!projVersion) {
|
||||||
@@ -600,7 +589,7 @@ int main(int argc, char const* const* argv)
|
|||||||
cmValue projVersionPatch =
|
cmValue projVersionPatch =
|
||||||
mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
|
mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
ostr << *projVersionMajor << "." << *projVersionMinor << "."
|
ostr << *projVersionMajor << "." << *projVersionMinor << '.'
|
||||||
<< *projVersionPatch;
|
<< *projVersionPatch;
|
||||||
mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str());
|
mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str());
|
||||||
}
|
}
|
||||||
@@ -609,7 +598,7 @@ int main(int argc, char const* const* argv)
|
|||||||
if (!res) {
|
if (!res) {
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Error when generating package: " << *projName
|
"Error when generating package: " << *projName
|
||||||
<< std::endl);
|
<< '\n');
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user