From 45122c12c5c40350f0e284b6af928e1790267e21 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 30 Sep 2021 22:42:16 +0200 Subject: [PATCH] Link libwinpthread statically if LINK_STD_STATICALLY is on. --- angelscript/projects/cmake/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/angelscript/projects/cmake/CMakeLists.txt b/angelscript/projects/cmake/CMakeLists.txt index a35fad6..2c768b5 100644 --- a/angelscript/projects/cmake/CMakeLists.txt +++ b/angelscript/projects/cmake/CMakeLists.txt @@ -164,8 +164,14 @@ endif() if (LINK_STD_STATICALLY) message(STATUS "Linking std libraries statically") - set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed") - target_link_libraries(${ANGELSCRIPT_LIBRARY_NAME} -lpthread -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ ) + set(as_LINKS -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++) + if (MSVC) + set(as_LINKS "${as_LINKS} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive") + else() + set(as_LINKS "${as_LINKS} -Wl,-Bdynamic -lpthread") + endif(MSVC) + message(STATUS "Angelscript LINKS ${as_LINKS}") + target_link_libraries(${ANGELSCRIPT_LIBRARY_NAME} ${as_LINKS}) else() set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED)