summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2020-03-22 14:29:43 (GMT)
committerAlex Turbov <i.zaufi@gmail.com>2020-03-24 13:32:05 (GMT)
commit1e4b5c7d090fc77daa2aaede0bd57d476e3f45ed (patch)
tree0215a0628dc36e38956f2fea531916f71a5d093b /Source/cmLocalGenerator.cxx
parent7099db5dd48d36e5d39ab17219278d834c8a88a7 (diff)
downloadCMake-1e4b5c7d090fc77daa2aaede0bd57d476e3f45ed.zip
CMake-1e4b5c7d090fc77daa2aaede0bd57d476e3f45ed.tar.gz
CMake-1e4b5c7d090fc77daa2aaede0bd57d476e3f45ed.tar.bz2
Refactor: Avoid `std::endl` where it's not necessary (part 2)
The `std::endl` manipulator, except inserting `\n` character, also performs `os.flush()`, which may lead to undesired effects (like disk I/O in the middle of forming data strings). For the `std::stringstream` it also has no meaning. * replace multiple `operator<<` calls on a string literal w/ the only call and the only (bigger) string literal; * replace one character string literal used in `operator<<` w/ a char literal.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx53
1 files changed, 27 insertions, 26 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index a7799b6..0a23afb 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -288,21 +288,23 @@ void cmLocalGenerator::GenerateTestFiles()
cmGeneratedFileStream fout(file);
fout.SetCopyIfDifferent(true);
- fout << "# CMake generated Testfile for " << std::endl
- << "# Source directory: "
- << this->StateSnapshot.GetDirectory().GetCurrentSource() << std::endl
- << "# Build directory: "
- << this->StateSnapshot.GetDirectory().GetCurrentBinary() << std::endl
- << "# " << std::endl
- << "# This file includes the relevant testing commands "
- << "required for " << std::endl
- << "# testing this directory and lists subdirectories to "
- << "be tested as well." << std::endl;
+ fout << "# CMake generated Testfile for \n"
+ "# Source directory: "
+ << this->StateSnapshot.GetDirectory().GetCurrentSource()
+ << "\n"
+ "# Build directory: "
+ << this->StateSnapshot.GetDirectory().GetCurrentBinary()
+ << "\n"
+ "# \n"
+ "# This file includes the relevant testing commands "
+ "required for \n"
+ "# testing this directory and lists subdirectories to "
+ "be tested as well.\n";
const char* testIncludeFile =
this->Makefile->GetProperty("TEST_INCLUDE_FILE");
if (testIncludeFile) {
- fout << "include(\"" << testIncludeFile << "\")" << std::endl;
+ fout << "include(\"" << testIncludeFile << "\")\n";
}
const char* testIncludeFiles =
@@ -310,7 +312,7 @@ void cmLocalGenerator::GenerateTestFiles()
if (testIncludeFiles) {
std::vector<std::string> includesList = cmExpandedList(testIncludeFiles);
for (std::string const& i : includesList) {
- fout << "include(\"" << i << "\")" << std::endl;
+ fout << "include(\"" << i << "\")\n";
}
}
@@ -327,7 +329,7 @@ void cmLocalGenerator::GenerateTestFiles()
std::string outP = i.GetDirectory().GetCurrentBinary();
outP = this->MaybeConvertToRelativePath(parentBinDir, outP);
outP = cmOutputConverter::EscapeForCMake(outP);
- fout << "subdirs(" << outP << ")" << std::endl;
+ fout << "subdirs(" << outP << ")\n";
}
// Add directory labels property
@@ -346,7 +348,7 @@ void cmLocalGenerator::GenerateTestFiles()
if (directoryLabels) {
fout << cmOutputConverter::EscapeForCMake(directoryLabels);
}
- fout << ")" << std::endl;
+ fout << ")\n";
}
}
@@ -467,16 +469,17 @@ void cmLocalGenerator::GenerateInstallRules()
fout.SetCopyIfDifferent(true);
// Write the header.
+ /* clang-format off */
fout << "# Install script for directory: "
- << this->StateSnapshot.GetDirectory().GetCurrentSource() << std::endl
- << std::endl;
- fout << "# Set the install prefix" << std::endl
- << "if(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl
- << " set(CMAKE_INSTALL_PREFIX \"" << prefix << "\")" << std::endl
- << "endif()" << std::endl
+ << this->StateSnapshot.GetDirectory().GetCurrentSource()
+ << "\n\n"
+ "# Set the install prefix\n"
+ "if(NOT DEFINED CMAKE_INSTALL_PREFIX)\n"
+ " set(CMAKE_INSTALL_PREFIX \"" << prefix << "\")\n"
+ "endif()\n"
<< R"(string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX )"
- << "\"${CMAKE_INSTALL_PREFIX}\")" << std::endl
- << std::endl;
+ << "\"${CMAKE_INSTALL_PREFIX}\")\n\n";
+ /* clang-format on */
// Write support code for generating per-configuration install rules.
/* clang-format off */
@@ -591,8 +594,7 @@ void cmLocalGenerator::GenerateInstallRules()
if (!c.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
std::string odir = c.GetDirectory().GetCurrentBinary();
cmSystemTools::ConvertToUnixSlashes(odir);
- fout << " include(\"" << odir << "/cmake_install.cmake\")"
- << std::endl;
+ fout << " include(\"" << odir << "/cmake_install.cmake\")\n";
}
}
fout << "\n";
@@ -949,8 +951,7 @@ void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags,
<< "\". "
"This is not permitted. The COMPILE_FEATURES may not both depend "
"on "
- "and be depended on by the link implementation."
- << std::endl;
+ "and be depended on by the link implementation.\n";
this->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}