mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-19 03:53:44 +00:00
Rename the project to shadowsocks-c while retaining ss-* commands, the embedding ABI, and legacy library/package lookup compatibility.
Replace libev with bundled libuv for IOCP/kqueue event backends, expand asynchronous runtime DNS coverage, and add actionlint/Ruff with strict clang-tidy failure handling. Validate native platforms, static builds, packaging, interoperability, sanitizers, and canonical/legacy consumers.
All 22 hosted checks pass at reviewed head a8493250eb.
69 lines
2.7 KiB
CMake
69 lines
2.7 KiB
CMake
set(SS_DEPENDENCY_MODE "bundled" CACHE STRING "Dependency source: bundled or system")
|
|
set_property(CACHE SS_DEPENDENCY_MODE PROPERTY STRINGS bundled system)
|
|
set(SS_MATH_LIBRARY "")
|
|
if(NOT WIN32)
|
|
set(SS_MATH_LIBRARY m)
|
|
endif()
|
|
find_package(Threads REQUIRED)
|
|
if(SS_DEPENDENCY_MODE STREQUAL "bundled")
|
|
if(NOT WITH_STATIC)
|
|
message(FATAL_ERROR "Bundled mode requires WITH_STATIC=ON; use system mode for shared dependencies")
|
|
endif()
|
|
add_subdirectory(third_party)
|
|
return()
|
|
elseif(NOT SS_DEPENDENCY_MODE STREQUAL "system")
|
|
message(FATAL_ERROR "SS_DEPENDENCY_MODE must be bundled or system")
|
|
endif()
|
|
if(WIN32)
|
|
message(FATAL_ERROR "Windows requires bundled dependencies: the bundled libuv configuration is the validated Windows build")
|
|
endif()
|
|
|
|
# Select one linkage mode consistently for programs, libraries, and tests.
|
|
# Never require shared copies in a static dependency build.
|
|
if(WITH_STATIC)
|
|
set(_ss_saved_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
|
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
|
|
endif()
|
|
if(SS_ENABLE_REGEX)
|
|
find_package(PCRE2 REQUIRED)
|
|
endif()
|
|
find_package(MbedTLS REQUIRED)
|
|
find_package(Sodium REQUIRED)
|
|
find_package(Cares REQUIRED)
|
|
find_path(LIBUV_INCLUDE_DIR uv.h REQUIRED)
|
|
find_library(LIBUV_LIBRARY NAMES uv REQUIRED)
|
|
find_package(Threads REQUIRED)
|
|
if(WITH_STATIC)
|
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_ss_saved_suffixes})
|
|
endif()
|
|
|
|
function(ss_import_dependency target location includes)
|
|
add_library(${target} UNKNOWN IMPORTED GLOBAL)
|
|
set_target_properties(${target} PROPERTIES
|
|
IMPORTED_LOCATION "${location}"
|
|
INTERFACE_INCLUDE_DIRECTORIES "${includes}")
|
|
endfunction()
|
|
ss_import_dependency(ss_sodium "${SODIUM_LIBRARY}" "${SODIUM_INCLUDE_DIRS}")
|
|
ss_import_dependency(ss_mbedcrypto "${MBEDTLS_CRYPTO_LIBRARY}" "${MBEDTLS_INCLUDE_DIRS}")
|
|
ss_import_dependency(ss_cares "${CARES_LIBRARY}" "${CARES_INCLUDE_DIRS}")
|
|
if(SS_ENABLE_REGEX)
|
|
ss_import_dependency(ss_pcre2 "${PCRE2_LIBRARY}" "${PCRE2_INCLUDE_DIRS}")
|
|
endif()
|
|
ss_import_dependency(ss_uv "${LIBUV_LIBRARY}" "${LIBUV_INCLUDE_DIR}")
|
|
include(${PROJECT_SOURCE_DIR}/cmake/EventLoop.cmake)
|
|
if(WIN32)
|
|
set_property(TARGET ss_cares APPEND PROPERTY INTERFACE_LINK_LIBRARIES ws2_32 iphlpapi)
|
|
set_property(TARGET ss_ev APPEND PROPERTY INTERFACE_LINK_LIBRARIES ws2_32)
|
|
if(WITH_STATIC)
|
|
set_property(TARGET ss_cares APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS CARES_STATICLIB)
|
|
if(SS_ENABLE_REGEX)
|
|
set_property(TARGET ss_pcre2 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS PCRE2_STATIC)
|
|
endif()
|
|
set_property(TARGET ss_sodium APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS SODIUM_STATIC)
|
|
endif()
|
|
endif()
|
|
set(SS_MATH_LIBRARY "")
|
|
if(NOT WIN32)
|
|
set(SS_MATH_LIBRARY m)
|
|
endif()
|