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)