diff options
author | Brad King <brad.king@kitware.com> | 2006-02-07 22:09:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-02-07 22:09:41 (GMT) |
commit | 9163af8745eb152082b4b00645f07cd4df8a1107 (patch) | |
tree | 68a6ed7d04e47890f23c24ec6204d3592863de55 /Source | |
parent | 53564358cade9ae184f8ae9e13a4c1eb879c782f (diff) | |
download | CMake-9163af8745eb152082b4b00645f07cd4df8a1107.zip CMake-9163af8745eb152082b4b00645f07cd4df8a1107.tar.gz CMake-9163af8745eb152082b4b00645f07cd4df8a1107.tar.bz2 |
BUG: Fixed finding of MinGW libraries with a windows build of CMake.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmMakefile.cxx | 69 |
1 files changed, 63 insertions, 6 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4fb853b..772d6e6 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2296,14 +2296,71 @@ std::string cmMakefile::FindLibrary(const char* name, } } // now look for the library in the 64 bit path - std::string tmp = cmSystemTools::FindLibrary(name, path64); - cmSystemTools::ConvertToUnixSlashes(tmp); - return tmp; + path = path64; } } - std::string tmp = cmSystemTools::FindLibrary(name, path); - cmSystemTools::ConvertToUnixSlashes(tmp); - return tmp; + + // See if the library exists as written. + if(cmSystemTools::FileExists(name) && + !cmSystemTools::FileIsDirectory(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; + } + + std::string tryPath; + for(std::vector<std::string>::const_iterator p = path.begin(); + p != path.end(); ++p) + { + // Look for a framework. + if(supportFrameworks) + { + tryPath = *p; + tryPath += "/"; + tryPath += name; + tryPath += ".framework"; + if(cmSystemTools::FileExists(tryPath.c_str()) + && cmSystemTools::FileIsDirectory(tryPath.c_str())) + { + tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); + cmSystemTools::ConvertToUnixSlashes(tryPath); + return tryPath; + } + } + + // 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) + { + 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; + } + } + } + + // Couldn't find the library. + return ""; } //---------------------------------------------------------------------------- |