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.
This commit is contained in:
parent
1712cd0a98
commit
2b96e0edab
|
@ -63,6 +63,7 @@ cmFindPackageCommand::cmFindPackageCommand()
|
||||||
this->NoBuilds = false;
|
this->NoBuilds = false;
|
||||||
this->NoModule = false;
|
this->NoModule = false;
|
||||||
this->DebugMode = false;
|
this->DebugMode = false;
|
||||||
|
this->UseLib64Paths = false;
|
||||||
this->VersionMajor = 0;
|
this->VersionMajor = 0;
|
||||||
this->VersionMinor = 0;
|
this->VersionMinor = 0;
|
||||||
this->VersionPatch = 0;
|
this->VersionPatch = 0;
|
||||||
|
@ -298,6 +299,18 @@ bool cmFindPackageCommand
|
||||||
// Check for debug mode.
|
// Check for debug mode.
|
||||||
this->DebugMode = this->Makefile->IsOn("CMAKE_FIND_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.
|
// Find the current root path mode.
|
||||||
this->SelectDefaultRootPathMode();
|
this->SelectDefaultRootPathMode();
|
||||||
|
|
||||||
|
@ -1457,16 +1470,12 @@ private:
|
||||||
class cmFileListGeneratorEnumerate: public cmFileListGeneratorBase
|
class cmFileListGeneratorEnumerate: public cmFileListGeneratorBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cmFileListGeneratorEnumerate(const char* p1, const char* p2):
|
cmFileListGeneratorEnumerate(std::vector<std::string> const& v):
|
||||||
cmFileListGeneratorBase()
|
cmFileListGeneratorBase(), Vector(v) {}
|
||||||
{
|
|
||||||
this->Vector.push_back(p1);
|
|
||||||
this->Vector.push_back(p2);
|
|
||||||
}
|
|
||||||
cmFileListGeneratorEnumerate(cmFileListGeneratorEnumerate const& r):
|
cmFileListGeneratorEnumerate(cmFileListGeneratorEnumerate const& r):
|
||||||
cmFileListGeneratorBase(), Vector(r.Vector) {}
|
cmFileListGeneratorBase(), Vector(r.Vector) {}
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> Vector;
|
std::vector<std::string> const& Vector;
|
||||||
virtual bool Search(std::string const& parent, cmFileList& lister)
|
virtual bool Search(std::string const& parent, cmFileList& lister)
|
||||||
{
|
{
|
||||||
for(std::vector<std::string>::const_iterator i = this->Vector.begin();
|
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).*/
|
// PREFIX/(share|lib)/(Foo|foo|FOO).*/
|
||||||
{
|
{
|
||||||
cmFindPackageFileList lister(this);
|
cmFindPackageFileList lister(this);
|
||||||
lister
|
lister
|
||||||
/ cmFileListGeneratorFixed(prefix)
|
/ cmFileListGeneratorFixed(prefix)
|
||||||
/ cmFileListGeneratorEnumerate("lib", "share")
|
/ cmFileListGeneratorEnumerate(common)
|
||||||
/ cmFileListGeneratorProject(this->Names);
|
/ cmFileListGeneratorProject(this->Names);
|
||||||
if(lister.Search())
|
if(lister.Search())
|
||||||
{
|
{
|
||||||
|
@ -1734,7 +1752,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
|
||||||
cmFindPackageFileList lister(this);
|
cmFindPackageFileList lister(this);
|
||||||
lister
|
lister
|
||||||
/ cmFileListGeneratorFixed(prefix)
|
/ cmFileListGeneratorFixed(prefix)
|
||||||
/ cmFileListGeneratorEnumerate("lib", "share")
|
/ cmFileListGeneratorEnumerate(common)
|
||||||
/ cmFileListGeneratorProject(this->Names)
|
/ cmFileListGeneratorProject(this->Names)
|
||||||
/ cmFileListGeneratorCaseInsensitive("cmake");
|
/ cmFileListGeneratorCaseInsensitive("cmake");
|
||||||
if(lister.Search())
|
if(lister.Search())
|
||||||
|
|
|
@ -124,6 +124,7 @@ private:
|
||||||
bool NoModule;
|
bool NoModule;
|
||||||
bool NoBuilds;
|
bool NoBuilds;
|
||||||
bool DebugMode;
|
bool DebugMode;
|
||||||
|
bool UseLib64Paths;
|
||||||
std::vector<std::string> Names;
|
std::vector<std::string> Names;
|
||||||
std::vector<std::string> Configs;
|
std::vector<std::string> Configs;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue