You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
4.6 KiB

7 years ago
  1. cmake_minimum_required(VERSION 3.2)
  2. set(PROJECT_NAME shadowsocks-libev)
  3. set(RELEASE_DATE 2017-11-20)
  4. set(PROJECT_VERSION "3.1.1")
  5. set(PROJECT_DESC "a lightweight secured socks5 proxy")
  6. set(PROJECT_URL "https://shadowsocks.org")
  7. set(PROJECT_ISSUES_URL "https://github.com/shadowsocks/shadowsocks-libev")
  8. project(${PROJECT_NAME})
  9. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
  10. #set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/out)
  11. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
  12. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
  13. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
  14. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
  15. set(RUNTIME_SHARED_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/shared/bin)
  16. set(CMAKE_MACOSX_RPATH TRUE)
  17. if (NOT CMAKE_BUILD_TYPE)
  18. set(CMAKE_BUILD_TYPE Debug)
  19. endif ()
  20. # Detect linux
  21. if (UNIX AND NOT APPLE)
  22. set(LINUX TRUE)
  23. endif ()
  24. message(STATUS "Running cmake version ${CMAKE_VERSION}")
  25. option(WITH_STATIC "build with static libraries." ON)
  26. # Will set GIT_EXECUTABLE and GIT_FOUND
  27. # find_package(Git)
  28. # Run platform tests
  29. include(${CMAKE_SOURCE_DIR}/cmake/configure.cmake)
  30. configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake ${CMAKE_BINARY_DIR}/src/config.h)
  31. add_definitions(-I$(CMAKE_BINARY_DIR)/src)
  32. add_definitions(-DHAVE_CONFIG_H)
  33. # pkg-config
  34. configure_file(
  35. ${CMAKE_SOURCE_DIR}/cmake/shadowsocks-libev.pc.cmake
  36. ${CMAKE_BINARY_DIR}/pkgconfig/shadowsocks-libev.pc
  37. @ONLY
  38. )
  39. install(FILES
  40. ${CMAKE_BINARY_DIR}/pkgconfig/shadowsocks-libev.pc
  41. DESTINATION pkgconfig
  42. )
  43. # We need libcork,libipset headers
  44. include_directories(libcork/include)
  45. include_directories(libipset/include)
  46. include_directories(libbloom/murmur2)
  47. include_directories(libbloom)
  48. set(LIBCORK_SOURCE
  49. libcork/src/libcork/cli/commands.c
  50. libcork/src/libcork/core/allocator.c
  51. libcork/src/libcork/core/error.c
  52. libcork/src/libcork/core/gc.c
  53. libcork/src/libcork/core/hash.c
  54. libcork/src/libcork/core/ip-address.c
  55. libcork/src/libcork/core/mempool.c
  56. libcork/src/libcork/core/timestamp.c
  57. libcork/src/libcork/core/u128.c
  58. libcork/src/libcork/core/version.c
  59. libcork/src/libcork/ds/array.c
  60. libcork/src/libcork/ds/bitset.c
  61. libcork/src/libcork/ds/buffer.c
  62. libcork/src/libcork/ds/dllist.c
  63. libcork/src/libcork/ds/file-stream.c
  64. libcork/src/libcork/ds/hash-table.c
  65. libcork/src/libcork/ds/managed-buffer.c
  66. libcork/src/libcork/ds/ring-buffer.c
  67. libcork/src/libcork/ds/slice.c
  68. libcork/src/libcork/posix/directory-walker.c
  69. libcork/src/libcork/posix/env.c
  70. libcork/src/libcork/posix/exec.c
  71. libcork/src/libcork/posix/files.c
  72. libcork/src/libcork/posix/process.c
  73. libcork/src/libcork/posix/subprocess.c
  74. libcork/src/libcork/pthreads/thread.c
  75. )
  76. if (WITH_STATIC)
  77. add_library(cork STATIC ${LIBCORK_SOURCE})
  78. target_compile_definitions(cork PUBLIC -DCORK_API=CORK_LOCAL)
  79. endif ()
  80. add_library(cork-shared SHARED ${LIBCORK_SOURCE})
  81. target_compile_definitions(cork-shared PUBLIC -DCORK_API=CORK_EXPORT)
  82. set_target_properties(cork-shared PROPERTIES OUTPUT_NAME cork)
  83. set(LIBIPSET_SOURCE
  84. libipset/src/libipset/general.c
  85. libipset/src/libipset/bdd/assignments.c
  86. libipset/src/libipset/bdd/basics.c
  87. libipset/src/libipset/bdd/bdd-iterator.c
  88. libipset/src/libipset/bdd/expanded.c
  89. libipset/src/libipset/bdd/reachable.c
  90. libipset/src/libipset/bdd/read.c
  91. libipset/src/libipset/bdd/write.c
  92. libipset/src/libipset/map/allocation.c
  93. libipset/src/libipset/map/inspection.c
  94. libipset/src/libipset/map/ipv4_map.c
  95. libipset/src/libipset/map/ipv6_map.c
  96. libipset/src/libipset/map/storage.c
  97. libipset/src/libipset/set/allocation.c
  98. libipset/src/libipset/set/inspection.c
  99. libipset/src/libipset/set/ipv4_set.c
  100. libipset/src/libipset/set/ipv6_set.c
  101. libipset/src/libipset/set/iterator.c
  102. libipset/src/libipset/set/storage.c
  103. )
  104. if (WITH_STATIC)
  105. add_library(ipset STATIC ${LIBIPSET_SOURCE})
  106. endif ()
  107. add_library(ipset-shared SHARED ${LIBIPSET_SOURCE})
  108. set_target_properties(ipset-shared PROPERTIES OUTPUT_NAME ipset)
  109. set(LIBBLOOM_SOURCE
  110. libbloom/bloom.c
  111. libbloom/murmur2/MurmurHash2.c
  112. )
  113. if (WITH_STATIC)
  114. add_library(bloom STATIC ${LIBBLOOM_SOURCE})
  115. target_link_libraries(ipset cork bloom)
  116. endif ()
  117. add_library(bloom-shared SHARED ${LIBBLOOM_SOURCE})
  118. target_link_libraries(ipset-shared cork-shared bloom-shared)
  119. set_target_properties(bloom-shared PROPERTIES OUTPUT_NAME bloom)
  120. add_subdirectory(src)
  121. add_subdirectory(doc)