diff --git a/CMakeLists.txt b/CMakeLists.txt index 77ce1129..a56a0da1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,9 +91,13 @@ set(LIBCORK_SOURCE libcork/src/libcork/posix/exec.c libcork/src/libcork/posix/files.c libcork/src/libcork/posix/process.c - libcork/src/libcork/posix/subprocess.c libcork/src/libcork/pthreads/thread.c ) +if (NOT MINGW) +set(LIBCORK_SOURCE ${LIBCORK_SOURCE} libcork/src/libcork/posix/subprocess.c) +else () +set(LIBCORK_SOURCE ${LIBCORK_SOURCE} libcork/src/libcork/posix/mingw.c) +endif () if (WITH_STATIC) add_library(cork STATIC ${LIBCORK_SOURCE}) @@ -103,6 +107,9 @@ endif () add_library(cork-shared SHARED ${LIBCORK_SOURCE}) target_compile_definitions(cork-shared PUBLIC -DCORK_API=CORK_EXPORT) set_target_properties(cork-shared PROPERTIES OUTPUT_NAME cork) +if (MINGW) +target_link_libraries(cork-shared ws2_32) +endif () set(LIBIPSET_SOURCE libipset/src/libipset/general.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 87171e7b..312dc12a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,10 @@ # redir need linux/* stuff if (LINUX) option(WITH_SS_REDIR "Build ss-redir" ON) + option(WITH_SS_MANAGER "Build ss-manager" ON) else () option(WITH_SS_REDIR "Build ss-redir" OFF) + option(WITH_SS_MANAGER "Build ss-manager" OFF) endif () @@ -29,6 +31,9 @@ set(SS_SHARED_SOURCES json.c netutils.c ) +if (MINGW) +set(SS_SHARED_SOURCES ${SS_SHARED_SOURCES} winsock.c) +endif () set(LIBSHADOWSOCKS_LIBEV_SOURCE ${SS_SHARED_SOURCES} @@ -110,6 +115,9 @@ list(APPEND DEPS ${LIBMBEDTLS} ${LIBMBEDCRYPTO} ) +if (MINGW) +list(APPEND DEPS ws2_32) +endif () endif () find_library(LIBSODIUM_SHARED sodium) @@ -158,7 +166,11 @@ if (WITH_STATIC) # By default we use normal name for static, all shared targets will add a `-shared' suffix add_executable(ss-server ${SS_SERVER_SOURCE}) add_executable(ss-tunnel ${SS_TUNNEL_SOURCE}) -add_executable(ss-manager ${SS_MANAGER_SOURCE}) +if (WITH_SS_MANAGER) + add_executable(ss-manager ${SS_MANAGER_SOURCE}) +else () + add_executable(ss-manager EXCLUDE_FROM_ALL ${SS_MANAGER_SOURCE}) +endif () add_executable(ss-local ${SS_LOCAL_SOURCE}) if (WITH_SS_REDIR) add_executable(ss-redir ${SS_REDIR_SOURCE}) @@ -192,7 +204,11 @@ endif () # For shared binary, we still use the same name as static, without `-shared', but will output to shared directory add_executable(ss-server-shared ${SS_SERVER_SOURCE}) add_executable(ss-tunnel-shared ${SS_TUNNEL_SOURCE}) -add_executable(ss-manager-shared ${SS_MANAGER_SOURCE}) +if (WITH_SS_MANAGER) + add_executable(ss-manager-shared ${SS_MANAGER_SOURCE}) +else () + add_executable(ss-manager-shared EXCLUDE_FROM_ALL ${SS_MANAGER_SOURCE}) +endif () add_executable(ss-local-shared ${SS_LOCAL_SOURCE}) if (WITH_SS_REDIR) add_executable(ss-redir-shared ${SS_REDIR_SOURCE})