summaryrefslogtreecommitdiffstats
path: root/Source/cmCacheManager.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-05-06 18:19:04 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-06 18:25:55 (GMT)
commit64b5520346c75ec479042a114390a0bf71909723 (patch)
treebea1373e84594ba036fe50eea3eab86375d63aa6 /Source/cmCacheManager.cxx
parent73601ff831faa80a188e5997ee048b6986b00a5c (diff)
downloadCMake-64b5520346c75ec479042a114390a0bf71909723.zip
CMake-64b5520346c75ec479042a114390a0bf71909723.tar.gz
CMake-64b5520346c75ec479042a114390a0bf71909723.tar.bz2
Isolate formatted streaming blocks with clang-format off/on
The clang-format tool can do a good job formatting most code, but well-organized streaming blocks are best left manually formatted. Find blocks of the form os << "...\n" "...\n" ; using the command $ git ls-files -z -- Source | egrep -v -z '^Source/kwsys/' | xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \ '<<[^\n]*\n(^ *("[^\n]*("|<<|;)$|;)\n){2,}' Find blocks of the form os << "...\n" << "...\n" << "...\n"; using the command $ git ls-files -z -- Source | egrep -v -z '^Source/kwsys/' | xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \ '<<[^\n]*\n(^ *<<[^\n]*(\\n"|<<|;)$\n){2,}' Surround such blocks with the pair /* clang-format off */ ... /* clang-format on */ in order to protect them from update by clang-format. Use the C-style `/*...*/` comments instead of C++-style `//...` comments in order to prevent them from ever being swallowed by re-formatting of surrounding comments.
Diffstat (limited to 'Source/cmCacheManager.cxx')
-rw-r--r--Source/cmCacheManager.cxx4
1 files changed, 4 insertions, 0 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index afa2ba7..4dcd613 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -318,11 +318,14 @@ bool cmCacheManager::SaveCache(const std::string& path)
"This is the directory where this CMakeCache.txt"
" was created", cmState::INTERNAL);
+ /* clang-format off */
fout << "# This is the CMakeCache file.\n"
<< "# For build in directory: " << currentcwd << "\n"
<< "# It was generated by CMake: "
<< cmSystemTools::GetCMakeCommand() << std::endl;
+ /* clang-format on */
+ /* clang-format off */
fout << "# You can edit this file to change values found and used by cmake."
<< std::endl
<< "# If you do not want to change any of the values, simply exit the "
@@ -335,6 +338,7 @@ bool cmCacheManager::SaveCache(const std::string& path)
<< "# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT "
"TYPE!." << std::endl
<< "# VALUE is the current value for the KEY.\n\n";
+ /* clang-format on */
fout << "########################\n";
fout << "# EXTERNAL cache entries\n";