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.

131 lines
4.4 KiB

7 years ago
  1. cmake_minimum_required(VERSION 2.8)
  2. set(PROJECT_NAME shadowsocks-libev)
  3. set(RELEASE_DATE 2017-3-16)
  4. set(PROJECT_VERSION "3.0.4")
  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(CMAKE_MACOSX_RPATH TRUE)
  16. if (NOT CMAKE_BUILD_TYPE)
  17. set(CMAKE_BUILD_TYPE Debug)
  18. endif ()
  19. # Detect linux
  20. if (UNIX AND NOT APPLE)
  21. set(LINUX TRUE)
  22. endif ()
  23. message(STATUS "Running cmake version ${CMAKE_VERSION}")
  24. # Will set GIT_EXECUTABLE and GIT_FOUND
  25. # find_package(Git)
  26. # Run platform tests
  27. include(${CMAKE_SOURCE_DIR}/cmake/configure.cmake)
  28. configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake ${CMAKE_SOURCE_DIR}/src/config.h)
  29. add_definitions(-DHAVE_CONFIG_H)
  30. # pkg-config
  31. configure_file(
  32. "${CMAKE_SOURCE_DIR}/cmake/shadowsocks-libev.pc.cmake"
  33. "${CMAKE_BINARY_DIR}/pkgconfig/shadowsocks-libev.pc"
  34. @ONLY
  35. )
  36. install(FILES
  37. "${CMAKE_BINARY_DIR}/pkgconfig/shadowsocks-libev.pc"
  38. DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
  39. )
  40. # We need libcork,libipset headers
  41. include_directories(libcork/include)
  42. include_directories(libipset/include)
  43. include_directories(libbloom/murmur2)
  44. include_directories(libbloom)
  45. set(LIBCORK_SOURCE
  46. libcork/src/libcork/cli/commands.c
  47. libcork/src/libcork/core/allocator.c
  48. libcork/src/libcork/core/error.c
  49. libcork/src/libcork/core/gc.c
  50. libcork/src/libcork/core/hash.c
  51. libcork/src/libcork/core/ip-address.c
  52. libcork/src/libcork/core/mempool.c
  53. libcork/src/libcork/core/timestamp.c
  54. libcork/src/libcork/core/u128.c
  55. libcork/src/libcork/core/version.c
  56. libcork/src/libcork/ds/array.c
  57. libcork/src/libcork/ds/bitset.c
  58. libcork/src/libcork/ds/buffer.c
  59. libcork/src/libcork/ds/dllist.c
  60. libcork/src/libcork/ds/file-stream.c
  61. libcork/src/libcork/ds/hash-table.c
  62. libcork/src/libcork/ds/managed-buffer.c
  63. libcork/src/libcork/ds/ring-buffer.c
  64. libcork/src/libcork/ds/slice.c
  65. libcork/src/libcork/posix/directory-walker.c
  66. libcork/src/libcork/posix/env.c
  67. libcork/src/libcork/posix/exec.c
  68. libcork/src/libcork/posix/files.c
  69. libcork/src/libcork/posix/process.c
  70. libcork/src/libcork/posix/subprocess.c
  71. libcork/src/libcork/pthreads/thread.c
  72. )
  73. add_library(cork STATIC ${LIBCORK_SOURCE})
  74. target_compile_definitions(cork PUBLIC -DCORK_API=CORK_LOCAL)
  75. add_library(cork-shared SHARED ${LIBCORK_SOURCE})
  76. target_compile_definitions(cork-shared PUBLIC -DCORK_API=CORK_EXPORT)
  77. set_target_properties(cork-shared PROPERTIES OUTPUT_NAME cork)
  78. set(LIBIPSET_SOURCE
  79. libipset/src/libipset/general.c
  80. libipset/src/libipset/bdd/assignments.c
  81. libipset/src/libipset/bdd/basics.c
  82. libipset/src/libipset/bdd/bdd-iterator.c
  83. libipset/src/libipset/bdd/expanded.c
  84. libipset/src/libipset/bdd/reachable.c
  85. libipset/src/libipset/bdd/read.c
  86. libipset/src/libipset/bdd/write.c
  87. libipset/src/libipset/map/allocation.c
  88. libipset/src/libipset/map/inspection.c
  89. libipset/src/libipset/map/ipv4_map.c
  90. libipset/src/libipset/map/ipv6_map.c
  91. libipset/src/libipset/map/storage.c
  92. libipset/src/libipset/set/allocation.c
  93. libipset/src/libipset/set/inspection.c
  94. libipset/src/libipset/set/ipv4_set.c
  95. libipset/src/libipset/set/ipv6_set.c
  96. libipset/src/libipset/set/iterator.c
  97. libipset/src/libipset/set/storage.c
  98. )
  99. add_library(ipset STATIC ${LIBIPSET_SOURCE})
  100. add_library(ipset-shared SHARED ${LIBIPSET_SOURCE})
  101. set_target_properties(ipset-shared PROPERTIES OUTPUT_NAME ipset)
  102. set(LIBBLOOM_SOURCE
  103. libbloom/bloom.c
  104. libbloom/murmur2/MurmurHash2.c
  105. )
  106. add_library(bloom STATIC ${LIBBLOOM_SOURCE})
  107. target_link_libraries(ipset cork bloom)
  108. add_library(bloom-shared SHARED ${LIBBLOOM_SOURCE})
  109. target_link_libraries(ipset-shared cork-shared bloom-shared)
  110. set_target_properties(bloom-shared PROPERTIES OUTPUT_NAME bloom)
  111. add_subdirectory(src)