forked from h128/PhantomChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDependencies.cmake
More file actions
140 lines (118 loc) · 4.19 KB
/
Copy pathDependencies.cmake
File metadata and controls
140 lines (118 loc) · 4.19 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
include(cmake/CPM.cmake)
include(FetchContent)
# Done as a function so that updates to variables like
# CMAKE_CXX_FLAGS don't propagate out to other
# targets
function(phantomchat_setup_dependencies)
# For each dependency, see if it's
# already been provided to us by a parent project
if(NOT TARGET fmtlib::fmtlib)
cpmaddpackage("gh:fmtlib/fmt#12.1.0")
endif()
if(NOT TARGET CLI11::CLI11)
cpmaddpackage("gh:CLIUtils/CLI11#v2.6.2")
endif()
if(NOT TARGET nlohmann_json::nlohmann_json)
CPMAddPackage(
NAME nlohmann_json
GITHUB_REPOSITORY nlohmann/json
VERSION 3.12.0)
endif()
if(NOT TARGET spdlog::spdlog)
cpmaddpackage(
NAME
spdlog
VERSION
1.17.0
GITHUB_REPOSITORY
"gabime/spdlog"
OPTIONS
"SPDLOG_FMT_EXTERNAL ON")
endif()
if(NOT TARGET Catch2::Catch2WithMain)
cpmaddpackage("gh:catchorg/Catch2@3.13.0")
endif()
if(NOT TARGET myZlib)
FetchContent_Declare(
zlib_content
GIT_REPOSITORY https://github.com/madler/zlib.git
GIT_TAG v1.3.2
)
FetchContent_MakeAvailable(zlib_content)
file(GLOB_RECURSE zlibSources CONFIGURE_DEPENDS
${zlib_content_SOURCE_DIR}/*.c
)
list(FILTER zlibSources EXCLUDE REGEX ".*/contrib/.*")
add_library(myZlib STATIC ${zlibSources})
target_include_directories(myZlib PUBLIC ${zlib_content_SOURCE_DIR})
endif()
if(NOT TARGET uSockets)
FetchContent_Declare(
uSockets_content
GIT_REPOSITORY https://github.com/uNetworking/uSockets.git
GIT_TAG v0.8.8
)
FetchContent_MakeAvailable(uSockets_content)
# If FetchContent failed or variable is empty, set manually
if(NOT uSockets_content_SOURCE_DIR OR uSockets_content_SOURCE_DIR STREQUAL "")
set(uSockets_content_SOURCE_DIR "build/_deps/usockets_content-src")
set(uSockets_content_BINARY_DIR "build/_deps/usockets_content-build")
endif()
message(STATUS "uSockets source dir: ${uSockets_content_SOURCE_DIR}")
file(GLOB_RECURSE uSocketsSources ${uSockets_content_SOURCE_DIR}/src/*.c ${uSockets_content_SOURCE_DIR}/src/*.cpp)
add_library(uSockets STATIC ${uSocketsSources})
target_include_directories(uSockets PUBLIC ${uSockets_content_SOURCE_DIR}/src)
set(OPENSSL_USE_STATIC_LIBS TRUE)
find_package(OpenSSL REQUIRED)
find_package(Threads REQUIRED)
target_compile_definitions(uSockets PRIVATE LIBUS_USE_OPENSSL)
target_link_libraries(uSockets PRIVATE OpenSSL::SSL OpenSSL::Crypto ${CMAKE_DL_LIBS} Threads::Threads)
endif()
if(NOT TARGET uWS)
FetchContent_Declare(
uWebSockets_content
GIT_REPOSITORY https://github.com/uNetworking/uWebSockets.git
GIT_TAG v20.76.0
)
FetchContent_MakeAvailable(uWebSockets_content)
if(NOT uWebSockets_content_SOURCE_DIR OR uWebSockets_content_SOURCE_DIR STREQUAL "")
set(uWebSockets_content_SOURCE_DIR "build/_deps/uwebsockets_content-src")
set(uWebSockets_content_BINARY_DIR "build/_deps/uwebsockets_content-build")
endif()
# Create interface library for uWebSockets (header-only)
add_library(uWS INTERFACE)
target_include_directories(uWS INTERFACE ${uWebSockets_content_SOURCE_DIR}/src)
target_link_libraries(uWS INTERFACE uSockets myZlib)
endif()
if(NOT TARGET sodium)
CPMAddPackage(
NAME sodium
GITHUB_REPOSITORY robinlinden/libsodium-cmake
GIT_TAG cfebfd3da486d5a86c644c8b47067e5411c7599c
)
endif()
if(NOT TARGET concurrentqueue)
CPMAddPackage(
NAME concurrentqueue
GITHUB_REPOSITORY cameron314/concurrentqueue
VERSION 1.0.4
)
endif()
if(NOT TARGET CURL::libcurl)
set(CURL_USE_LIBPSL OFF CACHE BOOL "" FORCE)
set(BUILD_CURL_EXE OFF CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(CURL_DISABLE_INSTALL ON CACHE BOOL "" FORCE)
set(CURL_DISABLE_TESTS ON CACHE BOOL "" FORCE)
set(HTTP_ONLY ON CACHE BOOL "" FORCE)
set(CURL_USE_OPENSSL ON CACHE BOOL "" FORCE)
set(CURL_ZLIB OFF CACHE BOOL "" FORCE)
set(CMAKE_DISABLE_FIND_PACKAGE_ZLIB TRUE CACHE BOOL "" FORCE)
CPMAddPackage(
NAME curl
GITHUB_REPOSITORY curl/curl
GIT_TAG curl-8_19_0
VERSION 8.19.0
)
endif()
endfunction()