diff options
author | Kitware Robot <kwrobot@kitware.com> | 2016-05-16 10:34:04 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-16 16:05:19 -0400 |
commit | d9fd2f5402eeaa345691313658e02b51038f570b (patch) | |
tree | dca71b9a7e267f4c6300da3eb770415381726785 /Source/cmAddCustomTargetCommand.cxx | |
parent | 82df6deaafb36cbbfd450202bb20b320f637751a (diff) | |
download | cmake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz |
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/cmAddCustomTargetCommand.cxx')
-rw-r--r-- | Source/cmAddCustomTargetCommand.cxx | 165 |
1 files changed, 62 insertions, 103 deletions
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 5bf752a19f..ac08cb2602 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -15,28 +15,25 @@ #include "cmGlobalGenerator.h" // cmAddCustomTargetCommand -bool cmAddCustomTargetCommand -::InitialPass(std::vector<std::string> const& args, - cmExecutionStatus&) +bool cmAddCustomTargetCommand::InitialPass( + std::vector<std::string> const& args, cmExecutionStatus&) { - if(args.size() < 1 ) - { + if (args.size() < 1) { this->SetError("called with incorrect number of arguments"); return false; - } + } std::string targetName = args[0]; // Check the target name. - if(targetName.find_first_of("/\\") != targetName.npos) - { + if (targetName.find_first_of("/\\") != targetName.npos) { std::ostringstream e; e << "called with invalid target name \"" << targetName << "\". Target names may not contain a slash. " << "Use ADD_CUSTOM_COMMAND to generate files."; this->SetError(e.str()); return false; - } + } // Accumulate one command line at a time. cmCustomCommandLine currentLine; @@ -54,7 +51,8 @@ bool cmAddCustomTargetCommand std::vector<std::string> sources; // Keep track of parser state. - enum tdoing { + enum tdoing + { doing_command, doing_depends, doing_byproducts, @@ -68,131 +66,100 @@ bool cmAddCustomTargetCommand // Look for the ALL option. bool excludeFromAll = true; unsigned int start = 1; - if(args.size() > 1) - { - if(args[1] == "ALL") - { + if (args.size() > 1) { + if (args[1] == "ALL") { excludeFromAll = false; start = 2; - } } + } // Parse the rest of the arguments. - for(unsigned int j = start; j < args.size(); ++j) - { + for (unsigned int j = start; j < args.size(); ++j) { std::string const& copy = args[j]; - if(copy == "DEPENDS") - { + if (copy == "DEPENDS") { doing = doing_depends; - } - else if(copy == "BYPRODUCTS") - { + } else if (copy == "BYPRODUCTS") { doing = doing_byproducts; - } - else if(copy == "WORKING_DIRECTORY") - { + } else if (copy == "WORKING_DIRECTORY") { doing = doing_working_directory; - } - else if(copy == "VERBATIM") - { + } else if (copy == "VERBATIM") { doing = doing_nothing; verbatim = true; - } - else if(copy == "USES_TERMINAL") - { + } else if (copy == "USES_TERMINAL") { doing = doing_nothing; uses_terminal = true; - } - else if (copy == "COMMENT") - { + } else if (copy == "COMMENT") { doing = doing_comment; - } - else if(copy == "COMMAND") - { + } else if (copy == "COMMAND") { doing = doing_command; // Save the current command before starting the next command. - if(!currentLine.empty()) - { + if (!currentLine.empty()) { commandLines.push_back(currentLine); currentLine.clear(); - } } - else if(copy == "SOURCES") - { + } else if (copy == "SOURCES") { doing = doing_source; - } - else - { - switch (doing) - { + } else { + switch (doing) { case doing_working_directory: working_directory = copy; break; case doing_command: currentLine.push_back(copy); break; - case doing_byproducts: - { + case doing_byproducts: { std::string filename; - if (!cmSystemTools::FileIsFullPath(copy.c_str())) - { + if (!cmSystemTools::FileIsFullPath(copy.c_str())) { filename = this->Makefile->GetCurrentBinaryDirectory(); filename += "/"; - } + } filename += copy; cmSystemTools::ConvertToUnixSlashes(filename); byproducts.push_back(filename); - } - break; - case doing_depends: - { + } break; + case doing_depends: { std::string dep = copy; cmSystemTools::ConvertToUnixSlashes(dep); depends.push_back(dep); - } + } break; + case doing_comment: + comment_buffer = copy; + comment = comment_buffer.c_str(); break; - case doing_comment: - comment_buffer = copy; - comment = comment_buffer.c_str(); - break; case doing_source: sources.push_back(copy); break; default: this->SetError("Wrong syntax. Unknown type of argument."); return false; - } } } + } std::string::size_type pos = targetName.find_first_of("#<>"); - if(pos != targetName.npos) - { + if (pos != targetName.npos) { std::ostringstream msg; msg << "called with target name containing a \"" << targetName[pos] << "\". This character is not allowed."; this->SetError(msg.str()); return false; - } + } // Some requirements on custom target names already exist // and have been checked at this point. // The following restrictions overlap but depend on policy CMP0037. bool nameOk = cmGeneratorExpression::IsValidTargetName(targetName) && !cmGlobalGenerator::IsReservedTarget(targetName); - if (nameOk) - { + if (nameOk) { nameOk = targetName.find(":") == std::string::npos; - } - if (!nameOk) - { + } + if (!nameOk) { cmake::MessageType messageType = cmake::AUTHOR_WARNING; std::ostringstream e; bool issueMessage = false; - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) - { + switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) { case cmPolicies::WARN: e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n"; issueMessage = true; @@ -203,9 +170,8 @@ bool cmAddCustomTargetCommand case cmPolicies::REQUIRED_ALWAYS: issueMessage = true; messageType = cmake::FATAL_ERROR; - } - if (issueMessage) - { + } + if (issueMessage) { /* clang-format off */ e << "The target name \"" << targetName << "\" is reserved or not valid for certain " @@ -214,59 +180,52 @@ bool cmAddCustomTargetCommand /* clang-format on */ this->Makefile->IssueMessage(messageType, e.str()); - if (messageType == cmake::FATAL_ERROR) - { + if (messageType == cmake::FATAL_ERROR) { return false; - } } } + } // Store the last command line finished. - if(!currentLine.empty()) - { + if (!currentLine.empty()) { commandLines.push_back(currentLine); currentLine.clear(); - } + } // Enforce name uniqueness. { - std::string msg; - if(!this->Makefile->EnforceUniqueName(targetName, msg, true)) - { - this->SetError(msg); - return false; + std::string msg; + if (!this->Makefile->EnforceUniqueName(targetName, msg, true)) { + this->SetError(msg); + return false; } } // Convert working directory to a full path. - if(!working_directory.empty()) - { + if (!working_directory.empty()) { const char* build_dir = this->Makefile->GetCurrentBinaryDirectory(); working_directory = cmSystemTools::CollapseFullPath(working_directory, build_dir); - } + } - if (commandLines.empty() && !byproducts.empty()) - { - this->Makefile->IssueMessage(cmake::FATAL_ERROR, + if (commandLines.empty() && !byproducts.empty()) { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, "BYPRODUCTS may not be specified without any COMMAND"); return true; - } - if (commandLines.empty() && uses_terminal) - { - this->Makefile->IssueMessage(cmake::FATAL_ERROR, + } + if (commandLines.empty() && uses_terminal) { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, "USES_TERMINAL may not be specified without any COMMAND"); return true; - } + } // Add the utility target to the makefile. bool escapeOldStyle = !verbatim; - cmTarget* target = - this->Makefile->AddUtilityCommand(targetName, excludeFromAll, - working_directory.c_str(), - byproducts, depends, - commandLines, escapeOldStyle, comment, - uses_terminal); + cmTarget* target = this->Makefile->AddUtilityCommand( + targetName, excludeFromAll, working_directory.c_str(), byproducts, depends, + commandLines, escapeOldStyle, comment, uses_terminal); // Add additional user-specified source files to the target. target->AddSources(sources); |