From ce71c01f11fa27164d4681396f0ab0d97b04b400 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 18 Nov 2014 17:04:47 -0500 Subject: [PATCH] cmake: work around a bug with implicit link directories Unfortunately, this is necessary because CMake doesn't detect whether mingw libraries are static or shared and doesn't put a -static flag around the -lfoo argument which then makes the shared library be linked to. --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3b517a8b..ebca5c6fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,14 @@ option(STATIC "Link libraries statically" ${DEFAULT_STATIC}) if(MINGW) get_filename_component(msys2_install_path "[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MSYS2 64bit;InstallLocation]" ABSOLUTE) set(CMAKE_INCLUDE_PATH "${msys2_install_path}/mingw64/include") + # This is necessary because otherwise CMake will make Boost libraries -lfoo + # rather than a full path. Unfortunately, this makes the shared libraries get + # linked due to a bug in CMake which misses putting -static flags around the + # -lfoo arguments. + list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_DIRECTORIES + "${msys2_install_path}/mingw64/lib") + list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES + "${msys2_install_path}/mingw64/lib") endif() if(STATIC)