forked from seredat/karbowanecwallet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
701 lines (611 loc) · 27.2 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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
# We need 3.8 for set(CMAKE_CXX_STANDARD 17)
cmake_minimum_required(VERSION 3.8)
# Required for finding Threads on ARM
enable_language(C)
enable_language(CXX)
# Enable c++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
include(CryptoNoteWallet.cmake)
include(external/ext.cmake)
if (NOT ARCH OR ARCH STREQUAL "" OR ARCH STREQUAL "native" OR ARCH STREQUAL "default")
set(ARCH_ID "${CMAKE_SYSTEM_PROCESSOR}")
else()
set(ARCH_ID "${ARCH}")
endif()
string(TOLOWER "${ARCH_ID}" ARM_ID)
if (ARM_ID)
string(SUBSTRING "${ARM_ID}" 0 3 ARM_TEST)
endif()
if (ARM_TEST STREQUAL "arm")
set(ARM 1)
string(SUBSTRING "${ARM_ID}" 0 5 ARM_TEST)
if (ARM_TEST STREQUAL "armv6")
set(ARM6 1)
endif()
if (ARM_TEST STREQUAL "armv7")
set(ARM7 1)
endif()
endif()
if (ARM_ID STREQUAL "aarch64" OR ARM_ID STREQUAL "arm64" OR ARM_ID STREQUAL "armv8-a")
set(ARM 1)
set(ARM8 1)
set(ARCH "armv8-a")
endif()
if(ARCH_ID STREQUAL "ppc64le")
set(PPC64LE 1)
endif()
project(${WALLET_NAME})
execute_process(COMMAND git log -1 --pretty=format:%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REVISION)
set(CRYPTONOTE_LIB cryptonote)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(UPNPC_BUILD_STATIC ON CACHE BOOL "Build static library")
set(UPNPC_BUILD_SHARED OFF CACHE BOOL "Build shared library")
set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Build test executables")
include_directories(${CMAKE_BINARY_DIR}
src
cryptonote/external/leveldb/include
cryptonote/external/rocksdb/include
cryptonote/external/zstd/lib
cryptonote/external/zstd/lib/common
cryptonote/external/zstd/lib/compress
cryptonote/external/zstd/lib/decompress
cryptonote/external/snappy
cryptonote/external
cryptonote/include
cryptonote/src
external/libqrencode
external/qcustomplot)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
find_package(Qt5LinguistTools REQUIRED)
find_package(Qt5DBus REQUIRED)
include_directories(${Qt5DBus_INCLUDE_DIRS} include src external "${CMAKE_CURRENT_BINARY_DIR}/version")
set(Boost_NO_BOOST_CMAKE ON)
set(Boost_USE_STATIC_LIBS ON)
if(WIN32)
set(Boost_USE_STATIC_RUNTIME OFF)
else(WIN32)
set(Boost_USE_STATIC_RUNTIME ON)
endif(WIN32)
find_package(Boost REQUIRED COMPONENTS date_time filesystem program_options regex serialization system thread chrono)
if ((${Boost_MAJOR_VERSION} EQUAL 1) AND (${Boost_MINOR_VERSION} EQUAL 54))
message(SEND_ERROR "Boost version 1.54 is unsupported, more details are available here http://goo.gl/RrCFmA")
endif ()
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
# We have to look for Homebrew OpenSSL a bit differently
# Borrowed from https://github.com/tarantool/tarantool/commit/6eab201af1843f53a833c8928dc58fceffa08147
if (APPLE)
find_program(HOMEBREW_EXECUTABLE brew)
execute_process(COMMAND ${HOMEBREW_EXECUTABLE} --prefix openssl
OUTPUT_VARIABLE HOMEBREW_OPENSSL
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (DEFINED HOMEBREW_OPENSSL)
if (NOT DEFINED OPENSSL_ROOT_DIR)
message(STATUS "Setting OpenSSL root to ${HOMEBREW_OPENSSL}")
set(OPENSSL_ROOT_DIR "${HOMEBREW_OPENSSL}")
endif ()
endif ()
endif ()
find_package(OpenSSL)
if (NOT OPENSSL_FOUND)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_search_module(OPENSSL openssl)
endif()
endif()
if (OPENSSL_FOUND)
## On non MSVC build systems, we need to link ldl with the static OpenSSL library
if (NOT MSVC)
set(OPENSSL_LIBRARIES "${OPENSSL_LIBRARIES};dl")
endif ()
include_directories(${OPENSSL_INCLUDE_DIR})
message(STATUS "OpenSSL Found: ${OPENSSL_INCLUDE_DIR}")
message(STATUS "OpenSSL Libraries: ${OPENSSL_LIBRARIES}")
else ()
message(STATUS "OpenSSL Found: No... Skipping...")
endif ()
set(VERSION "")
include(cn_version.cmake)
configure_file("src/CryptoNoteWalletConfig.h.in" "CryptoNoteWalletConfig.h")
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/src/Info.plist.in"
"${CMAKE_CURRENT_BINARY_DIR}/Info.plist"
@ONLY
)
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/src/WindowsInstall.nsi.in"
"${CMAKE_CURRENT_BINARY_DIR}/WindowsInstall.nsi"
@ONLY
)
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/src/karbowanecwallet.desktop.in"
"${CMAKE_CURRENT_BINARY_DIR}/karbowanecwallet.desktop"
@ONLY
)
add_definitions(-DVERSION=\"${WALLET_VERSION}\")
add_definitions(-DGIT_REVISION=\"${GIT_REVISION}\")
add_definitions(-DUPNP_STATIC -DMINIUPNP_STATICLIB -DUPNPC_BUILD_STATIC)
set(CMAKE_AUTOMOC ON)
file(GLOB_RECURSE CRYPTONOTE_SOURCES
cryptonote/external/miniupnpc/connecthostport.c
cryptonote/external/miniupnpc/igd_desc_parse.c
cryptonote/external/miniupnpc/minisoap.c
cryptonote/external/miniupnpc/minissdpc.c
cryptonote/external/miniupnpc/miniupnpc.c
cryptonote/external/miniupnpc/miniwget.c
cryptonote/external/miniupnpc/minixml.c
cryptonote/external/miniupnpc/portlistingparse.c
cryptonote/external/miniupnpc/receivedata.c
cryptonote/external/miniupnpc/upnpcommands.c
cryptonote/external/miniupnpc/upnpdev.c
cryptonote/external/miniupnpc/upnperrors.c
cryptonote/external/miniupnpc/upnpreplyparse.c
cryptonote/src/Common/Base58.cpp
cryptonote/src/Common/CommandLine.cpp
cryptonote/src/Common/FormatTools.cpp
cryptonote/src/Common/Util.cpp
cryptonote/src/Common/StringTools.cpp
cryptonote/src/Common/JsonValue.cpp
cryptonote/src/Common/ConsoleTools.cpp
cryptonote/src/Common/MemoryInputStream.cpp
cryptonote/src/Common/PathTools.cpp
cryptonote/src/Common/PasswordContainer.cpp
cryptonote/src/Common/DnsTools.cpp
cryptonote/src/Common/StdInputStream.cpp
cryptonote/src/Common/StdOutputStream.cpp
cryptonote/src/Common/StreamTools.cpp
cryptonote/src/Common/StringOutputStream.cpp
cryptonote/src/Common/StringView.cpp
cryptonote/src/Common/VectorOutputStream.cpp
cryptonote/src/Common/ScopeExit.cpp
cryptonote/src/crypto/blake256.c
cryptonote/src/crypto/chacha8.cpp
cryptonote/src/crypto/crypto-ops-data.c
cryptonote/src/crypto/crypto-ops.c
cryptonote/src/crypto/crypto-util.c
cryptonote/src/crypto/crypto.cpp
cryptonote/src/crypto/groestl.c
cryptonote/src/crypto/hash-extra-blake.c
cryptonote/src/crypto/hash-extra-groestl.c
cryptonote/src/crypto/hash-extra-jh.c
cryptonote/src/crypto/hash-extra-skein.c
cryptonote/src/crypto/hash.c
cryptonote/src/crypto/jh.c
cryptonote/src/crypto/keccak.c
cryptonote/src/crypto/oaes_lib.c
cryptonote/src/crypto/skein.c
cryptonote/src/crypto/slow-hash.c
cryptonote/src/crypto/slow-hash.cpp
cryptonote/src/crypto/tree-hash.c
cryptonote/src/crypto/yespower.c
cryptonote/src/Checkpoints/Checkpoints.cpp
cryptonote/src/CryptoNoteCore/*.cpp
cryptonote/src/CryptoNoteProtocol/*.cpp
cryptonote/src/HTTP/HttpRequest.cpp
cryptonote/src/HTTP/HttpParser.cpp
cryptonote/src/HTTP/HttpParserErrorCodes.cpp
cryptonote/src/HTTP/HttpResponse.cpp
cryptonote/src/InProcessNode/InProcessNode.cpp
cryptonote/src/InProcessNode/InProcessNodeErrors.cpp
cryptonote/src/NodeRpcProxy/NodeErrors.cpp
cryptonote/src/NodeRpcProxy/NodeRpcProxy.cpp
cryptonote/src/P2p/NetNodeConfig.cpp
cryptonote/src/Logging/*.cpp
cryptonote/src/P2p/*.cpp
cryptonote/src/Rpc/*.cpp
cryptonote/src/Serialization/*.cpp
cryptonote/src/Transfers/BlockchainSynchronizer.cpp
cryptonote/src/Transfers/SynchronizationState.cpp
cryptonote/src/Transfers/TransfersConsumer.cpp
cryptonote/src/Transfers/TransfersContainer.cpp
cryptonote/src/Transfers/TransfersSubscription.cpp
cryptonote/src/Transfers/TransfersSynchronizer.cpp
cryptonote/src/Wallet/LegacyKeysImporter.cpp
cryptonote/src/Wallet/WalletAsyncContextCounter.cpp
cryptonote/src/Wallet/WalletErrors.cpp
cryptonote/src/Wallet/WalletSerializationV1.cpp
cryptonote/src/Wallet/WalletSerializationV2.cpp
cryptonote/src/Wallet/WalletUtils.cpp
cryptonote/src/WalletLegacy/KeysStorage.cpp
cryptonote/src/WalletLegacy/WalletLegacy.cpp
cryptonote/src/WalletLegacy/WalletHelper.cpp
cryptonote/src/WalletLegacy/WalletLegacySerializer.cpp
cryptonote/src/WalletLegacy/WalletLegacySerialization.cpp
cryptonote/src/WalletLegacy/WalletTransactionSender.cpp
cryptonote/src/WalletLegacy/WalletUnconfirmedTransactions.cpp
cryptonote/src/WalletLegacy/WalletUserTransactionsCache.cpp
cryptonote/src/System/ContextGroup.cpp
cryptonote/src/System/Event.cpp
cryptonote/src/System/EventLock.cpp
cryptonote/src/System/InterruptedException.cpp
cryptonote/src/System/Ipv4Address.cpp
cryptonote/src/System/SocketStream.cpp
cryptonote/src/System/TcpStream.cpp
cryptonote/src/JsonRpcServer/*.cpp
cryptonote/src/BlockchainExplorer/BlockchainExplorer.cpp
cryptonote/src/BlockchainExplorer/BlockchainExplorerDataBuilder.cpp
cryptonote/src/BlockchainExplorer/BlockchainExplorerErrors.cpp
cryptonote/src/BlockchainExplorer/BlockchainExplorerDataBuilder.cpp
)
file(GLOB_RECURSE SOURCES src/*.cpp)
file(GLOB_RECURSE HEADERS src/*.h)
file(GLOB_RECURSE FORMS src/gui/ui/*.ui)
file(GLOB_RECURSE Mnemonics cryptonote/src/Mnemonics/*)
file(GLOB_RECURSE QCustomPlot external/qcustomplot/*)
file(GLOB TRANSLATION_FILES src/languages/*.ts)
set(QRC
src/resources.qrc
src/qdarkstyle/style.qrc)
set_source_files_properties(${TRANSLATION_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_BINARY_DIR}/languages")
qt5_wrap_ui(UIS ${FORMS})
qt5_add_resources(RCC ${QRC})
#qt5_create_translation(TRANSLATION_MESSAGES ${FORMS} ${TRANSLATION_FILES})
qt5_add_translation(TRANSLATION_QM ${TRANSLATION_FILES})
add_custom_target(translations DEPENDS ${TRANSLATION_QM})
#add_custom_target(translations_update DEPENDS ${TRANSLATION_MESSAGES})
if (WIN32)
file(GLOB _TRANSLATION_FILES_DEFAULT ${_qt5Core_install_prefix}/translations/*.qm)
list(FILTER _TRANSLATION_FILES_DEFAULT INCLUDE REGEX "\\/[a-z][a-z]_[a-z][a-z].qm$")
add_custom_target(translations_default)
foreach(_qm_file_src ${_TRANSLATION_FILES_DEFAULT})
get_filename_component(_qm_file_name ${_qm_file_src} NAME)
set(_qm_file_dst "${CMAKE_BINARY_DIR}/languages/${_qm_file_name}")
add_custom_command(TARGET translations_default
COMMAND ${CMAKE_COMMAND} -E copy ${_qm_file_src} ${_qm_file_dst})
endforeach()
endif()
option(WITH_ZSTD ON "Build RocksDB with ZSTD")
option(ZSTD_USE_STATIC_RUNTIME "LINK TO STATIC RUN-TIME LIBRARIES" OFF)
option(WITH_MD_LIBRARY "Build RocksDB with MD" ON)
set(PORTABLE ON CACHE BOOL "Buid portable RockDB")
set(WITH_GFLAGS OFF CACHE BOOL "No gflags")
set(WITH_TESTS OFF CACHE BOOL "No tests")
set(WITH_TOOLS OFF CACHE BOOL "No tools")
add_subdirectory(cryptonote/external/miniupnpc EXCLUDE_FROM_ALL)
if (WIN32)
if (NOT MSVC)
message(FATAL_ERROR "Only MSVC is supported on this platform")
endif ()
add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600 /DSTATICLIB)
add_subdirectory(cryptonote/external/zstd EXCLUDE_FROM_ALL)
add_subdirectory(cryptonote/external/snappy EXCLUDE_FROM_ALL)
add_subdirectory(cryptonote/external/rocksdb EXCLUDE_FROM_ALL)
add_subdirectory(cryptonote/external/leveldb EXCLUDE_FROM_ALL)
set_property(TARGET rocksdb leveldb snappy zstd PROPERTY FOLDER "external")
include_directories(cryptonote/src/platform/msc)
set(CMAKE_CXX_FLAGS "-bigobj -EHsc -std:c++17")
set(PLATFORM_DIR Windows)
set(BUILD_PLATFORM WIN32)
set(BUILD_RESOURCES src/cryptonotewallet.rc)
set(QTMAIN Qt5::WinMain)
elseif (UNIX)
set(CRYPTONOTE_SOURCES ${CRYPTONOTE_SOURCES} cryptonote/external/miniupnpc/minissdpc.c)
file(GLOB PLATFORM_POSIX cryptonote/src/Platform/Posix/System/*)
list(APPEND CRYPTONOTE_SOURCES ${PLATFORM_POSIX})
if (APPLE)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.12")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.12")
execute_process(
COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/cryptonote/external/zstd -DCMAKE_C_FLAGS="-mmacosx-version-min=10.12" -DCMAKE_CXX_FLAGS="-mmacosx-version-min=10.12" -B${PROJECT_BINARY_DIR}/zstd
)
execute_process(
COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/cryptonote/external/snappy -DCMAKE_C_FLAGS="-mmacosx-version-min=10.12" -DCMAKE_CXX_FLAGS="-mmacosx-version-min=10.12" -B${PROJECT_BINARY_DIR}/snappy
)
else()
execute_process(
COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/cryptonote/external/zstd -B${PROJECT_BINARY_DIR}/zstd
)
execute_process(
COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/cryptonote/external/snappy -B${PROJECT_BINARY_DIR}/snappy
)
endif()
add_custom_target(
zstd
COMMAND $(MAKE) zstd
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/zstd
)
add_library(zstdlib STATIC IMPORTED GLOBAL)
set_target_properties(zstdlib PROPERTIES IMPORTED_LOCATION ${PROJECT_BINARY_DIR}/zstd/libzstd.a)
add_dependencies(zstdlib zstd)
add_custom_target(
snappy
COMMAND $(MAKE) snappy
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/snappy
)
add_library(snappylib STATIC IMPORTED GLOBAL)
set_target_properties(snappylib PROPERTIES IMPORTED_LOCATION ${PROJECT_BINARY_DIR}/snappy/libsnappy.a)
add_dependencies(snappylib snappy)
if (APPLE)
execute_process(
COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/cryptonote/external/rocksdb -DARCH=${ARCH} -DWITH_ZSTD=ON -DWITH_GFLAGS=0 -DCMAKE_BUILD_TYPE=MinSizeRel -DWITH_TESTS=OFF -DWITH_TOOLS=OFF -DPORTABLE=ON -DCMAKE_C_FLAGS="-mmacosx-version-min=10.12" -DCMAKE_CXX_FLAGS="-mmacosx-version-min=10.12" -B${PROJECT_BINARY_DIR}/rocksdb
)
execute_process(
COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/cryptonote/external/leveldb -DARCH=${ARCH} -DCMAKE_BUILD_TYPE=MinSizeRel -DLEVELDB_BUILD_TESTS=OFF -DLEVELDB_BUILD_BENCHMARKS=OFF -DLEVELDB_INSTALL=OFF -DCMAKE_C_FLAGS="-mmacosx-version-min=10.12" -DCMAKE_CXX_FLAGS="-mmacosx-version-min=10.12" -B${PROJECT_BINARY_DIR}/leveldb
)
else()
execute_process(
COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/cryptonote/external/rocksdb -DARCH=${ARCH} -DWITH_ZSTD=ON -DWITH_GFLAGS=0 -DCMAKE_BUILD_TYPE=MinSizeRel -DWITH_TESTS=OFF -DWITH_TOOLS=OFF -DPORTABLE=ON -B${PROJECT_BINARY_DIR}/rocksdb
)
execute_process(
COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/cryptonote/external/leveldb -DARCH=${ARCH} -DCMAKE_BUILD_TYPE=MinSizeRel -DLEVELDB_BUILD_TESTS=OFF -DLEVELDB_BUILD_BENCHMARKS=OFF -DLEVELDB_INSTALL=OFF -B${PROJECT_BINARY_DIR}/leveldb
)
endif()
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_BINARY_DIR}/rocksdb/librocksdb.a")
set_property(TARGET upnpc-static PROPERTY FOLDER "external")
add_custom_target(
rocksdb
COMMAND $(MAKE) rocksdb
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/rocksdb
)
add_library(rocksdblib STATIC IMPORTED GLOBAL)
set_target_properties(rocksdblib PROPERTIES IMPORTED_LOCATION ${PROJECT_BINARY_DIR}/rocksdb/librocksdb.a)
add_dependencies(rocksdblib rocksdb)
add_custom_target(
leveldb
COMMAND $(MAKE) leveldb
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/leveldb
)
add_library(leveldblib STATIC IMPORTED GLOBAL)
set_target_properties(leveldblib PROPERTIES IMPORTED_LOCATION ${PROJECT_BINARY_DIR}/leveldb/libleveldb.a)
add_dependencies(leveldblib leveldb)
set(CRYPTONOTE_SOURCES ${CRYPTONOTE_SOURCES} cryptonote/external/miniupnpc/minissdpc.c)
if (APPLE)
enable_language(ASM)
file(GLOB_RECURSE OBJC_SOURCES src/*.mm)
set(SOURCES ${SOURCES} ${OBJC_SOURCES})
set(PLATFORM_DIR OSX)
set(MACOSX_BUNDLE_INFO_STRING "Karbowanec GUI Wallet")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${VERSION_VERSION}.${VERSION_MINOR}.${VERSION_PATCH}")
set(MACOSX_BUNDLE_BUNDLE_NAME "Karbo Wallet")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${VERSION_VERSION}.${VERSION_MINOR}.${VERSION_PATCH}")
set(MACOSX_BUNDLE_BUNDLE_VERSION "$${VERSION_VERSION}.${VERSION_MINOR}.${VERSION_PATCH}")
find_package(Qt5PrintSupport REQUIRED)
include_directories(/usr/include/malloc)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes -std=c++17 -stdlib=libc++")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -maes -D_DARWIN_C_SOURCE")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa -framework OpenGL -framework CoreFoundation -framework Carbon -framework IOKit -L/usr/lib")
set(MACOSX_BUNDLE_ICON_FILE karbowanec.icns)
set(APPLICATION_ICON src/images/karbowanec.icns)
set_source_files_properties(${APPLICATION_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set(BUILD_PLATFORM MACOSX_BUNDLE)
set(BUILD_RESOURCES ${APPLICATION_ICON})
GET_TARGET_PROPERTY(QT_LIB_DIR "${Qt5Widgets_LIBRARIES}" LOCATION)
GET_FILENAME_COMPONENT(QT_LIB_DIR "${QT_LIB_DIR}" PATH)
else()
include(TestCXXAcceptsFlag)
if (CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*|FreeBSD")
set(PLATFORM_DIR "FreeBSD")
enable_language(ASM)
else()
set(PLATFORM_DIR "Linux")
endif()
list(REMOVE_ITEM HEADERS ${CMAKE_SOURCE_DIR}/src/gui/macdockiconhandler.h)
set(ARCH default CACHE STRING "CPU to build for: -march value or default to not pass -march at all")
message(STATUS "Building on ${CMAKE_SYSTEM_PROCESSOR} for ${ARCH}")
if ("${ARCH}" STREQUAL "default")
set(ARCH_FLAG "")
elseif(PPC64LE)
set(ARCH_FLAG "-mcpu=${ARCH}")
else()
set(ARCH_FLAG "-march=${ARCH}")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -D_GNU_SOURCE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE")
if (NOT ARM AND NOT PPC64LE)
message(STATUS "AES support enabled")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes")
elseif (PPC64LE)
message(STATUS "AES support not available on ppc64le")
elseif (ARM6)
message(STATUS "AES support not available on ARMv6")
elseif (ARM7)
message(STATUS "AES support not available on ARMv7")
elseif (ARM8)
CHECK_CXX_ACCEPTS_FLAG("-march=${ARCH}+crypto" ARCH_PLUS_CRYPTO)
if (ARCH_PLUS_CRYPTO)
message(STATUS "Crypto extensions enabled for ARMv8")
set(ARCH_FLAG "-march=${ARCH}+crypto")
else()
message(STATUS "Crypto extensions unavailable on your ARMv8 device")
endif()
else()
message(STATUS "AES support disabled")
endif()
# Compiled binary malfunctions due to aliasing (GCC 6.1+)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_FLAG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_FLAG}")
if (ARM)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
endif()
if (ARM)
message(STATUS "Setting FPU Flags for ARM Processors")
# NB NEON hardware does not fully implement the IEEE 754 standard for floating-point arithmetic
# Need custom assembly code to take full advantage of NEON SIMD
#
# Cortex-A5/9 -mfpu=neon-fp16
# Cortex-A7/15 -mfpu=neon-vfpv4
# Cortex-A8 -mfpu=neon
# ARMv8 -FP and SIMD on by default for all ARM8v-A series, NO -mfpu setting needed
#
# For custom -mtune, processor IDs for ARMv8-A series:
# 0xd04 - Cortex-A35
# 0xd07 - Cortex-A57
# 0xd08 - Cortex-A72
# 0xd03 - Cortex-A73
if (NOT ARM8)
CHECK_CXX_ACCEPTS_FLAG(-mfpu=vfp3-d16 CXX_ACCEPTS_VFP3_D16)
CHECK_CXX_ACCEPTS_FLAG(-mfpu=vfp4 CXX_ACCEPTS_VFP4)
CHECK_CXX_ACCEPTS_FLAG(-mfloat-abi=hard CXX_ACCEPTS_MFLOAT_HARD)
CHECK_CXX_ACCEPTS_FLAG(-mfloat-abi=softfp CXX_ACCEPTS_MFLOAT_SOFTFP)
endif()
if (ARM8)
CHECK_CXX_ACCEPTS_FLAG(-mfix-cortex-a53-835769 CXX_ACCEPTS_MFIX_CORTEX_A53_835769)
CHECK_CXX_ACCEPTS_FLAG(-mfix-cortex-a53-843419 CXX_ACCEPTS_MFIX_CORTEX_A53_843419)
endif()
if (ARM6)
message(STATUS "Selecting VFP for ARMv6")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfp")
endif()
if (ARM7)
if (CXX_ACCEPTS_VFP3_D16 AND NOT CXX_ACCEPTS_VFP4)
message(STATUS "Selecting VFP3 for ARMv7")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp3-d16")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfp3-d16")
endif()
if (CXX_ACCEPTS_VFP4)
message(STATUS "Selecting VFP4 for ARMv7")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp4")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfp4")
endif()
if (CXX_ACCEPTS_MFLOAT_HARD)
message(STATUS "Setting Hardware ABI for Floating Point")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=hard")
endif()
if (CXX_ACCEPTS_MFLOAT_SOFTFP AND NOT CXX_ACCEPTS_MFLOAT_HARD)
message(STATUS "Setting Software ABI for Floating Point")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=softfp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=softfp")
endif()
endif()
if (ARM8)
if (CXX_ACCEPTS_MFIX_CORTEX_A53_835769)
message(STATUS "Enabling Cortex-A53 workaround 835769")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfix-cortex-a53-835769")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfix-cortex-a53-835769")
endif()
if (CXX_ACCEPTS_MFIX_CORTEX_A53_843419)
message(STATUS "Enabling Cortex-A53 workaround 843419")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfix-cortex-a53-843419")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfix-cortex-a53-843419")
endif()
endif()
endif()
endif()
endif ()
include_directories(cryptonote/src/Platform/${PLATFORM_DIR})
include_directories(cryptonote/src/Platform/Posix)
file(GLOB PLATFORM_SOURCES cryptonote/src/Platform/${PLATFORM_DIR}/System/*)
set(CRYPTONOTE_SOURCES ${CRYPTONOTE_SOURCES} ${PLATFORM_SOURCES})
add_library(${CRYPTONOTE_LIB} STATIC ${CRYPTONOTE_SOURCES})
add_library(Mnemonics ${Mnemonics})
add_library(QCustomPlot ${QCustomPlot})
set_target_properties(${CRYPTONOTE_LIB} PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE)
if (WIN32)
target_link_libraries(${CRYPTONOTE_LIB} rocksdb leveldb snappy zstd ${Boost_LIBRARIES})
else ()
target_link_libraries(${CRYPTONOTE_LIB} rocksdblib zstdlib leveldblib snappylib ${Boost_LIBRARIES} -lresolv)
endif ()
set_target_properties(Mnemonics PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE)
target_link_libraries(Mnemonics ${Boost_LIBRARIES})
set_target_properties(QCustomPlot PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE)
target_link_libraries(QCustomPlot Qt5::Core Qt5::PrintSupport)
add_executable(${WALLET_NAME} ${BUILD_PLATFORM} ${BUILD_RESOURCES} ${SOURCES} ${HEADERS} ${UIS} ${RCC})
set_target_properties(${WALLET_NAME} PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE)
target_link_libraries(${WALLET_NAME} ${Boost_LIBRARIES} ${QTMAIN} ${CRYPTONOTE_LIB} ${QRENCODE_LIB} Mnemonics QCustomPlot)
add_dependencies(${WALLET_NAME} translations)
if (WIN32)
add_dependencies(${WALLET_NAME} translations_default)
endif ()
if (OPENSSL_FOUND)
target_link_libraries(${PROJECT_NAME} ${OPENSSL_LIBRARIES})
if (MSVC)
target_link_libraries(${PROJECT_NAME} Rpcrt4 ws2_32 advapi32 crypt32 gdi32 user32)
endif()
endif ()
if (APPLE)
set_target_properties(${WALLET_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
target_link_libraries(${WALLET_NAME} Qt5::PrintSupport)
elseif (UNIX)
target_link_libraries(${WALLET_NAME} -lpthread)
elseif (WIN32 AND NOT ROCKSDB_FOUND)
target_link_libraries(${WALLET_NAME} Imm32 Iphlpapi Winmm)
elseif (WIN32 AND ROCKSDB_FOUND)
target_link_libraries(${WALLET_NAME} Imm32 Iphlpapi Winmm Rpcrt4 Shlwapi)
endif (APPLE)
qt5_use_modules(${WALLET_NAME} Core Widgets Gui Network PrintSupport)
# Installation
set(CPACK_PACKAGE_NAME ${WALLET_NAME})
set(CPACK_PACKAGE_VERSION ${WALLET_VERSION})
set(CPACK_PACKAGE_VENDOR "Karbowanec-project")
set(CPACK_PACKAGE_CONTACT "https://karbo.org")
set(CPACK_STRIP_FILES ON)
if (APPLE)
set(CPACK_GENERATOR DragNDrop)
set(CPACK_BUNDLE_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
install(TARGETS ${WALLET_NAME} BUNDLE DESTINATION .)
elseif (UNIX)
find_program(RPMBUILD rpmbuild)
install(PROGRAMS ${CMAKE_BINARY_DIR}/${WALLET_NAME} DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CMAKE_BINARY_DIR}/karbowanecwallet.desktop DESTINATION share/applications)
install(FILES src/images/karbowanez.png DESTINATION share/pixmaps RENAME karbowanec.png)
install(FILES copyright DESTINATION share/doc/karbowanecwallet)
install(DIRECTORY "${CMAKE_BINARY_DIR}/languages" DESTINATION /opt/karbo/ FILES_MATCHING PATTERN "*.qm")
if (RPMBUILD)
set(CPACK_GENERATOR "RPM;DEB")
set(CPACK_SYSTEM_NAME x86_64)
set(CPACK_RPM_PACKAGE_RELEASE ${WALLET_VERSION})
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_GROUP Office)
set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase >= 5.3.2, qt5-qtbase-gui >= 5.3.2")
set(CPACK_RPM_PACKAGE_SUMMARY "Karbowanec KRB wallet")
set(CPACK_RPM_PACKAGE_DESCRIPTION "Karbowanec KRB wallet
Karbowanec is Ukrainian decentrilized, privacy oriented peer-to-peer
cryptocurrency. It is open-source, nobody owns or controls Karbowanec
and everyone can take part.")
else ()
set(CPACK_GENERATOR DEB)
endif ()
set(CPACK_SYSTEM_NAME 64-bit)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR} <[email protected]>")
set(CPACK_DEBIAN_PACKAGE_SECTION Office)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Karbowanec KRB wallet
Karbowanec is Ukrainian decentralized, privacy oriented peer-to-peer
cryptocurrency. It is open-source, nobody owns or controls Karbowanec
and everyone can take part.")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
elseif (WIN32)
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Karbowanec KRB wallet
Karbowanec is Ukrainian decentralized, privacy oriented peer-to-peer
cryptocurrency. It is open-source, nobody owns or controls Karbowanec
and everyone can take part.")
set (CPACK_PACKAGE_VERSION_MAJOR "1")
set (CPACK_PACKAGE_VERSION_MINOR "4")
set (CPACK_PACKAGE_VERSION_PATCH "1")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "Karbowanec")
# Define components and their display names
set (CPACK_COMPONENTS_ALL applications)
set (CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "Karbo wallet")
# Human readable component descriptions
set (CPACK_COMPONENT_APPLICATIONS_DESCRIPTION
"Ukrainian decentralized, privacy oriented peer-to-peer cryptocurrency")
# Define groups
set(CPACK_COMPONENT_APPLICATIONS_GROUP "Runtime")
set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
"Ukrainian decentralized, privacy oriented peer-to-peer cryptocurrency")
# Define NSIS installation types
set(CPACK_ALL_INSTALL_TYPES Full)
set(CPACK_COMPONENT_APPLICATIONS_INSTALL_TYPES Full)
#install(TARGETS ${WALLET_NAME} RUNTIME DESTINATION .)
set(CPACK_GENERATOR NSIS)
endif (APPLE)
include(CPack)