forked from KomodoPlatform/komodo-wallet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
350 lines (290 loc) · 13.5 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
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
cmake_minimum_required(VERSION 3.5)
project(atomicdex-desktop LANGUAGES CXX VERSION 0.3.0)
option(DISABLE_GEOBLOCKING "Enable to disable geoblocking (for dev purpose)" OFF)
set(FETCHCONTENT_QUIET OFF CACHE BOOL "Override option" FORCE)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POLICY_WARNING_CMP0100 OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (EXISTS ${CMAKE_BINARY_DIR}/conan_paths.cmake)
set(CONAN_ENABLED ON)
message(STATUS "Conan package manager enabled")
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
else ()
message(STATUS "VCPKG package manager enabled")
endif ()
##! Antara
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(antara)
##! Calling this macros provided by the sdk will if you are on Apple init the environment for this OS (std::filesystem).
init_antara_env()
##! We include the module from CMake for fetching dependencies
include(FetchContent)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(LINUX TRUE)
endif ()
if (UNIX AND NOT APPLE)
message("Forcing stdlib C++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif ()
##! We fetch our dependencies
if (APPLE)
FetchContent_Declare(mm2
URL https://github.com/KomodoPlatform/atomicDEX-API/releases/download/beta-2.0.2422/mm2-31d1803b0-Darwin-Release.zip)
elseif (UNIX AND NOT APPLE)
FetchContent_Declare(mm2
URL https://github.com/KomodoPlatform/atomicDEX-API/releases/download/beta-2.0.2422/mm2-31d1803b0-Linux-Release.zip)
else ()
FetchContent_Declare(mm2
URL https://github.com/KomodoPlatform/atomicDEX-API/releases/download/beta-2.0.2422/mm2-31d1803b0-Windows_NT-Release.zip)
endif ()
FetchContent_Declare(qmaterial URL https://github.com/KomodoPlatform/Qaterial/archive/master.zip)
FetchContent_Declare(jl777-coins
URL https://github.com/KomodoPlatform/coins/archive/master.zip)
FetchContent_MakeAvailable(mm2 jl777-coins qmaterial)
##! Configure our needs.
if (UNIX)
configure_file(${jl777-coins_SOURCE_DIR}/coins ${CMAKE_CURRENT_SOURCE_DIR}/assets/tools/mm2/coins COPYONLY)
configure_file(${mm2_SOURCE_DIR}/mm2 ${CMAKE_CURRENT_SOURCE_DIR}/assets/tools/mm2/mm2 COPYONLY)
else ()
configure_file(${jl777-coins_SOURCE_DIR}/coins ${CMAKE_BINARY_DIR}/bin/assets/tools/mm2/coins COPYONLY)
configure_file(${mm2_SOURCE_DIR}/mm2.exe ${CMAKE_BINARY_DIR}/bin/assets/tools/mm2/mm2.exe COPYONLY)
configure_file(${mm2_SOURCE_DIR}/msvcp140.dll ${CMAKE_BINARY_DIR}/bin/assets/tools/mm2/msvcp140.dll COPYONLY)
configure_file(${mm2_SOURCE_DIR}/msvcr100.dll ${CMAKE_BINARY_DIR}/bin/assets/tools/mm2/msvcr100.dll COPYONLY)
configure_file(${mm2_SOURCE_DIR}/vcruntime140.dll ${CMAKE_BINARY_DIR}/bin/assets/tools/mm2/vcruntime140.dll COPYONLY)
endif ()
add_subdirectory(vendor/antara-gaming_sdk/modules)
##! Osx bundle icon
set(ICON)
configure_icon_osx(data/osx/atomicdex-desktop.icns ICON atomicdex-desktop.icns)
##! End antara
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
##Lang
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM TRUE)
set(TS_FILES
${CMAKE_SOURCE_DIR}/atomic_defi_design/assets/languages/atomic_defi_en.ts
${CMAKE_SOURCE_DIR}/atomic_defi_design/assets/languages/atomic_defi_fr.ts
${CMAKE_SOURCE_DIR}/atomic_defi_design/assets/languages/atomic_defi_tr.ts
${CMAKE_SOURCE_DIR}/atomic_defi_design/assets/languages/atomic_defi_ru.ts)
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_SOURCE_DIR}/atomic_defi_design/assets/languages/")
qt5_create_translation(QM_FILES
${PROJECT_SOURCE_DIR}/atomic_defi_design/qml
${TS_FILES}
OPTIONS -source-language en_US -no-obsolete)
message(STATUS "QM FILES -> ${QM_FILES}")
message(STATUS "TS FILES -> ${TS_FILES}")
##! End Lang
##! Atomic QT Shared Deps Between main executable and unit tests
add_library(atomicdex-desktop_shared_deps INTERFACE)
target_sources(atomicdex-desktop_shared_deps INTERFACE
##! App
${CMAKE_SOURCE_DIR}/src/atomicdex/app.cpp
##! Utilities
${CMAKE_SOURCE_DIR}/src/atomicdex/utilities/kill.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/utilities/cpprestsdk.utilities.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/utilities/qt.utilities.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/utilities/qt.bindings.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/utilities/security.utilities.cpp
##! Constants
${CMAKE_SOURCE_DIR}/src/atomicdex/constants/mm2.error.code.cpp
##! Config
${CMAKE_SOURCE_DIR}/src/atomicdex/config/app.cfg.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/config/coins.cfg.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/config/wallet.cfg.cpp
##! Managers
${CMAKE_SOURCE_DIR}/src/atomicdex/managers/notification.manager.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/managers/qt.wallet.manager.cpp
##! API
${CMAKE_SOURCE_DIR}/src/atomicdex/api/ohlc/ohlc.api.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/api/mm2/mm2.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/api/coinpaprika/coinpaprika.cpp
##! Models
${CMAKE_SOURCE_DIR}/src/atomicdex/models/qt.orders.model.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/models/qt.orders.proxy.model.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/models/qt.candlestick.charts.model.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/models/qt.addressbook.model.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/models/qt.addressbook.proxy.filter.model.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/models/qt.contact.model.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/models/qt.orderbook.model.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/models/qt.orderbook.proxy.model.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/models/qt.portfolio.model.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/models/qt.wallet.transactions.model.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/models/qt.wallet.transactions.proxy.filter.model.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/models/qt.portfolio.proxy.filter.model.cpp
##ToClass
##! Widgets
${CMAKE_SOURCE_DIR}/src/atomicdex/widgets/dex/qt.market.pairs.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/widgets/dex/qt.orderbook.cpp
##! Pages
${CMAKE_SOURCE_DIR}/src/atomicdex/pages/qt.trading.page.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/pages/qt.settings.page.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/pages/qt.portfolio.page.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/pages/qt.wallet.page.cpp
##! Services
${CMAKE_SOURCE_DIR}/src/atomicdex/services/price/global.provider.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/services/price/coinpaprika/coinpaprika.provider.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/services/price/oracle/band.provider.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/services/update/update.checker.service.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/services/ohlc/ohlc.provider.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/services/mm2/mm2.service.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/services/internet/internet.checker.service.cpp
${CMAKE_SOURCE_DIR}/src/atomicdex/services/ip/ip.checker.service.cpp
##! Platform
$<$<PLATFORM_ID:Darwin>:${CMAKE_SOURCE_DIR}/src/atomicdex/platform/osx/manager.mm>
##! QRC
${CMAKE_SOURCE_DIR}/qml.qrc
##! Linguistic
${QM_FILES}
${TS_FILES}
)
target_compile_definitions(atomicdex-desktop_shared_deps
INTERFACE
$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>
$<$<PLATFORM_ID:Windows>:HAS_REMOTE_API>
$<$<PLATFORM_ID:Windows>:AUTO_DOWNLOAD>
)
if (DISABLE_GEOBLOCKING)
message(STATUS "Disabling Geoblocking for dev purpose")
target_compile_definitions(atomicdex-desktop_shared_deps INTERFACE -DDISABLE_GEOBLOCKING)
endif()
#target_compile_options(atomicdex-desktop_shared_deps INTERFACE -fstandalone-debug)
target_link_libraries(atomicdex-desktop_shared_deps
INTERFACE
Qt::Core
Qt::Quick
Qt::Svg
Qt::Charts
Qt::WebEngine
Qt::WebEngineCore
Qt::WebEngineWidgets
Qt::Widgets
qzxing
antara::world
Boost::random
Boost::filesystem
komodo-sodium::sodium
unofficial-btc::bitcoin
reproc++
komodo-date::date
komodo-folly::folly
komodo-taskflow::taskflow
nlohmann_json::nlohmann_json
#spdlog::spdlog
#spdlog::spdlog_header_only
cpprestsdk::cpprest
Qaterial
)
target_include_directories(atomicdex-desktop_shared_deps
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/src
$<$<PLATFORM_ID:Darwin>:${CMAKE_CURRENT_SOURCE_DIR}/src/osx>
${libqr_code_SOURCE_DIR}/src
)
##! Main executable
add_executable(atomicdex-desktop MACOSX_BUNDLE ${ICON}
${CMAKE_CURRENT_SOURCE_DIR}/data/windows/atomicdex-desktop.rc
main.cpp
)
##! Testing executable
add_executable(atomicdex-desktop_tests MACOSX_BUNDLE ${ICON}
src/atomicdex/tests/atomic.dex.tests.cpp
src/atomicdex/tests/atomic.dex.wallet.config.tests.cpp
src/atomicdex/tests/atomic.dex.utilities.tests.cpp
src/atomicdex/tests/atomic.dex.provider.cex.prices.tests.cpp
src/atomicdex/tests/atomic.dex.qt.utilities.tests.cpp
src/atomicdex/tests/atomic.dex.provider.cex.prices.api.tests.cpp)
target_link_libraries(atomicdex-desktop
PRIVATE
atomicdex-desktop_shared_deps
$<$<PLATFORM_ID:Darwin>:/usr/local/lib/libcurl.a>
)
target_include_directories(atomicdex-desktop PUBLIC src)
target_link_libraries(atomicdex-desktop_tests
PRIVATE
atomicdex-desktop_shared_deps
$<$<PLATFORM_ID:Darwin>:/usr/local/lib/libcurl.a>
doctest::doctest)
##! Setting output directory
set_target_properties(${PROJECT_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
)
set_target_properties(${PROJECT_NAME}_tests
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
)
if (NOT APPLE)
target_precompile_headers(${PROJECT_NAME} PRIVATE src/atomicdex/pch.hpp)
endif ()
#target_enable_tsan(atomicdex-desktop_tests)
#target_enable_asan(atomicdex-desktop)
##! Move assets
if (LINUX)
get_target_property(exe_runtime_directory_at ${PROJECT_NAME} RUNTIME_OUTPUT_DIRECTORY)
set(output_dir_at "${exe_runtime_directory_at}/AntaraAtomicDexAppDir")
magic_game_app_image_generation("${CMAKE_CURRENT_SOURCE_DIR}/data/linux"
"atomicdex-desktop.desktop"
"atomicdex-desktop.appdata.xml"
"atomicdex-desktop_64.png"
atomicdex-desktop
AntaraAtomicDexAppDir
${CMAKE_CURRENT_SOURCE_DIR}/assets
)
magic_game_app_image_generation("${CMAKE_CURRENT_SOURCE_DIR}/data/linux"
"atomicdex-desktop.desktop"
"atomicdex-desktop.appdata.xml"
"atomicdex-desktop_64.png"
atomicdex-desktop_tests
AntaraAtomicDexTestsAppDir
${CMAKE_CURRENT_SOURCE_DIR}/assets
)
set(from_dir "${CMAKE_CURRENT_SOURCE_DIR}/data/linux")
set(desktop_file "atomicdex-desktop.desktop")
set(appdata_file "atomicdex-desktop.appdata.xml")
set(app_icon "atomicdex-desktop-64.png")
message(STATUS "${output_dir_at}")
configure_file(${from_dir}/${desktop_file} ${output_dir_at}/usr/share/applications/${desktop_file} COPYONLY)
configure_file(${from_dir}/${appdata_file} ${output_dir_at}/usr/share/metainfo/${appdata_file} COPYONLY)
configure_file(${from_dir}/${app_icon} ${output_dir_at}/usr/share/icons/hicolor/64x64/apps/${app_icon} COPYONLY)
configure_file(${from_dir}/${app_icon} ${output_dir_at}/usr/share/icons/default/64x64/apps/${app_icon} COPYONLY)
endif ()
if (WIN32)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
file(COPY assets DESTINATION ${CMAKE_BINARY_DIR}/bin/)
configure_file(wally/wally.dll ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
set_target_properties(Folly::folly PROPERTIES INTERFACE_COMPILE_OPTIONS "")
if (CMAKE_BUILD_TYPE MATCHES Release)
message(STATUS "disabling console")
target_compile_definitions(atomicdex-desktop PRIVATE WINDOWS_RELEASE_MAIN)
target_compile_options(atomicdex-desktop PRIVATE -Wno-deprecated-declarations)
target_link_options(atomicdex-desktop PUBLIC --for-linker -subsystem:windows)
endif ()
set(WINDEPLOYQT_PATH "")
if (CONAN_ENABLED)
set(WINDEPLOYQT_PATH ${CONAN_QT_ROOT}/bin/windeployqt.exe)
else()
set(WINDEPLOYQT_PATH $ENV{QT_INSTALL_CMAKE_PATH}/bin/windeployqt.exe)
endif()
if (EXISTS ${WINDEPLOYQT_PATH})
message(STATUS "windeployqt path is -> ${WINDEPLOYQT_PATH}")
else ()
message(FATAL_ERROR "Didn't find windeployqt ${WINDEPLOYQT_PATH}")
endif ()
#bin --qmldir
add_custom_command(TARGET atomicdex-desktop PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/ci_tools_atomic_dex/windows_misc $<TARGET_FILE_DIR:atomicdex-desktop>)
add_custom_command(TARGET atomicdex-desktop
POST_BUILD
COMMAND ${WINDEPLOYQT_PATH} ${CMAKE_BINARY_DIR}/bin --qmldir ${CMAKE_SOURCE_DIR}/atomic_defi_design/qml
)
endif ()
if (APPLE)
file(COPY assets DESTINATION ${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}.app/Contents/Resources)
file(COPY assets DESTINATION ${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}_tests.app/Contents/Resources)
include(data/osx/atomicdex_install.cmake)
endif ()