diff options
author | Brad King <brad.king@kitware.com> | 2008-08-12 23:01:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-08-12 23:01:04 (GMT) |
commit | 2b96e0edab9f255ff049b93f4fa17a3a444c8338 (patch) | |
tree | b0f494bae65177f4dbf3dec1d962515835165acb /Source/cmFindPackageCommand.cxx | |
parent | 1712cd0a9874914f04514f5d35a204e9d30a8dea (diff) | |
download | CMake-2b96e0edab9f255ff049b93f4fa17a3a444c8338.zip CMake-2b96e0edab9f255ff049b93f4fa17a3a444c8338.tar.gz CMake-2b96e0edab9f255ff049b93f4fa17a3a444c8338.tar.bz2 |
ENH: Teach find_package about lib64 paths
When find_package is about to look in <prefix>/lib, search first in
<prefix>/lib64 in cases that find_library would use lib64 paths.
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index f4e36e0..f130ba2 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -63,6 +63,7 @@ cmFindPackageCommand::cmFindPackageCommand() this->NoBuilds = false; this->NoModule = false; this->DebugMode = false; + this->UseLib64Paths = false; this->VersionMajor = 0; this->VersionMinor = 0; this->VersionPatch = 0; @@ -298,6 +299,18 @@ bool cmFindPackageCommand // Check for debug mode. this->DebugMode = this->Makefile->IsOn("CMAKE_FIND_DEBUG_MODE"); + // Lookup whether lib64 paths should be used. + if(const char* sizeof_dptr = + this->Makefile->GetDefinition("CMAKE_SIZEOF_VOID_P")) + { + if(atoi(sizeof_dptr) == 8 && + this->Makefile->GetCMakeInstance() + ->GetPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS")) + { + this->UseLib64Paths = true; + } + } + // Find the current root path mode. this->SelectDefaultRootPathMode(); @@ -1457,16 +1470,12 @@ private: class cmFileListGeneratorEnumerate: public cmFileListGeneratorBase { public: - cmFileListGeneratorEnumerate(const char* p1, const char* p2): - cmFileListGeneratorBase() - { - this->Vector.push_back(p1); - this->Vector.push_back(p2); - } + cmFileListGeneratorEnumerate(std::vector<std::string> const& v): + cmFileListGeneratorBase(), Vector(v) {} cmFileListGeneratorEnumerate(cmFileListGeneratorEnumerate const& r): cmFileListGeneratorBase(), Vector(r.Vector) {} private: - std::vector<std::string> Vector; + std::vector<std::string> const& Vector; virtual bool Search(std::string const& parent, cmFileList& lister) { for(std::vector<std::string>::const_iterator i = this->Vector.begin(); @@ -1716,12 +1725,21 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) } } + // Construct list of common install locations (lib and share). + std::vector<std::string> common; + if(this->UseLib64Paths) + { + common.push_back("lib64"); + } + common.push_back("lib"); + common.push_back("share"); + // PREFIX/(share|lib)/(Foo|foo|FOO).*/ { cmFindPackageFileList lister(this); lister / cmFileListGeneratorFixed(prefix) - / cmFileListGeneratorEnumerate("lib", "share") + / cmFileListGeneratorEnumerate(common) / cmFileListGeneratorProject(this->Names); if(lister.Search()) { @@ -1734,7 +1752,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) cmFindPackageFileList lister(this); lister / cmFileListGeneratorFixed(prefix) - / cmFileListGeneratorEnumerate("lib", "share") + / cmFileListGeneratorEnumerate(common) / cmFileListGeneratorProject(this->Names) / cmFileListGeneratorCaseInsensitive("cmake"); if(lister.Search()) |