diff options
-rw-r--r-- | Modules/CMakeGenericSystem.cmake | 3 | ||||
-rw-r--r-- | Modules/Platform/CYGWIN.cmake | 3 | ||||
-rw-r--r-- | Modules/Platform/Darwin.cmake | 1 | ||||
-rw-r--r-- | Modules/Platform/HP-UX.cmake | 1 | ||||
-rw-r--r-- | Modules/Platform/Windows-bcc32.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/Windows-gcc.cmake | 5 | ||||
-rw-r--r-- | Modules/Platform/Windows.cmake | 3 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 50 |
8 files changed, 44 insertions, 24 deletions
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index fc2b95d..1ea6e36 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -22,6 +22,9 @@ IF(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") # -pic 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 "If set, runtime paths are not added when using shared libraries.") diff --git a/Modules/Platform/CYGWIN.cmake b/Modules/Platform/CYGWIN.cmake index 7fd6615..cfd1fb0 100644 --- a/Modules/Platform/CYGWIN.cmake +++ b/Modules/Platform/CYGWIN.cmake @@ -6,3 +6,6 @@ SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe + +SET(CMAKE_FIND_LIBRARY_PREFIXES "cyg" "lib") +SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a") diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index 74caf0b..f6e5946 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -6,6 +6,7 @@ SET(CMAKE_MODULE_EXISTS 1) SET(CMAKE_DL_LIBS "") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib") SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle") +SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a") IF("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$") SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake index b2b9e03..6b31509 100644 --- a/Modules/Platform/HP-UX.cmake +++ b/Modules/Platform/HP-UX.cmake @@ -1,5 +1,6 @@ SET(CMAKE_SHARED_LIBRARY_SUFFIX ".sl") # .so SET(CMAKE_DL_LIBS "-ldld") +SET(CMAKE_FIND_LIBRARY_SUFFIXES ".sl" ".so" ".a") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty diff --git a/Modules/Platform/Windows-bcc32.cmake b/Modules/Platform/Windows-bcc32.cmake index 72d86b7..f265c64 100644 --- a/Modules/Platform/Windows-bcc32.cmake +++ b/Modules/Platform/Windows-bcc32.cmake @@ -16,6 +16,8 @@ SET(CMAKE_SHARED_BUILD_CXX_FLAGS "-tWR") SET(CMAKE_SHARED_BUILD_C_FLAGS "-tWR") SET(BORLAND 1) +SET(CMAKE_FIND_LIBRARY_SUFFIXES "-bcc.lib" ".lib") + # uncomment these out to debug makefiles #SET(CMAKE_START_TEMP_FILE "") #SET(CMAKE_END_TEMP_FILE "") diff --git a/Modules/Platform/Windows-gcc.cmake b/Modules/Platform/Windows-gcc.cmake index 949cc56..779d1e5 100644 --- a/Modules/Platform/Windows-gcc.cmake +++ b/Modules/Platform/Windows-gcc.cmake @@ -15,3 +15,8 @@ SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") # -rpath SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty SET(CMAKE_LIBRARY_PATH_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) diff --git a/Modules/Platform/Windows.cmake b/Modules/Platform/Windows.cmake index 163d3f6..a79a489 100644 --- a/Modules/Platform/Windows.cmake +++ b/Modules/Platform/Windows.cmake @@ -6,6 +6,9 @@ SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe SET(CMAKE_LINK_LIBRARY_SUFFIX ".lib") 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 # with the following syntax, see Windows-bcc32.cmake for use IF(CMAKE_GENERATOR MATCHES "Borland") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4eae622..d8ba05a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2310,17 +2310,16 @@ std::string cmMakefile::FindLibrary(const char* name, return cmSystemTools::CollapseFullPath(name); } - // Construct a list of possible suffixes. - const char* windows_suffixes[] = {".lib", 0}; - const char* unix_suffixes[] = {".so", ".sl", ".dylib", ".a", - ".dll", ".dll.a", 0}; - bool windowsLibs = false; - if(cmSystemTools::IsOn(this->GetDefinition("WIN32")) && - !cmSystemTools::IsOn(this->GetDefinition("CYGWIN")) && - !cmSystemTools::IsOn(this->GetDefinition("MINGW"))) - { - windowsLibs = true; - } + // Get the list of possible prefixes and suffixes for libraries on + // this platform. + const char* prefixes_list = + this->GetRequiredDefinition("CMAKE_FIND_LIBRARY_PREFIXES"); + const char* suffixes_list = + this->GetRequiredDefinition("CMAKE_FIND_LIBRARY_SUFFIXES"); + std::vector<std::string> prefixes; + std::vector<std::string> suffixes; + cmSystemTools::ExpandListArgument(prefixes_list, prefixes); + cmSystemTools::ExpandListArgument(suffixes_list, suffixes); std::string tryPath; 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. - const char* prefix = windowsLibs? "" : "lib"; - const char** suffixes = windowsLibs? windows_suffixes : unix_suffixes; - for(const char** suffix = suffixes; *suffix; ++suffix) + for(std::vector<std::string>::iterator prefix = prefixes.begin(); + prefix != prefixes.end(); ++prefix) { - tryPath = *p; - tryPath += "/"; - tryPath += prefix; - tryPath += name; - tryPath += *suffix; - if(cmSystemTools::FileExists(tryPath.c_str()) - && !cmSystemTools::FileIsDirectory(tryPath.c_str())) + for(std::vector<std::string>::iterator suffix = suffixes.begin(); + suffix != suffixes.end(); ++suffix) { - tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); - cmSystemTools::ConvertToUnixSlashes(tryPath); - return tryPath; + tryPath = *p; + 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; + } } } } |