-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
123 lines (104 loc) · 3.13 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
cmake_minimum_required(VERSION 3.14)
project(dht)
# require C++17
set(CMAKE_CXX_STANDARD 17)
if ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed.")
endif ()
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(CPM)
include(Tools)
include(CTest)
find_package(Threads REQUIRED)
# pull asio using cpm:
CPMAddPackage(
NAME asio
VERSION 1-18-2
GITHUB_REPOSITORY chriskohlhoff/asio
GIT_TAG asio-1-18-2
)
if (asio_ADDED)
add_library(asio INTERFACE)
target_include_directories(asio
INTERFACE ${asio_SOURCE_DIR}/asio/include
)
target_compile_definitions(asio
INTERFACE
ASIO_STANDALONE
)
target_link_libraries(asio
INTERFACE
Threads::Threads
)
if (WIN32)
# macro see @ https://stackoverflow.com/a/40217291/1746503
macro(get_win32_winnt version)
if (CMAKE_SYSTEM_VERSION)
set(ver ${CMAKE_SYSTEM_VERSION})
string(REGEX MATCH "^([0-9]+).([0-9])" ver ${ver})
string(REGEX MATCH "^([0-9]+)" verMajor ${ver})
if ("${verMajor}" MATCHES "10")
set(verMajor "A")
string(REGEX REPLACE "^([0-9]+)" ${verMajor} ver ${ver})
endif ("${verMajor}" MATCHES "10")
string(REPLACE "." "" ver ${ver})
string(REGEX REPLACE "([0-9A-Z])" "0\\1" ver ${ver})
set(${version} "0x${ver}")
endif ()
endmacro()
if (NOT DEFINED _WIN32_WINNT)
get_win32_winnt(ver)
set(_WIN32_WINNT ${ver})
endif ()
message(STATUS "Set _WIN32_WINNET=${_WIN32_WINNT}")
target_compile_definitions(asio
INTERFACE
_WIN32_WINNT=${_WIN32_WINNT}
WIN32_LEAN_AND_MEAN
)
endif ()
endif ()
# pull cxxopts using cpm:
CPMAddPackage(
NAME cxxopts
VERSION 2.2.1
GITHUB_REPOSITORY jarro2783/cxxopts
OPTIONS "CXXOPTS_BUILD_TESTS OFF"
)
# pull inipp using cpm:
CPMAddPackage(
NAME inipp
VERSION 1.0.13
GITHUB_REPOSITORY MixusMinimax/inipp
GIT_TAG 1.0.13
OPTIONS "BUILD_TESTING OFF"
)
if (inipp_ADDED)
add_library(inipp INTERFACE IMPORTED)
target_include_directories(inipp INTERFACE ${inipp_SOURCE_DIR}/inipp)
endif ()
# pull openssl from github:
CPMAddPackage(
NAME OpenSSL
VERSION 1.1.1f
GITHUB_REPOSITORY MixusMinimax/openssl-cmake
GIT_TAG 1.1.1f-20210430
)
# pull cap'n proto from github:
CPMAddPackage(
NAME capnproto
VERSION 0.10.0
GITHUB_REPOSITORY MixusMinimax/capnproto
OPTIONS "WITH_OPENSSL ON" "BUILD_TESTING OFF" "EXPORT_TARGETS ON"
)
# pull spdlog from github:
CPMAddPackage("gh:gabime/[email protected]")
add_subdirectory(src)
add_subdirectory(src/api)
add_subdirectory(src/config)
add_subdirectory(src/dht)
add_subdirectory(src/entry)
add_subdirectory(src/logging)
add_subdirectory(src/rpc)
add_subdirectory(src/util)
add_subdirectory(test)