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/cmFindCommon.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/cmFindCommon.cxx')
-rw-r--r-- | Source/cmFindCommon.cxx | 260 |
1 files changed, 98 insertions, 162 deletions
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 2758c18..638c1d1 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -16,11 +16,11 @@ cmFindCommon::PathGroup cmFindCommon::PathGroup::All("ALL"); cmFindCommon::PathLabel cmFindCommon::PathLabel::CMake("CMAKE"); -cmFindCommon::PathLabel - cmFindCommon::PathLabel::CMakeEnvironment("CMAKE_ENVIRONMENT"); +cmFindCommon::PathLabel cmFindCommon::PathLabel::CMakeEnvironment( + "CMAKE_ENVIRONMENT"); cmFindCommon::PathLabel cmFindCommon::PathLabel::Hints("HINTS"); -cmFindCommon::PathLabel - cmFindCommon::PathLabel::SystemEnvironment("SYSTM_ENVIRONMENT"); +cmFindCommon::PathLabel cmFindCommon::PathLabel::SystemEnvironment( + "SYSTM_ENVIRONMENT"); cmFindCommon::PathLabel cmFindCommon::PathLabel::CMakeSystem("CMAKE_SYSTEM"); cmFindCommon::PathLabel cmFindCommon::PathLabel::Guess("GUESS"); @@ -33,8 +33,8 @@ cmFindCommon::cmFindCommon() this->NoSystemEnvironmentPath = false; this->NoCMakeSystemPath = false; - // OS X Bundle and Framework search policy. The default is to - // search frameworks first on apple. +// OS X Bundle and Framework search policy. The default is to +// search frameworks first on apple. #if defined(__APPLE__) this->SearchFrameworkFirst = true; this->SearchAppBundleFirst = true; @@ -73,18 +73,18 @@ void cmFindCommon::InitializeSearchPathGroups() this->PathGroupOrder.push_back(PathGroup::All); // Create the idividual labeld search paths - this->LabeledPaths.insert(std::make_pair(PathLabel::CMake, - cmSearchPath(this))); - this->LabeledPaths.insert(std::make_pair(PathLabel::CMakeEnvironment, - cmSearchPath(this))); - this->LabeledPaths.insert(std::make_pair(PathLabel::Hints, - cmSearchPath(this))); - this->LabeledPaths.insert(std::make_pair(PathLabel::SystemEnvironment, - cmSearchPath(this))); - this->LabeledPaths.insert(std::make_pair(PathLabel::CMakeSystem, - cmSearchPath(this))); - this->LabeledPaths.insert(std::make_pair(PathLabel::Guess, - cmSearchPath(this))); + this->LabeledPaths.insert( + std::make_pair(PathLabel::CMake, cmSearchPath(this))); + this->LabeledPaths.insert( + std::make_pair(PathLabel::CMakeEnvironment, cmSearchPath(this))); + this->LabeledPaths.insert( + std::make_pair(PathLabel::Hints, cmSearchPath(this))); + this->LabeledPaths.insert( + std::make_pair(PathLabel::SystemEnvironment, cmSearchPath(this))); + this->LabeledPaths.insert( + std::make_pair(PathLabel::CMakeSystem, cmSearchPath(this))); + this->LabeledPaths.insert( + std::make_pair(PathLabel::Guess, cmSearchPath(this))); } void cmFindCommon::SelectDefaultRootPathMode() @@ -94,73 +94,54 @@ void cmFindCommon::SelectDefaultRootPathMode() findRootPathVar += this->CMakePathName; std::string rootPathMode = this->Makefile->GetSafeDefinition(findRootPathVar); - if (rootPathMode=="NEVER") - { + if (rootPathMode == "NEVER") { this->FindRootPathMode = RootPathModeNever; - } - else if (rootPathMode=="ONLY") - { + } else if (rootPathMode == "ONLY") { this->FindRootPathMode = RootPathModeOnly; - } - else if (rootPathMode=="BOTH") - { + } else if (rootPathMode == "BOTH") { this->FindRootPathMode = RootPathModeBoth; - } + } } void cmFindCommon::SelectDefaultMacMode() { std::string ff = this->Makefile->GetSafeDefinition("CMAKE_FIND_FRAMEWORK"); - if(ff == "NEVER") - { + if (ff == "NEVER") { this->SearchFrameworkLast = false; this->SearchFrameworkFirst = false; this->SearchFrameworkOnly = false; - } - else if(ff == "ONLY") - { + } else if (ff == "ONLY") { this->SearchFrameworkLast = false; this->SearchFrameworkFirst = false; this->SearchFrameworkOnly = true; - } - else if(ff == "FIRST") - { + } else if (ff == "FIRST") { this->SearchFrameworkLast = false; this->SearchFrameworkFirst = true; this->SearchFrameworkOnly = false; - } - else if(ff == "LAST") - { + } else if (ff == "LAST") { this->SearchFrameworkLast = true; this->SearchFrameworkFirst = false; this->SearchFrameworkOnly = false; - } + } std::string fab = this->Makefile->GetSafeDefinition("CMAKE_FIND_APPBUNDLE"); - if(fab == "NEVER") - { + if (fab == "NEVER") { this->SearchAppBundleLast = false; this->SearchAppBundleFirst = false; this->SearchAppBundleOnly = false; - } - else if(fab == "ONLY") - { + } else if (fab == "ONLY") { this->SearchAppBundleLast = false; this->SearchAppBundleFirst = false; this->SearchAppBundleOnly = true; - } - else if(fab == "FIRST") - { + } else if (fab == "FIRST") { this->SearchAppBundleLast = false; this->SearchAppBundleFirst = true; this->SearchAppBundleOnly = false; - } - else if(fab == "LAST") - { + } else if (fab == "LAST") { this->SearchAppBundleLast = true; this->SearchAppBundleFirst = false; this->SearchAppBundleOnly = false; - } + } } void cmFindCommon::RerootPaths(std::vector<std::string>& paths) @@ -173,125 +154,105 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) } #endif // Short-circuit if there is nothing to do. - if(this->FindRootPathMode == RootPathModeNever) - { + if (this->FindRootPathMode == RootPathModeNever) { return; - } + } - const char* sysroot = - this->Makefile->GetDefinition("CMAKE_SYSROOT"); - const char* rootPath = - this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH"); + const char* sysroot = this->Makefile->GetDefinition("CMAKE_SYSROOT"); + const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH"); const bool noSysroot = !sysroot || !*sysroot; const bool noRootPath = !rootPath || !*rootPath; - if(noSysroot && noRootPath) - { + if (noSysroot && noRootPath) { return; - } + } // Construct the list of path roots with no trailing slashes. std::vector<std::string> roots; - if (rootPath) - { + if (rootPath) { cmSystemTools::ExpandListArgument(rootPath, roots); - } - if (sysroot) - { + } + if (sysroot) { roots.push_back(sysroot); - } - for(std::vector<std::string>::iterator ri = roots.begin(); - ri != roots.end(); ++ri) - { + } + for (std::vector<std::string>::iterator ri = roots.begin(); + ri != roots.end(); ++ri) { cmSystemTools::ConvertToUnixSlashes(*ri); - } + } const char* stagePrefix = - this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); + this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); // Copy the original set of unrooted paths. std::vector<std::string> unrootedPaths = paths; paths.clear(); - for(std::vector<std::string>::const_iterator ri = roots.begin(); - ri != roots.end(); ++ri) - { - for(std::vector<std::string>::const_iterator ui = unrootedPaths.begin(); - ui != unrootedPaths.end(); ++ui) - { + for (std::vector<std::string>::const_iterator ri = roots.begin(); + ri != roots.end(); ++ri) { + for (std::vector<std::string>::const_iterator ui = unrootedPaths.begin(); + ui != unrootedPaths.end(); ++ui) { // Place the unrooted path under the current root if it is not // already inside. Skip the unrooted path if it is relative to // a user home directory or is empty. std::string rootedDir; - if(cmSystemTools::IsSubDirectory(*ui, *ri) - || (stagePrefix - && cmSystemTools::IsSubDirectory(*ui, stagePrefix))) - { + if (cmSystemTools::IsSubDirectory(*ui, *ri) || + (stagePrefix && cmSystemTools::IsSubDirectory(*ui, stagePrefix))) { rootedDir = *ui; - } - else if(!ui->empty() && (*ui)[0] != '~') - { + } else if (!ui->empty() && (*ui)[0] != '~') { // Start with the new root. rootedDir = *ri; rootedDir += "/"; // Append the original path with its old root removed. rootedDir += cmSystemTools::SplitPathRootComponent(*ui); - } + } // Store the new path. paths.push_back(rootedDir); - } } + } // If searching both rooted and unrooted paths add the original // paths again. - if(this->FindRootPathMode == RootPathModeBoth) - { + if (this->FindRootPathMode == RootPathModeBoth) { paths.insert(paths.end(), unrootedPaths.begin(), unrootedPaths.end()); - } + } } void cmFindCommon::FilterPaths(const std::vector<std::string>& inPaths, const std::set<std::string>& ignore, std::vector<std::string>& outPaths) { - for(std::vector<std::string>::const_iterator i = inPaths.begin(); - i != inPaths.end(); ++i) - { - if(ignore.count(*i) == 0) - { + for (std::vector<std::string>::const_iterator i = inPaths.begin(); + i != inPaths.end(); ++i) { + if (ignore.count(*i) == 0) { outPaths.push_back(*i); - } } + } } void cmFindCommon::GetIgnoredPaths(std::vector<std::string>& ignore) { // null-terminated list of paths. - static const char *paths[] = - { "CMAKE_SYSTEM_IGNORE_PATH", "CMAKE_IGNORE_PATH", 0 }; + static const char* paths[] = { "CMAKE_SYSTEM_IGNORE_PATH", + "CMAKE_IGNORE_PATH", 0 }; // Construct the list of path roots with no trailing slashes. - for(const char **pathName = paths; *pathName; ++pathName) - { + for (const char** pathName = paths; *pathName; ++pathName) { // Get the list of paths to ignore from the variable. const char* ignorePath = this->Makefile->GetDefinition(*pathName); - if((ignorePath == 0) || (strlen(ignorePath) == 0)) - { + if ((ignorePath == 0) || (strlen(ignorePath) == 0)) { continue; - } + } cmSystemTools::ExpandListArgument(ignorePath, ignore); - } + } - for(std::vector<std::string>::iterator i = ignore.begin(); - i != ignore.end(); ++i) - { + for (std::vector<std::string>::iterator i = ignore.begin(); + i != ignore.end(); ++i) { cmSystemTools::ConvertToUnixSlashes(*i); - } + } } - void cmFindCommon::GetIgnoredPaths(std::set<std::string>& ignore) { std::vector<std::string> ignoreVec; @@ -301,43 +262,26 @@ void cmFindCommon::GetIgnoredPaths(std::set<std::string>& ignore) bool cmFindCommon::CheckCommonArgument(std::string const& arg) { - if(arg == "NO_DEFAULT_PATH") - { + if (arg == "NO_DEFAULT_PATH") { this->NoDefaultPath = true; - } - else if(arg == "NO_CMAKE_ENVIRONMENT_PATH") - { + } else if (arg == "NO_CMAKE_ENVIRONMENT_PATH") { this->NoCMakeEnvironmentPath = true; - } - else if(arg == "NO_CMAKE_PATH") - { + } else if (arg == "NO_CMAKE_PATH") { this->NoCMakePath = true; - } - else if(arg == "NO_SYSTEM_ENVIRONMENT_PATH") - { + } else if (arg == "NO_SYSTEM_ENVIRONMENT_PATH") { this->NoSystemEnvironmentPath = true; - } - else if(arg == "NO_CMAKE_SYSTEM_PATH") - { + } else if (arg == "NO_CMAKE_SYSTEM_PATH") { this->NoCMakeSystemPath = true; - } - else if(arg == "NO_CMAKE_FIND_ROOT_PATH") - { + } else if (arg == "NO_CMAKE_FIND_ROOT_PATH") { this->FindRootPathMode = RootPathModeNever; - } - else if(arg == "ONLY_CMAKE_FIND_ROOT_PATH") - { + } else if (arg == "ONLY_CMAKE_FIND_ROOT_PATH") { this->FindRootPathMode = RootPathModeOnly; - } - else if(arg == "CMAKE_FIND_ROOT_PATH_BOTH") - { + } else if (arg == "CMAKE_FIND_ROOT_PATH_BOTH") { this->FindRootPathMode = RootPathModeBoth; - } - else - { + } else { // The argument is not one of the above. return false; - } + } // The argument is one of the above. return true; @@ -348,26 +292,21 @@ void cmFindCommon::AddPathSuffix(std::string const& arg) std::string suffix = arg; // Strip leading and trailing slashes. - if(suffix.empty()) - { + if (suffix.empty()) { return; - } - if(suffix[0] == '/') - { + } + if (suffix[0] == '/') { suffix = suffix.substr(1, suffix.npos); - } - if(suffix.empty()) - { + } + if (suffix.empty()) { return; - } - if(suffix[suffix.size()-1] == '/') - { - suffix = suffix.substr(0, suffix.size()-1); - } - if(suffix.empty()) - { + } + if (suffix[suffix.size() - 1] == '/') { + suffix = suffix.substr(0, suffix.size() - 1); + } + if (suffix.empty()) { return; - } + } // Store the suffix. this->SearchPathSuffixes.push_back(suffix); @@ -375,10 +314,9 @@ void cmFindCommon::AddPathSuffix(std::string const& arg) void AddTrailingSlash(std::string& s) { - if(!s.empty() && *s.rbegin() != '/') - { + if (!s.empty() && *s.rbegin() != '/') { s += '/'; - } + } } void cmFindCommon::ComputeFinalPaths() { @@ -389,11 +327,10 @@ void cmFindCommon::ComputeFinalPaths() // Combine the seperate path types, filtering out ignores this->SearchPaths.clear(); std::vector<PathLabel>& allLabels = this->PathGroupLabelMap[PathGroup::All]; - for(std::vector<PathLabel>::const_iterator l = allLabels.begin(); - l != allLabels.end(); ++l) - { + for (std::vector<PathLabel>::const_iterator l = allLabels.begin(); + l != allLabels.end(); ++l) { this->LabeledPaths[*l].ExtractWithout(ignored, this->SearchPaths); - } + } // Expand list of paths inside all search roots. this->RerootPaths(this->SearchPaths); @@ -409,9 +346,8 @@ void cmFindCommon::SetMakefile(cmMakefile* makefile) // If we are building for Apple (OSX or also iphone), make sure // that frameworks and bundles are searched first. - if(this->Makefile->IsOn("APPLE")) - { + if (this->Makefile->IsOn("APPLE")) { this->SearchFrameworkFirst = true; this->SearchAppBundleFirst = true; - } + } } |