summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.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/cmLocalGenerator.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/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 6db18f7..18b3ef3 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -349,6 +349,7 @@ void cmLocalGenerator::GenerateInstallRules()
<< std::endl;
// Write support code for generating per-configuration install rules.
+ /* clang-format off */
fout <<
"# Set the install configuration name.\n"
"if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)\n"
@@ -362,8 +363,10 @@ void cmLocalGenerator::GenerateInstallRules()
"\\\"${CMAKE_INSTALL_CONFIG_NAME}\\\"\")\n"
"endif()\n"
"\n";
+ /* clang-format on */
// Write support code for dealing with component-specific installs.
+ /* clang-format off */
fout <<
"# Set the component getting installed.\n"
"if(NOT CMAKE_INSTALL_COMPONENT)\n"
@@ -375,17 +378,20 @@ void cmLocalGenerator::GenerateInstallRules()
" endif()\n"
"endif()\n"
"\n";
+ /* clang-format on */
// Copy user-specified install options to the install code.
if(const char* so_no_exe =
this->Makefile->GetDefinition("CMAKE_INSTALL_SO_NO_EXE"))
{
+ /* clang-format off */
fout <<
"# Install shared libraries without execute permission?\n"
"if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)\n"
" set(CMAKE_INSTALL_SO_NO_EXE \"" << so_no_exe << "\")\n"
"endif()\n"
"\n";
+ /* clang-format on */
}
// Ask each install generator to write its code.
@@ -426,6 +432,7 @@ void cmLocalGenerator::GenerateInstallRules()
// Record the install manifest.
if ( toplevel_install )
{
+ /* clang-format off */
fout <<
"if(CMAKE_INSTALL_COMPONENT)\n"
" set(CMAKE_INSTALL_MANIFEST \"install_manifest_"
@@ -438,6 +445,7 @@ void cmLocalGenerator::GenerateInstallRules()
" \"${CMAKE_INSTALL_MANIFEST_FILES}\")\n"
"file(WRITE \"" << homedir << "/${CMAKE_INSTALL_MANIFEST}\"\n"
" \"${CMAKE_INSTALL_MANIFEST_CONTENT}\")\n";
+ /* clang-format on */
}
}
@@ -1594,10 +1602,12 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
"CMAKE_POLICY_WARNING_CMP0065"))
{
std::ostringstream w;
+ /* clang-format off */
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0065) << "\n"
"For compatibility with older versions of CMake, "
"additional flags may be added to export symbols on all "
"executables regardless of thier ENABLE_EXPORTS property.";
+ /* clang-format on */
this->IssueMessage(cmake::AUTHOR_WARNING, w.str());
}
case cmPolicies::OLD:
@@ -2176,6 +2186,7 @@ void cmLocalGenerator
this->WarnCMP0063.insert(target).second)
{
std::ostringstream w;
+ /* clang-format off */
w <<
cmPolicies::GetPolicyWarning(cmPolicies::CMP0063) << "\n"
"Target \"" << target->GetName() << "\" of "
@@ -2183,6 +2194,7 @@ void cmLocalGenerator
"has the following visibility properties set for " << lang << ":\n" <<
warnCMP0063 <<
"For compatibility CMake is not honoring them for this target.";
+ /* clang-format on */
target->GetLocalGenerator()->GetCMakeInstance()
->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
target->GetBacktrace());
@@ -2764,6 +2776,7 @@ cmLocalGenerator
if(this->ObjectMaxPathViolations.insert(dir_max).second)
{
std::ostringstream m;
+ /* clang-format off */
m << "The object file directory\n"
<< " " << dir_max << "\n"
<< "has " << dir_max.size() << " characters. "
@@ -2774,6 +2787,7 @@ cmLocalGenerator
<< " " << ssin << "\n"
<< "cannot be safely placed under this directory. "
<< "The build may not work correctly.";
+ /* clang-format on */
this->IssueMessage(cmake::WARNING, m.str());
}
}
@@ -3034,11 +3048,13 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const
if (define[pos] == '(')
{
std::ostringstream e;
+ /* clang-format off */
e << "WARNING: Function-style preprocessor definitions may not be "
<< "passed on the compiler command line because many compilers "
<< "do not support it.\n"
<< "CMake is dropping a preprocessor definition: " << define << "\n"
<< "Consider defining the macro in a (configured) header file.\n";
+ /* clang-format on */
cmSystemTools::Message(e.str().c_str());
return false;
}
@@ -3048,11 +3064,13 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const
if(define.find_first_of("#") != define.npos)
{
std::ostringstream e;
+ /* clang-format off */
e << "WARNING: Preprocessor definitions containing '#' may not be "
<< "passed on the compiler command line because many compilers "
<< "do not support it.\n"
<< "CMake is dropping a preprocessor definition: " << define << "\n"
<< "Consider defining the macro in a (configured) header file.\n";
+ /* clang-format on */
cmSystemTools::Message(e.str().c_str());
return false;
}