summaryrefslogtreecommitdiffstats
path: root/Source/cmCoreTryCompile.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/cmCoreTryCompile.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/cmCoreTryCompile.cxx')
-rw-r--r--Source/cmCoreTryCompile.cxx6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 231c260..18dca91 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -307,9 +307,11 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
if (!fout)
{
std::ostringstream e;
+ /* clang-format off */
e << "Failed to open\n"
<< " " << outFileName << "\n"
<< cmSystemTools::GetLastSystemError();
+ /* clang-format on */
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return -1;
}
@@ -369,11 +371,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
"CMAKE_POLICY_WARNING_CMP0056"))
{
std::ostringstream w;
+ /* clang-format off */
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0056) << "\n"
"For compatibility with older versions of CMake, try_compile "
"is not honoring caller link flags (e.g. CMAKE_EXE_LINKER_FLAGS) "
"in the test project."
;
+ /* clang-format on */
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
}
case cmPolicies::OLD:
@@ -608,10 +612,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
copyFile))
{
std::ostringstream emsg;
+ /* clang-format off */
emsg << "Cannot copy output executable\n"
<< " '" << this->OutputFile << "'\n"
<< "to destination specified by COPY_FILE:\n"
<< " '" << copyFile << "'\n";
+ /* clang-format on */
if(!this->FindErrorMessage.empty())
{
emsg << this->FindErrorMessage.c_str();