-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDependencies.cmake
More file actions
232 lines (205 loc) · 6.35 KB
/
Dependencies.cmake
File metadata and controls
232 lines (205 loc) · 6.35 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
include_guard()
include(ESUtil)
include(ESBoost)
include(ESOpenSSL)
include(ESEmscripten)
include(ESLangCompiler)
include(ESThirdPartyLibrary)
include(FetchContent)
if(NOT EMSCRIPTEN)
find_package(Threads REQUIRED)
endif()
if(ES_WITH_JNI)
find_package(JNI REQUIRED)
endif()
if(ES_STATIC_RUNTIME)
set(runtime_args STATIC_RUNTIME)
else()
set(runtime_args "")
endif()
message(STATUS "runtime_args: ${runtime_args}")
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
FetchContent_Declare(
perl-windows
URL https://github.com/refvalue/cpp-essence/releases/download/v5.36.0-perl-windows/perl-5.36-windows.zip
)
FetchContent_MakeAvailable(perl-windows)
es_add_to_env(
PREPEND
NAME PATH
VALUE ${CMAKE_BINARY_DIR}/_deps/perl-windows-src/bin
)
endif()
if(ES_WITH_TESTS)
es_deploy_lang_compiler("https://github.com/refvalue/cpp-essence/releases/download/v0.1.0-lang-compiler")
message(STATUS "ES_LANG_COMPILER_EXECUTABLE: ${ES_LANG_COMPILER_EXECUTABLE}")
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevents overriding the parent project's compiler/linker settings.
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
endif()
set(extra_cmake_args
-DCMAKE_CXX_STANDARD=20
-DCMAKE_CXX_STANDARD_REQUIRED=ON
)
set(extra_openssl_args no-tests no-afalgeng no-aria no-async no-autoload-config no-blake2 no-bf no-camellia no-cast no-chacha no-cmac no-cms no-cmp no-comp no-ct no-des no-dgram no-dh no-dsa no-dtls no-ec2m no-engine no-filenames no-gost no-idea no-ktls no-mdc2 no-md4 no-multiblock no-nextprotoneg no-ocsp no-ocb no-poly1305 no-psk no-rc2 no-rc4 no-rmd160 no-seed no-siphash no-siv no-srp no-srtp no-ssl3 no-ssl3-method no-ts no-ui-console no-whirlpool)
if(CMAKE_CROSSCOMPILING AND NOT EMSCRIPTEN)
# The Boost library is unnecessary if the websocketpp library is excluded
# when compiling the cpprestsdk on Windows.
message(STATUS "======== CROSS-COMPILING ========")
list(
APPEND extra_cmake_args
-DES_TOOLCHAIN_PREFIX=${ES_TOOLCHAIN_PREFIX}
)
if(ANDROID)
list(APPEND extra_openssl_args CC ${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}clang)
list(APPEND extra_cmake_args -DES_NDK_ROOT=${ES_NDK_ROOT})
endif()
endif()
es_make_install_third_party_library(
fmt
REQUIRED
${runtime_args}
PARALLEL_BUILD
SYNC_BUILD_TYPE
GENERATOR ${CMAKE_GENERATOR}
CMAKE_ARGS
-DFMT_TEST=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
${extra_cmake_args}
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/third-party/fmt
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
)
if(ES_HAVE_STD_FORMAT)
set(spdlog_extra_args -DSPDLOG_USE_STD_FORMAT=ON)
else()
set(spdlog_extra_args -DSPDLOG_FMT_EXTERNAL=ON)
endif()
es_make_install_third_party_library(
spdlog
REQUIRED
${runtime_args}
PARALLEL_BUILD
SYNC_BUILD_TYPE
GENERATOR ${CMAKE_GENERATOR}
CMAKE_ARGS
-DSPDLOG_BUILD_PIC=ON
-DSPDLOG_BUILD_EXAMPLE=OFF
-DSPDLOG_BUILD_EXAMPLE_HO=OFF
-DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}
${extra_cmake_args}
${spdlog_extra_args}
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/third-party/spdlog
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
)
es_make_openssl(
REQUIRED
STATIC
${runtime_args}
PARALLEL_BUILD
SYNC_BUILD_TYPE
${extra_openssl_args}
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/third-party/openssl
)
message(STATUS "====OPENSSL_CRYPTO_LIBRARY: ${OPENSSL_CRYPTO_LIBRARY}")
set(
zlibng_cmake_args
-DZLIB_ENABLE_TESTS=OFF
-DZLIB_COMPAT=ON
-DBUILD_SHARED_LIBS=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
${extra_cmake_args}
)
if(EMSCRIPTEN)
list(
APPEND zlibng_cmake_args
-DWITH_OPTIM=OFF
)
endif()
es_make_install_third_party_library(
ZLIB
MODULE
REQUIRED
${runtime_args}
PARALLEL_BUILD
SYNC_BUILD_TYPE
GENERATOR ${CMAKE_GENERATOR}
CMAKE_ARGS ${zlibng_cmake_args}
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/third-party/zlib-ng
RESULT_INSTALL_DIR ZLIB_ROOT
)
es_make_install_third_party_library(
zstd
REQUIRED
${runtime_args}
PARALLEL_BUILD
SYNC_BUILD_TYPE
GENERATOR ${CMAKE_GENERATOR}
CMAKE_ARGS
-DZSTD_BUILD_STATIC=ON
-DZSTD_BUILD_SHARED=OFF
-DZSTD_BUILD_TESTS=OFF
-DZSTD_BUILD_PROGRAMS=OFF
-DZSTD_MULTITHREAD_SUPPORT=OFF
${extra_cmake_args}
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/third-party/zstd/build/cmake
)
# The cpprestsdk library uses Ninja as the build system when cross-compiling.
if(ES_WITH_NET)
if(WIN32)
set(cpprestsdk_extra_cmake_args "")
else()
# Unix/Linux needs Boost.
set(
make_boost_extra_args
TOOLSET ${CMAKE_CXX_COMPILER}
TARGET_OS linux
)
es_make_boost(
REQUIRED
STATIC
${runtime_args}
PARALLEL_BUILD
SYNC_BUILD_TYPE
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/third-party/boost-archive-for-cpprestsdk
${make_boost_extra_args}
)
set(
cpprestsdk_extra_cmake_args
-DBOOST_ROOT=${BOOST_ROOT}
-DBoost_USE_STATIC_LIBS=ON
-DBoost_USE_STATIC_RUNTIME=${ES_STATIC_RUNTIME}
)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
list(APPEND cpprestsdk_extra_cmake_args -DCMAKE_CXX_FLAGS=-Wno-format-truncation)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
list(APPEND cpprestsdk_extra_cmake_args -DCMAKE_CXX_FLAGS=-Wno-enum-constexpr-conversion)
endif()
# Boost is excluded without compiling websocketpp as a dependency.
es_make_install_third_party_library(
cpprestsdk
REQUIRED
${runtime_args}
#PARALLEL_BUILD
SYNC_BUILD_TYPE
GENERATOR ${CMAKE_GENERATOR}
CMAKE_ARGS
-G Ninja
-DWERROR=OFF
-DBUILD_TESTS=OFF
-DBUILD_SAMPLES=OFF
-DBUILD_SHARED_LIBS=OFF
-DCPPREST_EXCLUDE_WEBSOCKETS=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DZLIB_ROOT=${ZLIB_ROOT}
-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
-DOPENSSL_USE_STATIC_LIBS=TRUE
${extra_cmake_args}
${cpprestsdk_extra_cmake_args}
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/third-party/cpprestsdk
)
endif()