diff options
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 123 |
1 files changed, 87 insertions, 36 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 7908afe..8338c2a 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -43,6 +43,7 @@ cmFindPackageCommand::cmFindPackageCommand() this->UseConfigFiles = true; this->UseFindModules = true; this->DebugMode = false; + this->UseLib32Paths = false; this->UseLib64Paths = false; this->PolicyScope = true; this->VersionMajor = 0; @@ -110,6 +111,13 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args, this->LibraryArchitecture = arch; } + // Lookup whether lib32 paths should be used. + if (this->Makefile->PlatformIs32Bit() && + this->Makefile->GetState()->GetGlobalPropertyAsBool( + "FIND_LIBRARY_USE_LIB32_PATHS")) { + this->UseLib32Paths = true; + } + // Lookup whether lib64 paths should be used. if (this->Makefile->PlatformIs64Bit() && this->Makefile->GetState()->GetGlobalPropertyAsBool( @@ -664,16 +672,18 @@ bool cmFindPackageCommand::HandlePackageMode() // If there are files in ConsideredConfigs, it means that FooConfig.cmake // have been found, but they didn't have appropriate versions. else if (!this->ConsideredConfigs.empty()) { + std::vector<ConfigFileInfo>::const_iterator duplicate_end = + cmRemoveDuplicates(this->ConsideredConfigs); e << "Could not find a configuration file for package \"" << this->Name << "\" that " << (this->VersionExact ? "exactly matches" : "is compatible with") << " requested version \"" << this->Version << "\".\n" << "The following configuration files were considered but not " "accepted:\n"; - for (std::vector<ConfigFileInfo>::size_type i = 0; - i < this->ConsideredConfigs.size(); i++) { - e << " " << this->ConsideredConfigs[i].filename - << ", version: " << this->ConsideredConfigs[i].version << "\n"; + for (std::vector<ConfigFileInfo>::const_iterator i = + this->ConsideredConfigs.begin(); + i != duplicate_end; ++i) { + e << " " << i->filename << ", version: " << i->version << "\n"; } } else { std::string requestedVersionString; @@ -766,12 +776,13 @@ bool cmFindPackageCommand::HandlePackageMode() std::string consideredVersions; const char* sep = ""; - for (std::vector<ConfigFileInfo>::size_type i = 0; - i < this->ConsideredConfigs.size(); i++) { + for (std::vector<ConfigFileInfo>::const_iterator i = + this->ConsideredConfigs.begin(); + i != this->ConsideredConfigs.end(); ++i) { consideredConfigFiles += sep; consideredVersions += sep; - consideredConfigFiles += this->ConsideredConfigs[i].filename; - consideredVersions += this->ConsideredConfigs[i].version; + consideredConfigFiles += i->filename; + consideredVersions += i->version; sep = ";"; } @@ -1066,8 +1077,8 @@ void cmFindPackageCommand::FillPrefixesUserRegistry() this->LabeledPaths[PathLabel::UserRegistry]); } #else - if (const char* home = cmSystemTools::GetEnv("HOME")) { - std::string dir = home; + std::string dir; + if (cmSystemTools::GetEnv("HOME", dir)) { dir += "/.cmake/packages/"; dir += this->Name; this->LoadPackageRegistryDir(dir, @@ -1188,7 +1199,7 @@ public: cmSystemTools::RemoveFile(this->File); } } - void Release() { this->File = 0; } + void Release() { this->File = CM_NULLPTR; } }; void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir, @@ -1489,9 +1500,9 @@ void cmFindPackageCommand::StoreVersionFound() this->Makefile->AddDefinition(ver + "_COUNT", buf); } +#include <cm_auto_ptr.hxx> #include <cmsys/Glob.hxx> #include <cmsys/String.h> -#include <cmsys/auto_ptr.hxx> class cmFileList; class cmFileListGeneratorBase @@ -1504,10 +1515,10 @@ protected: private: bool Search(cmFileList&); virtual bool Search(std::string const& parent, cmFileList&) = 0; - virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const = 0; + virtual CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const = 0; friend class cmFileList; cmFileListGeneratorBase* SetNext(cmFileListGeneratorBase const& next); - cmsys::auto_ptr<cmFileListGeneratorBase> Next; + CM_AUTO_PTR<cmFileListGeneratorBase> Next; }; class cmFileList @@ -1515,7 +1526,7 @@ class cmFileList public: cmFileList() : First() - , Last(0) + , Last(CM_NULLPTR) { } virtual ~cmFileList() {} @@ -1540,7 +1551,7 @@ public: private: virtual bool Visit(std::string const& fullPath) = 0; friend class cmFileListGeneratorBase; - cmsys::auto_ptr<cmFileListGeneratorBase> First; + CM_AUTO_PTR<cmFileListGeneratorBase> First; cmFileListGeneratorBase* Last; }; @@ -1555,7 +1566,7 @@ public: } private: - bool Visit(std::string const& fullPath) + bool Visit(std::string const& fullPath) CM_OVERRIDE { if (this->UseSuffixes) { return this->FPC->SearchDirectory(fullPath); @@ -1605,14 +1616,14 @@ public: private: std::string String; - virtual bool Search(std::string const& parent, cmFileList& lister) + bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE { std::string fullPath = parent + this->String; return this->Consider(fullPath, lister); } - virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const + CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const CM_OVERRIDE { - cmsys::auto_ptr<cmFileListGeneratorBase> g( + CM_AUTO_PTR<cmFileListGeneratorBase> g( new cmFileListGeneratorFixed(*this)); return g; } @@ -1634,7 +1645,7 @@ public: private: std::vector<std::string> const& Vector; - virtual bool Search(std::string const& parent, cmFileList& lister) + bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE { for (std::vector<std::string>::const_iterator i = this->Vector.begin(); i != this->Vector.end(); ++i) { @@ -1644,9 +1655,9 @@ private: } return false; } - virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const + CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const CM_OVERRIDE { - cmsys::auto_ptr<cmFileListGeneratorBase> g( + CM_AUTO_PTR<cmFileListGeneratorBase> g( new cmFileListGeneratorEnumerate(*this)); return g; } @@ -1668,7 +1679,7 @@ public: private: std::vector<std::string> const& Names; - virtual bool Search(std::string const& parent, cmFileList& lister) + bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE { // Construct a list of matches. std::vector<std::string> matches; @@ -1695,9 +1706,9 @@ private: } return false; } - virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const + CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const CM_OVERRIDE { - cmsys::auto_ptr<cmFileListGeneratorBase> g( + CM_AUTO_PTR<cmFileListGeneratorBase> g( new cmFileListGeneratorProject(*this)); return g; } @@ -1723,7 +1734,7 @@ public: private: std::vector<std::string> const& Names; std::string Extension; - virtual bool Search(std::string const& parent, cmFileList& lister) + bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE { // Construct a list of matches. std::vector<std::string> matches; @@ -1752,9 +1763,9 @@ private: } return false; } - virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const + CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const CM_OVERRIDE { - cmsys::auto_ptr<cmFileListGeneratorBase> g( + CM_AUTO_PTR<cmFileListGeneratorBase> g( new cmFileListGeneratorMacProject(*this)); return g; } @@ -1777,7 +1788,7 @@ public: private: std::string String; - virtual bool Search(std::string const& parent, cmFileList& lister) + bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE { // Look for matching files. std::vector<std::string> matches; @@ -1796,9 +1807,9 @@ private: } return false; } - virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const + CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const CM_OVERRIDE { - cmsys::auto_ptr<cmFileListGeneratorBase> g( + CM_AUTO_PTR<cmFileListGeneratorBase> g( new cmFileListGeneratorCaseInsensitive(*this)); return g; } @@ -1820,7 +1831,7 @@ public: private: std::string Pattern; - virtual bool Search(std::string const& parent, cmFileList& lister) + bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE { // Glob the set of matching files. std::string expr = parent; @@ -1842,10 +1853,9 @@ private: } return false; } - virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const + CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const CM_OVERRIDE { - cmsys::auto_ptr<cmFileListGeneratorBase> g( - new cmFileListGeneratorGlob(*this)); + CM_AUTO_PTR<cmFileListGeneratorBase> g(new cmFileListGeneratorGlob(*this)); return g; } }; @@ -1907,6 +1917,9 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) if (!this->LibraryArchitecture.empty()) { common.push_back("lib/" + this->LibraryArchitecture); } + if (this->UseLib32Paths) { + common.push_back("lib32"); + } if (this->UseLib64Paths) { common.push_back("lib64"); } @@ -1948,6 +1961,44 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) } } + // PREFIX/(Foo|foo|FOO).*/(lib/ARCH|lib|share)/cmake/(Foo|foo|FOO).*/ + { + cmFindPackageFileList lister(this); + lister / cmFileListGeneratorFixed(prefix) / + cmFileListGeneratorProject(this->Names) / + cmFileListGeneratorEnumerate(common) / + cmFileListGeneratorFixed("cmake") / + cmFileListGeneratorProject(this->Names); + if (lister.Search()) { + return true; + } + } + + // PREFIX/(Foo|foo|FOO).*/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/ + { + cmFindPackageFileList lister(this); + lister / cmFileListGeneratorFixed(prefix) / + cmFileListGeneratorProject(this->Names) / + cmFileListGeneratorEnumerate(common) / + cmFileListGeneratorProject(this->Names); + if (lister.Search()) { + return true; + } + } + + // PREFIX/(Foo|foo|FOO).*/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/(cmake|CMake)/ + { + cmFindPackageFileList lister(this); + lister / cmFileListGeneratorFixed(prefix) / + cmFileListGeneratorProject(this->Names) / + cmFileListGeneratorEnumerate(common) / + cmFileListGeneratorProject(this->Names) / + cmFileListGeneratorCaseInsensitive("cmake"); + if (lister.Search()) { + return true; + } + } + return false; } |