From 0376fe4b9becff8de75e81a15c67b40014b19ce3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 22 Mar 2006 11:10:58 -0500 Subject: [PATCH] ENH: Added support for linking to MS .lib libraries in MinGW. --- Modules/Platform/Windows-gcc.cmake | 3 ++- Source/cmLocalGenerator.cxx | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Modules/Platform/Windows-gcc.cmake b/Modules/Platform/Windows-gcc.cmake index dddf614ce..45c72af2f 100644 --- a/Modules/Platform/Windows-gcc.cmake +++ b/Modules/Platform/Windows-gcc.cmake @@ -17,10 +17,11 @@ 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") +SET(CMAKE_EXTRA_LINK_EXTENSIONS ".lib") # MinGW can also link to a MS .lib IF(MINGW) SET(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a") + SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a" ".lib") ENDIF(MINGW) SET(CMAKE_C_CREATE_SHARED_MODULE diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3a8a2f1dd..7a97cb46a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1318,8 +1318,21 @@ cmLocalGenerator::ComputeLinkInformation(cmTarget& target, this->Makefile->GetDefinition("CMAKE_STATIC_LIBRARY_SUFFIX")); orderLibs.AddLinkExtension( this->Makefile->GetDefinition("CMAKE_SHARED_LIBRARY_SUFFIX")); + orderLibs.AddLinkExtension( + this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")); orderLibs.AddLinkExtension( this->Makefile->GetDefinition("CMAKE_LINK_LIBRARY_SUFFIX")); + if(const char* linkSuffixes = + this->Makefile->GetDefinition("CMAKE_EXTRA_LINK_EXTENSIONS")) + { + std::vector linkSuffixVec; + cmSystemTools::ExpandListArgument(linkSuffixes, linkSuffixVec); + for(std::vector::iterator i = linkSuffixVec.begin(); + i != linkSuffixVec.end(); ++i) + { + orderLibs.AddLinkExtension(i->c_str()); + } + } orderLibs.SetLinkInformation(target.GetName(), linkLibraries, linkDirectories);