From f38bfa14b5e0ca20e48f91128eb05226dd73c54e Mon Sep 17 00:00:00 2001 From: Phillip Chang Date: Thu, 11 Apr 2019 03:32:09 +0900 Subject: [PATCH] linker flags for MinGW - must statically link with libc++ and libwinpthread --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2d6fa8..7d8af2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,10 @@ endif(CCACHE_FOUND) set(CMAKE_CXX_STANDARD 14) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) +if(MINGW) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,-Bdynamic,--whole-archive") +endif(MINGW) set(ALTLIB_DIR ${PROJECT_SOURCE_DIR}/deps/altlib) add_subdirectory(${ALTLIB_DIR})