From 94de4b040c7da63f279c5fe2eaf906b8817b057e Mon Sep 17 00:00:00 2001 From: redfish Date: Sat, 27 Aug 2016 18:47:07 -0400 Subject: [PATCH] cmake: pass -static when STATIC=ON on Windows This gets rid of bitmonerod.exe's dependecy on libwindpthreads-1.dll in build on Windows on x86_64 (via MSYS2 default toolchain). With this patch all DLL dependencies are on DLLs in c:\windows\system32. --- CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ac4a2f95..e9285b012 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -430,8 +430,18 @@ else() set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${RELEASE_FLAGS}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${RELEASE_FLAGS}") - if(STATIC AND NOT APPLE AND NOT FREEBSD AND NOT OPENBSD) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") + if(STATIC) + # STATIC already configures most deps to be linked in statically, + # here we make more deps static if the platform permits it + if (MINGW) + # On Windows, this is as close to fully-static as we get: + # this leaves only deps on /c/Windows/system32/*.dll + set(STATIC_FLAGS "-static") + elseif (NOT (APPLE OR FREEBSD OR OPENBSD)) + # On Linux, we don't support fully static build, but these can be static + set(STATIC_FLAGS "-static-libgcc -static-libstdc++") + endif() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${STATIC_FLAGS} ") endif() endif()