summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalVisualStudioGenerator.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/cmLocalVisualStudioGenerator.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/cmLocalVisualStudioGenerator.cxx')
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx102
1 files changed, 45 insertions, 57 deletions
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index b12ea49..85ab615 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -18,8 +18,8 @@
#include "cmSystemTools.h"
#include "windows.h"
-cmLocalVisualStudioGenerator
-::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf)
+cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator(
+ cmGlobalGenerator* gg, cmMakefile* mf)
: cmLocalGenerator(gg, mf)
{
}
@@ -37,8 +37,8 @@ cmLocalVisualStudioGenerator::GetVersion() const
}
void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
- std::map<cmSourceFile const*, std::string>& mapping,
- cmGeneratorTarget const* gt)
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt)
{
std::string dir_max = this->ComputeLongestObjectDirectory(gt);
@@ -46,33 +46,32 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
// windows file names are not case sensitive.
std::map<std::string, int> counts;
- for(std::map<cmSourceFile const*, std::string>::iterator
- si = mapping.begin(); si != mapping.end(); ++si)
- {
+ for (std::map<cmSourceFile const*, std::string>::iterator si =
+ mapping.begin();
+ si != mapping.end(); ++si) {
cmSourceFile const* sf = si->first;
std::string objectNameLower = cmSystemTools::LowerCase(
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
objectNameLower += this->GlobalGenerator->GetLanguageOutputExtension(*sf);
counts[objectNameLower] += 1;
- }
+ }
// For all source files producing duplicate names we need unique
// object name computation.
- for(std::map<cmSourceFile const*, std::string>::iterator
- si = mapping.begin(); si != mapping.end(); ++si)
- {
+ for (std::map<cmSourceFile const*, std::string>::iterator si =
+ mapping.begin();
+ si != mapping.end(); ++si) {
cmSourceFile const* sf = si->first;
std::string objectName =
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
objectName += this->GlobalGenerator->GetLanguageOutputExtension(*sf);
- if(counts[cmSystemTools::LowerCase(objectName)] > 1)
- {
+ if (counts[cmSystemTools::LowerCase(objectName)] > 1) {
const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf);
objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max);
- }
- si->second = objectName;
}
+ si->second = objectName;
+ }
}
cmsys::auto_ptr<cmCustomCommand>
@@ -85,12 +84,15 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
// If an executable exports symbols then VS wants to create an
// import library but forgets to create the output directory.
// The Intel Fortran plugin always forgets to the directory.
- if(target->GetType() != cmState::EXECUTABLE &&
- !(isFortran && target->GetType() == cmState::SHARED_LIBRARY))
- { return pcc; }
+ if (target->GetType() != cmState::EXECUTABLE &&
+ !(isFortran && target->GetType() == cmState::SHARED_LIBRARY)) {
+ return pcc;
+ }
std::string outDir = target->GetDirectory(config, false);
std::string impDir = target->GetDirectory(config, true);
- if(impDir == outDir) { return pcc; }
+ if (impDir == outDir) {
+ return pcc;
+ }
// Add a pre-build event to create the directory.
cmCustomCommandLine command;
@@ -103,8 +105,8 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
std::vector<std::string> no_depends;
cmCustomCommandLines commands;
commands.push_back(command);
- pcc.reset(new cmCustomCommand(0, no_output, no_byproducts,
- no_depends, commands, 0, 0));
+ pcc.reset(new cmCustomCommand(0, no_output, no_byproducts, no_depends,
+ commands, 0, 0));
pcc->SetEscapeOldStyle(false);
pcc->SetEscapeAllowMakeVars(true);
return pcc;
@@ -120,43 +122,36 @@ const char* cmLocalVisualStudioGenerator::GetReportErrorLabel() const
return this->ReportErrorLabel();
}
-std::string
-cmLocalVisualStudioGenerator
-::ConstructScript(cmCustomCommandGenerator const& ccg,
- const std::string& newline_text)
+std::string cmLocalVisualStudioGenerator::ConstructScript(
+ cmCustomCommandGenerator const& ccg, const std::string& newline_text)
{
bool useLocal = this->CustomCommandUseLocal();
std::string workingDirectory = ccg.GetWorkingDirectory();
- RelativeRoot relativeRoot = workingDirectory.empty()? START_OUTPUT : NONE;
+ RelativeRoot relativeRoot = workingDirectory.empty() ? START_OUTPUT : NONE;
// Avoid leading or trailing newlines.
std::string newline = "";
// Line to check for error between commands.
std::string check_error = newline_text;
- if(useLocal)
- {
+ if (useLocal) {
check_error += "if %errorlevel% neq 0 goto :cmEnd";
- }
- else
- {
+ } else {
check_error += "if errorlevel 1 goto ";
check_error += this->GetReportErrorLabel();
- }
+ }
// Store the script in a string.
std::string script;
// Open a local context.
- if(useLocal)
- {
+ if (useLocal) {
script += newline;
newline = newline_text;
script += "setlocal";
- }
+ }
- if(!workingDirectory.empty())
- {
+ if (!workingDirectory.empty()) {
// Change the working directory.
script += newline;
newline = newline_text;
@@ -165,35 +160,31 @@ cmLocalVisualStudioGenerator
script += check_error;
// Change the working drive.
- if(workingDirectory.size() > 1 && workingDirectory[1] == ':')
- {
+ if (workingDirectory.size() > 1 && workingDirectory[1] == ':') {
script += newline;
newline = newline_text;
script += workingDirectory[0];
script += workingDirectory[1];
script += check_error;
- }
}
+ }
// for visual studio IDE add extra stuff to the PATH
// if CMAKE_MSVCIDE_RUN_PATH is set.
- if(this->Makefile->GetDefinition("MSVC_IDE"))
- {
+ if (this->Makefile->GetDefinition("MSVC_IDE")) {
const char* extraPath =
this->Makefile->GetDefinition("CMAKE_MSVCIDE_RUN_PATH");
- if(extraPath)
- {
+ if (extraPath) {
script += newline;
newline = newline_text;
script += "set PATH=";
script += extraPath;
script += ";%PATH%";
- }
}
+ }
// Write each command on a single line.
- for(unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c)
- {
+ for (unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) {
// Start a new line.
script += newline;
newline = newline_text;
@@ -205,14 +196,12 @@ cmLocalVisualStudioGenerator
// invoked as custom commands.
//
std::string suffix;
- if (cmd.size() > 4)
- {
- suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size()-4));
- if (suffix == ".bat" || suffix == ".cmd")
- {
+ if (cmd.size() > 4) {
+ suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size() - 4));
+ if (suffix == ".bat" || suffix == ".cmd") {
script += "call ";
- }
}
+ }
script += this->Convert(cmd.c_str(), relativeRoot, SHELL);
ccg.AppendArguments(c, script);
@@ -222,11 +211,10 @@ cmLocalVisualStudioGenerator
// skipping the run of any subsequent commands in this
// sequence.
script += check_error;
- }
+ }
// Close the local context.
- if(useLocal)
- {
+ if (useLocal) {
script += newline;
script += ":cmEnd";
script += newline;
@@ -240,7 +228,7 @@ cmLocalVisualStudioGenerator
script += newline;
script += "if %errorlevel% neq 0 goto ";
script += this->GetReportErrorLabel();
- }
+ }
return script;
}