diff options
author | Kitware Robot <kwrobot@kitware.com> | 2016-05-16 14:34:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-16 20:05:19 (GMT) |
commit | d9fd2f5402eeaa345691313658e02b51038f570b (patch) | |
tree | dca71b9a7e267f4c6300da3eb770415381726785 /Source/cmSearchPath.cxx | |
parent | 82df6deaafb36cbbfd450202bb20b320f637751a (diff) | |
download | CMake-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/cmSearchPath.cxx')
-rw-r--r-- | Source/cmSearchPath.cxx | 161 |
1 files changed, 64 insertions, 97 deletions
diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx index 28798c1..a0cce12 100644 --- a/Source/cmSearchPath.cxx +++ b/Source/cmSearchPath.cxx @@ -15,7 +15,7 @@ #include "cmFindCommon.h" cmSearchPath::cmSearchPath(cmFindCommon* findCmd) -: FC(findCmd) + : FC(findCmd) { } @@ -23,23 +23,19 @@ cmSearchPath::~cmSearchPath() { } - void cmSearchPath::ExtractWithout(const std::set<std::string>& ignore, std::vector<std::string>& outPaths, bool clear) const { - if(clear) - { + if (clear) { outPaths.clear(); - } - for(std::vector<std::string>::const_iterator p = this->Paths.begin(); - p != this->Paths.end(); ++p) - { - if(ignore.count(*p) == 0) - { + } + for (std::vector<std::string>::const_iterator p = this->Paths.begin(); + p != this->Paths.end(); ++p) { + if (ignore.count(*p) == 0) { outPaths.push_back(*p); - } } + } } void cmSearchPath::AddPath(const std::string& path) @@ -57,11 +53,10 @@ void cmSearchPath::AddUserPath(const std::string& path) // it. cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32; cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64; - if(this->FC->Makefile->PlatformIs64Bit()) - { + if (this->FC->Makefile->PlatformIs64Bit()) { view = cmSystemTools::KeyWOW64_64; other_view = cmSystemTools::KeyWOW64_32; - } + } // Expand using the view of the target application. std::string expanded = path; @@ -70,19 +65,17 @@ void cmSearchPath::AddUserPath(const std::string& path) // Executables can be either 32-bit or 64-bit, so expand using the // alternative view. - if(expanded != path && this->FC->CMakePathName == "PROGRAM") - { + if (expanded != path && this->FC->CMakePathName == "PROGRAM") { expanded = path; cmSystemTools::ExpandRegistryValues(expanded, other_view); cmSystemTools::GlobDirs(expanded, outPaths); - } + } // Process them all from the current directory - for(std::vector<std::string>::const_iterator p = outPaths.begin(); - p != outPaths.end(); ++p) - { + for (std::vector<std::string>::const_iterator p = outPaths.begin(); + p != outPaths.end(); ++p) { this->AddPathInternal(*p, this->FC->Makefile->GetCurrentSourceDirectory()); - } + } } void cmSearchPath::AddCMakePath(const std::string& variable) @@ -90,29 +83,26 @@ void cmSearchPath::AddCMakePath(const std::string& variable) assert(this->FC != NULL); // Get a path from a CMake variable. - if(const char* value = this->FC->Makefile->GetDefinition(variable)) - { + if (const char* value = this->FC->Makefile->GetDefinition(variable)) { std::vector<std::string> expanded; cmSystemTools::ExpandListArgument(value, expanded); - for(std::vector<std::string>::const_iterator p = expanded.begin(); - p!= expanded.end(); ++p) - { + for (std::vector<std::string>::const_iterator p = expanded.begin(); + p != expanded.end(); ++p) { this->AddPathInternal(*p, this->FC->Makefile->GetCurrentSourceDirectory()); - } } + } } void cmSearchPath::AddEnvPath(const std::string& variable) { std::vector<std::string> expanded; cmSystemTools::GetPath(expanded, variable.c_str()); - for(std::vector<std::string>::const_iterator p = expanded.begin(); - p!= expanded.end(); ++p) - { + for (std::vector<std::string>::const_iterator p = expanded.begin(); + p != expanded.end(); ++p) { this->AddPathInternal(*p); - } + } } void cmSearchPath::AddCMakePrefixPath(const std::string& variable) @@ -120,39 +110,33 @@ void cmSearchPath::AddCMakePrefixPath(const std::string& variable) assert(this->FC != NULL); // Get a path from a CMake variable. - if(const char* value = this->FC->Makefile->GetDefinition(variable)) - { + if (const char* value = this->FC->Makefile->GetDefinition(variable)) { std::vector<std::string> expanded; cmSystemTools::ExpandListArgument(value, expanded); this->AddPrefixPaths(expanded, this->FC->Makefile->GetCurrentSourceDirectory()); - } + } } static std::string cmSearchPathStripBin(std::string const& s) { // If the path is a PREFIX/bin case then add its parent instead. - if((cmHasLiteralSuffix(s, "/bin")) || - (cmHasLiteralSuffix(s, "/sbin"))) - { + if ((cmHasLiteralSuffix(s, "/bin")) || (cmHasLiteralSuffix(s, "/sbin"))) { return cmSystemTools::GetFilenamePath(s); - } - else - { + } else { return s; - } + } } void cmSearchPath::AddEnvPrefixPath(const std::string& variable, bool stripBin) { std::vector<std::string> expanded; cmSystemTools::GetPath(expanded, variable.c_str()); - if (stripBin) - { + if (stripBin) { std::transform(expanded.begin(), expanded.end(), expanded.begin(), cmSearchPathStripBin); - } + } this->AddPrefixPaths(expanded); } @@ -160,102 +144,85 @@ void cmSearchPath::AddSuffixes(const std::vector<std::string>& suffixes) { std::vector<std::string> inPaths; inPaths.swap(this->Paths); - this->Paths.reserve(inPaths.size()*(suffixes.size()+1)); + this->Paths.reserve(inPaths.size() * (suffixes.size() + 1)); - for(std::vector<std::string>::iterator ip = inPaths.begin(); - ip != inPaths.end(); ++ip) - { + for (std::vector<std::string>::iterator ip = inPaths.begin(); + ip != inPaths.end(); ++ip) { cmSystemTools::ConvertToUnixSlashes(*ip); // if *i is only / then do not add a // // this will get incorrectly considered a network // path on windows and cause huge delays. std::string p = *ip; - if(!p.empty() && *p.rbegin() != '/') - { + if (!p.empty() && *p.rbegin() != '/') { p += "/"; - } + } // Combine with all the suffixes - for(std::vector<std::string>::const_iterator s = suffixes.begin(); - s != suffixes.end(); ++s) - { - this->Paths.push_back(p+*s); - } + for (std::vector<std::string>::const_iterator s = suffixes.begin(); + s != suffixes.end(); ++s) { + this->Paths.push_back(p + *s); + } // And now the original w/o any suffix this->Paths.push_back(*ip); - } + } } void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths, - const char *base) + const char* base) { assert(this->FC != NULL); // default for programs std::string subdir = "bin"; - if (this->FC->CMakePathName == "INCLUDE") - { + if (this->FC->CMakePathName == "INCLUDE") { subdir = "include"; - } - else if (this->FC->CMakePathName == "LIBRARY") - { + } else if (this->FC->CMakePathName == "LIBRARY") { subdir = "lib"; - } - else if (this->FC->CMakePathName == "FRAMEWORK") - { - subdir = ""; // ? what to do for frameworks ? - } + } else if (this->FC->CMakePathName == "FRAMEWORK") { + subdir = ""; // ? what to do for frameworks ? + } - for(std::vector<std::string>::const_iterator p = paths.begin(); - p != paths.end(); ++p) - { + for (std::vector<std::string>::const_iterator p = paths.begin(); + p != paths.end(); ++p) { std::string dir = *p; - if(!subdir.empty() && !dir.empty() && *dir.rbegin() != '/') - { + if (!subdir.empty() && !dir.empty() && *dir.rbegin() != '/') { dir += "/"; - } - if(subdir == "include" || subdir == "lib") - { + } + if (subdir == "include" || subdir == "lib") { const char* arch = this->FC->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"); - if(arch && *arch) - { - this->AddPathInternal(dir+subdir+"/"+arch, base); - } + if (arch && *arch) { + this->AddPathInternal(dir + subdir + "/" + arch, base); } + } std::string add = dir + subdir; - if(add != "/") - { + if (add != "/") { this->AddPathInternal(add, base); - } - if (subdir == "bin") - { - this->AddPathInternal(dir+"sbin", base); - } - if(!subdir.empty() && *p != "/") - { + } + if (subdir == "bin") { + this->AddPathInternal(dir + "sbin", base); + } + if (!subdir.empty() && *p != "/") { this->AddPathInternal(*p, base); - } } + } } -void cmSearchPath::AddPathInternal(const std::string& path, const char *base) +void cmSearchPath::AddPathInternal(const std::string& path, const char* base) { assert(this->FC != NULL); std::string collapsed = cmSystemTools::CollapseFullPath(path, base); - if(collapsed.empty()) - { + if (collapsed.empty()) { return; - } + } // Insert the path if has not already been emitted. - if(this->FC->SearchPathsEmitted.insert(collapsed).second) - { + if (this->FC->SearchPathsEmitted.insert(collapsed).second) { this->Paths.push_back(collapsed); - } + } } |