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.

138 lines
4.6 KiB

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