c3102397e6
git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/linamh@2784 6952d904-891a-0410-993b-d76249ca496b
218 lines
7.1 KiB
Diff
218 lines
7.1 KiB
Diff
Author: Nathan Phillip Brink <ohnobinki@ohnopublishing.net>
|
|
Date: 2010/09/17
|
|
Purpose: Add a global FIND_LIBRARY_USE_LIB32_PATHS property which is
|
|
an analog to the existing FIND_LIBRARY_USE_LIB64_PATHS
|
|
property. This fixes kde-base/kdelib's ability to find
|
|
automoc4 using FIND_PACKAGE's NO_MODULE mode on systems where
|
|
/usr/lib is neither a symlink to /usr/lib64 or /usr/lib32.
|
|
Gentoo-Bug: 338492
|
|
|
|
diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake
|
|
index 5ee7ddb..afcde6f 100644
|
|
--- a/Modules/Platform/UnixPaths.cmake
|
|
+++ b/Modules/Platform/UnixPaths.cmake
|
|
@@ -86,3 +86,6 @@ LIST(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
|
|
|
|
# Enable use of lib64 search path variants by default.
|
|
SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
|
|
+# Enable use of lib32 search path variants by default. Useful on
|
|
+# multilib systems. Not harmful for normal systems.
|
|
+SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
|
|
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
|
|
index 9077c8e..e09967d 100644
|
|
--- a/Source/cmFindLibraryCommand.cxx
|
|
+++ b/Source/cmFindLibraryCommand.cxx
|
|
@@ -92,6 +92,12 @@ bool cmFindLibraryCommand
|
|
// add special 64 bit paths if this is a 64 bit compile.
|
|
this->AddLib64Paths();
|
|
}
|
|
+ if(this->Makefile->GetCMakeInstance()
|
|
+ ->GetPropertyAsBool("FIND_LIBRARY_USE_LIB32_PATHS"))
|
|
+ {
|
|
+ // add special 32 bit paths if this is a 32 bit compile.
|
|
+ this->AddLib32Paths();
|
|
+ }
|
|
|
|
std::string library = this->FindLibrary();
|
|
if(library != "")
|
|
@@ -160,10 +166,7 @@ void cmFindLibraryCommand::AddLib64Paths()
|
|
{
|
|
return;
|
|
}
|
|
- std::string voidsize =
|
|
- this->Makefile->GetSafeDefinition("CMAKE_SIZEOF_VOID_P");
|
|
- int size = atoi(voidsize.c_str());
|
|
- if(size != 8)
|
|
+ if(!this->Makefile->PlatformIs64Bit())
|
|
{
|
|
return;
|
|
}
|
|
@@ -205,6 +208,55 @@ void cmFindLibraryCommand::AddLib64Paths()
|
|
}
|
|
}
|
|
|
|
+void cmFindLibraryCommand::AddLib32Paths()
|
|
+{
|
|
+ if(!this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
|
|
+ GetLanguageEnabled("C"))
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+ if(!this->Makefile->PlatformIs32Bit())
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+ std::vector<std::string> path32;
|
|
+ bool found32 = false;
|
|
+ for(std::vector<std::string>::iterator i = this->SearchPaths.begin();
|
|
+ i != this->SearchPaths.end(); ++i)
|
|
+ {
|
|
+ std::string s = *i;
|
|
+ std::string s2 = *i;
|
|
+ cmSystemTools::ReplaceString(s, "lib/", "lib32/");
|
|
+ // try to replace lib with lib32 and see if it is there,
|
|
+ // then prepend it to the path
|
|
+ // Note that all paths have trailing slashes.
|
|
+ if((s != *i) && cmSystemTools::FileIsDirectory(s.c_str()))
|
|
+ {
|
|
+ path32.push_back(s);
|
|
+ found32 = true;
|
|
+ }
|
|
+ // now just add a 32 to the path name and if it is there,
|
|
+ // add it to the path
|
|
+ s2 += "32/";
|
|
+ if(cmSystemTools::FileIsDirectory(s2.c_str()))
|
|
+ {
|
|
+ found32 = true;
|
|
+ path32.push_back(s2);
|
|
+ }
|
|
+ // now add the original unchanged path
|
|
+ if(cmSystemTools::FileIsDirectory(i->c_str()))
|
|
+ {
|
|
+ path32.push_back(*i);
|
|
+ }
|
|
+ }
|
|
+ // now replace the SearchPaths with the 32 bit converted path
|
|
+ // if any 32 bit paths were discovered
|
|
+ if(found32)
|
|
+ {
|
|
+ this->SearchPaths = path32;
|
|
+ }
|
|
+}
|
|
+
|
|
//----------------------------------------------------------------------------
|
|
std::string cmFindLibraryCommand::FindLibrary()
|
|
{
|
|
diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h
|
|
index 486c2cf..e0dd49d 100644
|
|
--- a/Source/cmFindLibraryCommand.h
|
|
+++ b/Source/cmFindLibraryCommand.h
|
|
@@ -63,6 +63,7 @@ public:
|
|
protected:
|
|
void AddArchitecturePaths(const char* suffix);
|
|
void AddLib64Paths();
|
|
+ void AddLib32Paths();
|
|
std::string FindLibrary();
|
|
private:
|
|
std::string FindNormalLibrary();
|
|
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
|
|
index ef0197a..b0a2985 100644
|
|
--- a/Source/cmFindPackageCommand.cxx
|
|
+++ b/Source/cmFindPackageCommand.cxx
|
|
@@ -66,6 +66,7 @@ cmFindPackageCommand::cmFindPackageCommand()
|
|
this->NoModule = false;
|
|
this->DebugMode = false;
|
|
this->UseLib64Paths = false;
|
|
+ this->UseLib32Paths = false;
|
|
this->PolicyScope = true;
|
|
this->VersionMajor = 0;
|
|
this->VersionMinor = 0;
|
|
@@ -341,6 +342,13 @@ bool cmFindPackageCommand
|
|
{
|
|
this->UseLib64Paths = true;
|
|
}
|
|
+ // Lookup whether lib32 paths should be used.
|
|
+ if(this->Makefile->PlatformIs32Bit() &&
|
|
+ this->Makefile->GetCMakeInstance()
|
|
+ ->GetPropertyAsBool("FIND_LIBRARY_USE_LIB32_PATHS"))
|
|
+ {
|
|
+ this->UseLib32Paths = true;
|
|
+ }
|
|
|
|
// Find the current root path mode.
|
|
this->SelectDefaultRootPathMode();
|
|
@@ -2105,6 +2113,10 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
|
|
{
|
|
common.push_back("lib64");
|
|
}
|
|
+ if(this->UseLib32Paths)
|
|
+ {
|
|
+ common.push_back("lib32");
|
|
+ }
|
|
common.push_back("lib");
|
|
common.push_back("share");
|
|
|
|
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
|
|
index 57aeab9..06edc1a 100644
|
|
--- a/Source/cmFindPackageCommand.h
|
|
+++ b/Source/cmFindPackageCommand.h
|
|
@@ -134,6 +134,7 @@ private:
|
|
bool NoBuilds;
|
|
bool DebugMode;
|
|
bool UseLib64Paths;
|
|
+ bool UseLib32Paths;
|
|
bool PolicyScope;
|
|
std::vector<std::string> Names;
|
|
std::vector<std::string> Configs;
|
|
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
|
|
index c64053a..c6cda07 100644
|
|
--- a/Source/cmMakefile.cxx
|
|
+++ b/Source/cmMakefile.cxx
|
|
@@ -1993,6 +1993,15 @@ bool cmMakefile::PlatformIs64Bit() const
|
|
return false;
|
|
}
|
|
|
|
+bool cmMakefile::PlatformIs32Bit() const
|
|
+{
|
|
+ if(const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P"))
|
|
+ {
|
|
+ return atoi(sizeof_dptr) == 4;
|
|
+ }
|
|
+ return false;
|
|
+}
|
|
+
|
|
bool cmMakefile::CanIWriteThisFile(const char* fileName)
|
|
{
|
|
if ( !this->IsOn("CMAKE_DISABLE_SOURCE_CHANGES") )
|
|
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
|
|
index 8b8a3f8..c16ba71 100644
|
|
--- a/Source/cmMakefile.h
|
|
+++ b/Source/cmMakefile.h
|
|
@@ -588,6 +588,8 @@ public:
|
|
|
|
/** Return whether the target platform is 64-bit. */
|
|
bool PlatformIs64Bit() const;
|
|
+ /** Return whether the target platform is 32-bit. */
|
|
+ bool PlatformIs32Bit() const;
|
|
|
|
/**
|
|
* Get a list of preprocessor define flags.
|
|
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
|
|
index 1e3b018..2bc3eba 100644
|
|
--- a/Source/cmake.cxx
|
|
+++ b/Source/cmake.cxx
|
|
@@ -3365,6 +3365,13 @@ void cmake::DefineProperties(cmake *cm)
|
|
"directories called lib in the search path when building 64-bit "
|
|
"binaries.");
|
|
cm->DefineProperty
|
|
+ ("FIND_LIBRARY_USE_LIB32_PATHS", cmProperty::GLOBAL,
|
|
+ "Whether FIND_LIBRARY should automatically search lib32 directories.",
|
|
+ "FIND_LIBRARY_USE_LIB32_PATHS is a boolean specifying whether the"
|
|
+ " FIND_LIBRARY command should automatically search the lib32 variant of"
|
|
+ " directories called lib in the search path when building 32-bit"
|
|
+ " binaries.");
|
|
+ cm->DefineProperty
|
|
("FIND_LIBRARY_USE_OPENBSD_VERSIONING", cmProperty::GLOBAL,
|
|
"Whether FIND_LIBRARY should find OpenBSD-style shared libraries.",
|
|
"This property is a boolean specifying whether the FIND_LIBRARY "
|