diff options
author | Brad King <brad.king@kitware.com> | 2016-05-06 18:19:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-06 18:25:55 (GMT) |
commit | 64b5520346c75ec479042a114390a0bf71909723 (patch) | |
tree | bea1373e84594ba036fe50eea3eab86375d63aa6 /Source/cmGeneratorTarget.cxx | |
parent | 73601ff831faa80a188e5997ee048b6986b00a5c (diff) | |
download | CMake-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/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f115d83..0189d93 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2693,6 +2693,7 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt, break; } } + /* clang-format off */ e << "Imported target \"" << targetName << "\" includes " "non-existent path\n \"" << *li << "\"\nin its " "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" @@ -2702,6 +2703,7 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt, "successfully.\n" "* The installation package was faulty and references files it " "does not provide.\n"; + /* clang-format on */ tgt->GetLocalGenerator()->IssueMessage(messageType, e.str()); return; } @@ -2713,9 +2715,11 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt, cmake::MessageType messageType = cmake::FATAL_ERROR; if (!targetName.empty()) { + /* clang-format off */ e << "Target \"" << targetName << "\" contains relative " "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" " \"" << *li << "\""; + /* clang-format on */ } else { @@ -5198,6 +5202,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( && strcmp(newExplicitLibraries, explicitLibraries) != 0) { std::ostringstream w; + /* clang-format off */ w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" "Target \"" << this->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property which differs from its " << @@ -5207,6 +5212,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( " " << newExplicitLibraries << "\n" << linkIfaceProp << ":\n" " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; + /* clang-format on */ this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str()); this->PolicyWarnedCMP0022 = true; } @@ -5269,6 +5275,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( { newLibraries = "(empty)"; } std::ostringstream w; + /* clang-format off */ w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n" "Target \"" << this->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property. " @@ -5281,6 +5288,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( " " << newLibraries << "\n" "Link implementation:\n" " " << oldLibraries << "\n"; + /* clang-format on */ this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str()); this->PolicyWarnedCMP0022 = true; } @@ -5630,6 +5638,7 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles( sep = "\n "; } std::ostringstream e; + /* clang-format off */ e << "Target \"" << this->GetName() << "\" has source files which vary by " "configuration. This is not supported by the \"" @@ -5639,6 +5648,7 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles( " " << firstConfigFiles << "\n" "Config \"" << *it << "\":\n" " " << thisConfigFiles << "\n"; + /* clang-format on */ this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); return false; } |