diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2010-08-12 22:20:47 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2010-08-13 15:53:28 (GMT) |
commit | 1221581aa8de2b4bb06e09894940dba6ff90caa1 (patch) | |
tree | 0b2559f8f54e203d189056464c48e8d096ab73da /Source/cmFindCommon.cxx | |
parent | 7b632e5ac62cb2af74025b71660a1c5822fcfc39 (diff) | |
download | CMake-1221581aa8de2b4bb06e09894940dba6ff90caa1.zip CMake-1221581aa8de2b4bb06e09894940dba6ff90caa1.tar.gz CMake-1221581aa8de2b4bb06e09894940dba6ff90caa1.tar.bz2 |
Teach find_* commands to ignore some paths
Add platform configuration variable CMAKE_SYSTEM_IGNORE_PATH and user
configuration variable CMAKE_IGNORE_PATH. These specify a set of
directories that will be ignored by all the find commands. Update
FindPackageTest so that several cases will fail without a functioning
CMAKE_IGNORE_PATH.
Diffstat (limited to 'Source/cmFindCommon.cxx')
-rw-r--r-- | Source/cmFindCommon.cxx | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index f352172..b7d3e52 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -241,6 +241,63 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) } //---------------------------------------------------------------------------- +void cmFindCommon::FilterPaths(std::vector<std::string>& paths, + const std::set<std::string>& ignore) +{ + // Now filter out anything that's in the ignore set. + std::vector<std::string> unfiltered; + unfiltered.swap(paths); + + for(std::vector<std::string>::iterator pi = unfiltered.begin(); + pi != unfiltered.end(); ++pi) + { + if (ignore.count(*pi) == 0) + { + paths.push_back(*pi); + } + } +} + + +//---------------------------------------------------------------------------- +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 }; + + // Construct the list of path roots with no trailing slashes. + 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)) + { + continue; + } + + cmSystemTools::ExpandListArgument(ignorePath, ignore); + } + + 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; + GetIgnoredPaths(ignoreVec); + ignore.insert(ignoreVec.begin(), ignoreVec.end()); +} + + + +//---------------------------------------------------------------------------- bool cmFindCommon::CheckCommonArgument(std::string const& arg) { if(arg == "NO_DEFAULT_PATH") |