ENH: Added platform settings CMAKE_FIND_LIBRARY_PREFIXES and CMAKE_FIND_LIBRARY_SUFFIXES to allow customized searching for libraries.

This commit is contained in:
Brad King 2006-02-09 15:05:13 -05:00
parent 0ddf06e952
commit 33587ce376
8 changed files with 44 additions and 24 deletions

View File

@ -22,6 +22,9 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") # -pic SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") # -pic
ENDIF(CMAKE_COMPILER_IS_GNUCXX) ENDIF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_FIND_LIBRARY_PREFIXES "lib")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
SET (CMAKE_SKIP_RPATH "NO" CACHE BOOL SET (CMAKE_SKIP_RPATH "NO" CACHE BOOL
"If set, runtime paths are not added when using shared libraries.") "If set, runtime paths are not added when using shared libraries.")

View File

@ -6,3 +6,6 @@ SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "")
SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe
SET(CMAKE_FIND_LIBRARY_PREFIXES "cyg" "lib")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a")

View File

@ -6,6 +6,7 @@ SET(CMAKE_MODULE_EXISTS 1)
SET(CMAKE_DL_LIBS "") SET(CMAKE_DL_LIBS "")
SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib")
SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle") SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
IF("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$") IF("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$")
SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS

View File

@ -1,5 +1,6 @@
SET(CMAKE_SHARED_LIBRARY_SUFFIX ".sl") # .so SET(CMAKE_SHARED_LIBRARY_SUFFIX ".sl") # .so
SET(CMAKE_DL_LIBS "-ldld") SET(CMAKE_DL_LIBS "-ldld")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".sl" ".so" ".a")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty

View File

@ -16,6 +16,8 @@ SET(CMAKE_SHARED_BUILD_CXX_FLAGS "-tWR")
SET(CMAKE_SHARED_BUILD_C_FLAGS "-tWR") SET(CMAKE_SHARED_BUILD_C_FLAGS "-tWR")
SET(BORLAND 1) SET(BORLAND 1)
SET(CMAKE_FIND_LIBRARY_SUFFIXES "-bcc.lib" ".lib")
# uncomment these out to debug makefiles # uncomment these out to debug makefiles
#SET(CMAKE_START_TEMP_FILE "") #SET(CMAKE_START_TEMP_FILE "")
#SET(CMAKE_END_TEMP_FILE "") #SET(CMAKE_END_TEMP_FILE "")

View File

@ -15,3 +15,8 @@ SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") # -rpath
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty
SET(CMAKE_LIBRARY_PATH_FLAG "-L") SET(CMAKE_LIBRARY_PATH_FLAG "-L")
SET(CMAKE_LINK_LIBRARY_FLAG "-l") SET(CMAKE_LINK_LIBRARY_FLAG "-l")
IF(MINGW)
SET(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a")
ENDIF(MINGW)

View File

@ -6,6 +6,9 @@ SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe
SET(CMAKE_LINK_LIBRARY_SUFFIX ".lib") SET(CMAKE_LINK_LIBRARY_SUFFIX ".lib")
SET(CMAKE_DL_LIBS "") SET(CMAKE_DL_LIBS "")
SET(CMAKE_FIND_LIBRARY_PREFIXES "")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
# for borland make long command lines are redirected to a file # for borland make long command lines are redirected to a file
# with the following syntax, see Windows-bcc32.cmake for use # with the following syntax, see Windows-bcc32.cmake for use
IF(CMAKE_GENERATOR MATCHES "Borland") IF(CMAKE_GENERATOR MATCHES "Borland")

View File

@ -2310,17 +2310,16 @@ std::string cmMakefile::FindLibrary(const char* name,
return cmSystemTools::CollapseFullPath(name); return cmSystemTools::CollapseFullPath(name);
} }
// Construct a list of possible suffixes. // Get the list of possible prefixes and suffixes for libraries on
const char* windows_suffixes[] = {".lib", 0}; // this platform.
const char* unix_suffixes[] = {".so", ".sl", ".dylib", ".a", const char* prefixes_list =
".dll", ".dll.a", 0}; this->GetRequiredDefinition("CMAKE_FIND_LIBRARY_PREFIXES");
bool windowsLibs = false; const char* suffixes_list =
if(cmSystemTools::IsOn(this->GetDefinition("WIN32")) && this->GetRequiredDefinition("CMAKE_FIND_LIBRARY_SUFFIXES");
!cmSystemTools::IsOn(this->GetDefinition("CYGWIN")) && std::vector<std::string> prefixes;
!cmSystemTools::IsOn(this->GetDefinition("MINGW"))) std::vector<std::string> suffixes;
{ cmSystemTools::ExpandListArgument(prefixes_list, prefixes);
windowsLibs = true; cmSystemTools::ExpandListArgument(suffixes_list, suffixes);
}
std::string tryPath; std::string tryPath;
for(std::vector<std::string>::const_iterator p = path.begin(); for(std::vector<std::string>::const_iterator p = path.begin();
@ -2343,21 +2342,24 @@ std::string cmMakefile::FindLibrary(const char* name,
} }
// Try various library naming conventions. // Try various library naming conventions.
const char* prefix = windowsLibs? "" : "lib"; for(std::vector<std::string>::iterator prefix = prefixes.begin();
const char** suffixes = windowsLibs? windows_suffixes : unix_suffixes; prefix != prefixes.end(); ++prefix)
for(const char** suffix = suffixes; *suffix; ++suffix)
{ {
tryPath = *p; for(std::vector<std::string>::iterator suffix = suffixes.begin();
tryPath += "/"; suffix != suffixes.end(); ++suffix)
tryPath += prefix;
tryPath += name;
tryPath += *suffix;
if(cmSystemTools::FileExists(tryPath.c_str())
&& !cmSystemTools::FileIsDirectory(tryPath.c_str()))
{ {
tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); tryPath = *p;
cmSystemTools::ConvertToUnixSlashes(tryPath); tryPath += "/";
return tryPath; tryPath += *prefix;
tryPath += name;
tryPath += *suffix;
if(cmSystemTools::FileExists(tryPath.c_str())
&& !cmSystemTools::FileIsDirectory(tryPath.c_str()))
{
tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
cmSystemTools::ConvertToUnixSlashes(tryPath);
return tryPath;
}
} }
} }
} }