summaryrefslogtreecommitdiffstats
path: root/Source/cmProjectCommand.cxx
diff options
context:
space:
mode:
authorKitware Robot <kwrobot@kitware.com>2016-05-16 14:34:04 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-16 20:05:19 (GMT)
commitd9fd2f5402eeaa345691313658e02b51038f570b (patch)
treedca71b9a7e267f4c6300da3eb770415381726785 /Source/cmProjectCommand.cxx
parent82df6deaafb36cbbfd450202bb20b320f637751a (diff)
downloadCMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
Diffstat (limited to 'Source/cmProjectCommand.cxx')
-rw-r--r--Source/cmProjectCommand.cxx192
1 files changed, 79 insertions, 113 deletions
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index 7123125..139303b 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -12,14 +12,13 @@
#include "cmProjectCommand.h"
// cmProjectCommand
-bool cmProjectCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(args.size() < 1 )
- {
+ if (args.size() < 1) {
this->SetError("PROJECT called with incorrect number of arguments");
return false;
- }
+ }
this->Makefile->SetProjectName(args[0]);
std::string bindir = args[0];
@@ -27,22 +26,20 @@ bool cmProjectCommand
std::string srcdir = args[0];
srcdir += "_SOURCE_DIR";
- this->Makefile->AddCacheDefinition
- (bindir,
- this->Makefile->GetCurrentBinaryDirectory(),
- "Value Computed by CMake", cmState::STATIC);
- this->Makefile->AddCacheDefinition
- (srcdir,
- this->Makefile->GetCurrentSourceDirectory(),
- "Value Computed by CMake", cmState::STATIC);
+ this->Makefile->AddCacheDefinition(
+ bindir, this->Makefile->GetCurrentBinaryDirectory(),
+ "Value Computed by CMake", cmState::STATIC);
+ this->Makefile->AddCacheDefinition(
+ srcdir, this->Makefile->GetCurrentSourceDirectory(),
+ "Value Computed by CMake", cmState::STATIC);
bindir = "PROJECT_BINARY_DIR";
srcdir = "PROJECT_SOURCE_DIR";
this->Makefile->AddDefinition(bindir,
- this->Makefile->GetCurrentBinaryDirectory());
+ this->Makefile->GetCurrentBinaryDirectory());
this->Makefile->AddDefinition(srcdir,
- this->Makefile->GetCurrentSourceDirectory());
+ this->Makefile->GetCurrentSourceDirectory());
this->Makefile->AddDefinition("PROJECT_NAME", args[0].c_str());
@@ -52,117 +49,100 @@ bool cmProjectCommand
// CMakeLists.txt file, then go with the last one, so that
// CMAKE_PROJECT_NAME will match PROJECT_NAME, and cmake --build
// will work.
- if(!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME")
- || (this->Makefile->IsRootMakefile()))
- {
+ if (!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME") ||
+ (this->Makefile->IsRootMakefile())) {
this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str());
- this->Makefile->AddCacheDefinition
- ("CMAKE_PROJECT_NAME",
- args[0].c_str(),
- "Value Computed by CMake", cmState::STATIC);
- }
+ this->Makefile->AddCacheDefinition("CMAKE_PROJECT_NAME", args[0].c_str(),
+ "Value Computed by CMake",
+ cmState::STATIC);
+ }
bool haveVersion = false;
bool haveLanguages = false;
std::string version;
std::vector<std::string> languages;
- enum Doing { DoingLanguages, DoingVersion };
+ enum Doing
+ {
+ DoingLanguages,
+ DoingVersion
+ };
Doing doing = DoingLanguages;
- for(size_t i = 1; i < args.size(); ++i)
- {
- if(args[i] == "LANGUAGES")
- {
- if(haveLanguages)
- {
- this->Makefile->IssueMessage
- (cmake::FATAL_ERROR, "LANGUAGES may be specified at most once.");
+ for (size_t i = 1; i < args.size(); ++i) {
+ if (args[i] == "LANGUAGES") {
+ if (haveLanguages) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR, "LANGUAGES may be specified at most once.");
cmSystemTools::SetFatalErrorOccured();
return true;
- }
+ }
haveLanguages = true;
doing = DoingLanguages;
- }
- else if (args[i] == "VERSION")
- {
- if(haveVersion)
- {
- this->Makefile->IssueMessage
- (cmake::FATAL_ERROR, "VERSION may be specified at most once.");
+ } else if (args[i] == "VERSION") {
+ if (haveVersion) {
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ "VERSION may be specified at most once.");
cmSystemTools::SetFatalErrorOccured();
return true;
- }
+ }
haveVersion = true;
doing = DoingVersion;
- }
- else if(doing == DoingVersion)
- {
+ } else if (doing == DoingVersion) {
doing = DoingLanguages;
version = args[i];
- }
- else // doing == DoingLanguages
- {
+ } else // doing == DoingLanguages
+ {
languages.push_back(args[i]);
- }
}
+ }
- if (haveVersion && !haveLanguages && !languages.empty())
- {
- this->Makefile->IssueMessage
- (cmake::FATAL_ERROR,
- "project with VERSION must use LANGUAGES before language names.");
+ if (haveVersion && !haveLanguages && !languages.empty()) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
+ "project with VERSION must use LANGUAGES before language names.");
cmSystemTools::SetFatalErrorOccured();
return true;
- }
- if (haveLanguages && languages.empty())
- {
+ }
+ if (haveLanguages && languages.empty()) {
languages.push_back("NONE");
- }
+ }
cmPolicies::PolicyStatus cmp0048 =
this->Makefile->GetPolicyStatus(cmPolicies::CMP0048);
- if (haveVersion)
- {
+ if (haveVersion) {
// Set project VERSION variables to given values
- if (cmp0048 == cmPolicies::OLD ||
- cmp0048 == cmPolicies::WARN)
- {
- this->Makefile->IssueMessage
- (cmake::FATAL_ERROR,
- "VERSION not allowed unless CMP0048 is set to NEW");
+ if (cmp0048 == cmPolicies::OLD || cmp0048 == cmPolicies::WARN) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
+ "VERSION not allowed unless CMP0048 is set to NEW");
cmSystemTools::SetFatalErrorOccured();
return true;
- }
+ }
- cmsys::RegularExpression
- vx("^([0-9]+(\\.[0-9]+(\\.[0-9]+(\\.[0-9]+)?)?)?)?$");
- if(!vx.find(version))
- {
+ cmsys::RegularExpression vx(
+ "^([0-9]+(\\.[0-9]+(\\.[0-9]+(\\.[0-9]+)?)?)?)?$");
+ if (!vx.find(version)) {
std::string e = "VERSION \"" + version + "\" format invalid.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e);
cmSystemTools::SetFatalErrorOccured();
return true;
- }
+ }
std::string vs;
const char* sep = "";
char vb[4][64];
- unsigned int v[4] = {0,0,0,0};
- int vc = sscanf(version.c_str(), "%u.%u.%u.%u",
- &v[0], &v[1], &v[2], &v[3]);
- for(int i=0; i < 4; ++i)
- {
- if(i < vc)
- {
+ unsigned int v[4] = { 0, 0, 0, 0 };
+ int vc =
+ sscanf(version.c_str(), "%u.%u.%u.%u", &v[0], &v[1], &v[2], &v[3]);
+ for (int i = 0; i < 4; ++i) {
+ if (i < vc) {
sprintf(vb[i], "%u", v[i]);
vs += sep;
vs += vb[i];
sep = ".";
- }
- else
- {
+ } else {
vb[i][0] = 0;
- }
}
+ }
std::string vv;
vv = args[0] + "_VERSION";
@@ -180,9 +160,7 @@ bool cmProjectCommand
vv = args[0] + "_VERSION_TWEAK";
this->Makefile->AddDefinition("PROJECT_VERSION_TWEAK", vb[3]);
this->Makefile->AddDefinition(vv, vb[3]);
- }
- else if(cmp0048 != cmPolicies::OLD)
- {
+ } else if (cmp0048 != cmPolicies::OLD) {
// Set project VERSION variables to empty
std::vector<std::string> vv;
vv.push_back("PROJECT_VERSION");
@@ -196,55 +174,43 @@ bool cmProjectCommand
vv.push_back(args[0] + "_VERSION_PATCH");
vv.push_back(args[0] + "_VERSION_TWEAK");
std::string vw;
- for(std::vector<std::string>::iterator i = vv.begin();
- i != vv.end(); ++i)
- {
+ for (std::vector<std::string>::iterator i = vv.begin(); i != vv.end();
+ ++i) {
const char* v = this->Makefile->GetDefinition(*i);
- if(v && *v)
- {
- if(cmp0048 == cmPolicies::WARN)
- {
+ if (v && *v) {
+ if (cmp0048 == cmPolicies::WARN) {
vw += "\n ";
vw += *i;
- }
- else
- {
+ } else {
this->Makefile->AddDefinition(*i, "");
- }
}
}
- if(!vw.empty())
- {
+ }
+ if (!vw.empty()) {
std::ostringstream w;
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0048)
<< "\nThe following variable(s) would be set to empty:" << vw;
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
- }
}
+ }
- if (languages.empty())
- {
+ if (languages.empty()) {
// if no language is specified do c and c++
languages.push_back("C");
languages.push_back("CXX");
- }
+ }
this->Makefile->EnableLanguage(languages, false);
std::string extraInclude = "CMAKE_PROJECT_" + args[0] + "_INCLUDE";
const char* include = this->Makefile->GetDefinition(extraInclude);
- if(include)
- {
- bool readit =
- this->Makefile->ReadDependentFile(include);
- if(!readit && !cmSystemTools::GetFatalErrorOccured())
- {
- std::string m =
- "could not find file:\n"
- " ";
+ if (include) {
+ bool readit = this->Makefile->ReadDependentFile(include);
+ if (!readit && !cmSystemTools::GetFatalErrorOccured()) {
+ std::string m = "could not find file:\n"
+ " ";
m += include;
this->SetError(m);
return false;
- }
}
+ }
return true;
}
-