forked from BeamMW/beam-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
290 lines (239 loc) · 11.8 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
cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0074 NEW)
if (BEAM_SIGN_PACKAGE AND WIN32)
# add_custom_target(signing ALL DEPENDS beam-wallet-ui COMMENT "Signing Package...")
find_program(SIGNTOOL_EXECUTABLE signtool.exe)
message("SignTool: ${SIGNTOOL_EXECUTABLE}" )
set(WINDOWS_IDENTITIY_PFX_FILE "THE_PFX_FILE_IS_MISSING_HERE!" CACHE STRING "PFX file, which represents the identity of the developer.")
set(WINDOWS_IDENTITIY_PFX_PASSWORD "" CACHE STRING "Password, which unlocks the PFX file (optional)")
set(BEAM_SIGN_SUBJECT_NAME "" CACHE STRING "Beam subjet")
set(SIGNTOOL_OPTIONS /tr http://timestamp.digicert.com /td sha256 /fd sha256 /n "${BEAM_SIGN_SUBJECT_NAME}")
#set(SIGNTOOL_OPTIONS /fd SHA256 /a /f ${WINDOWS_IDENTITIY_PFX_FILE} /tr http://timestamp.digicert.com )
#if(NOT ${WINDOWS_IDENTITIY_PFX_PASSWORD} EQUAL "")
# set(SIGNTOOL_OPTIONS ${SIGNTOOL_OPTIONS} /p ${WINDOWS_IDENTITIY_PFX_PASSWORD})
#else()
# message(FATAL_ERROR "You can't sign your executables without passing your password here!")
#endif()
#if(EXISTS ${WINDOWS_IDENTITIY_PFX_FILE})
# message(STATUS "Signing executables with: " ${WINDOWS_IDENTITIY_PFX_FILE})
# if(${WINDOWS_IDENTITIY_PFX_PASSWORD})
# message(WARNING "USE WITH CAUTION: Password for the PFX file has been set!")
# endif()
#else()
# message(WARNING "Could not find the PFX file. Can not sign the executables!")
#endif()
endif()
if(BEAM_LINK_TYPE MATCHES "Static")
set(BEAM_USE_STATIC TRUE)
endif()
option(BEAM_USE_STATIC_QT "Build with staticaly linked QT library" FALSE)
if (BEAM_USE_STATIC AND NOT BEAM_USE_STATIC_QT)
set(BEAM_USE_STATIC_RUNTIME FALSE)
endif()
# should be before project and git
set(BEAM_WALLET_CLIENT_LIBRARY TRUE)
set(BEAM_TESTS_ENABLED FALSE)
add_subdirectory(beam)
find_package(Git)
if(Git_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} status
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
ERROR_VARIABLE RESULT_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(LENGTH "${RESULT_STRING}" LENGTH_RESULT_STRING)
if(${LENGTH_RESULT_STRING} EQUAL 0)
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --format=%H
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-list HEAD --count
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE VERSION_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(APPVEYOR_REPO_BRANCH_EXISTS $ENV{APPVEYOR_REPO_BRANCH})
set(TRAVIS_BRANCH_EXISTS $ENV{TRAVIS_BRANCH})
if(NOT DEFINED BRANCH_NAME)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE BRANCH_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
endif()
else()
set(BRANCH_NAME "")
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/beam)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
if(BEAM_USE_STATIC)
add_definitions(-DBEAM_USE_STATIC)
endif()
if(BEAM_USE_STATIC_QT)
add_definitions(-DBEAM_USE_STATIC_QT)
endif()
if (NOT DEFINED BEAM_DEFAULT_NETWORK)
set(BEAM_DEFAULT_NETWORK "mainnet")
endif()
add_definitions(-DBEAM_DEFAULT_NETWORK=${BEAM_DEFAULT_NETWORK})
if(BEAM_DEFAULT_NETWORK STREQUAL "masternet")
set(BEAM_SUFFIX_LOWER_CASE "masternet" CACHE INTERNAL "")
set(BEAM_SUFFIX_UPPER_CASE "Masternet" CACHE INTERNAL "")
set(BEAM_TARGET_SUFFIX "-${BEAM_SUFFIX_LOWER_CASE}" CACHE INTERNAL "")
set(BEAM_DISPLAY_SUFFIX " ${BEAM_SUFFIX_UPPER_CASE}" CACHE INTERNAL "")
elseif(BEAM_DEFAULT_NETWORK STREQUAL "testnet")
set(BEAM_SUFFIX_LOWER_CASE "testnet" CACHE INTERNAL "")
set(BEAM_SUFFIX_UPPER_CASE "Testnet" CACHE INTERNAL "")
set(BEAM_TARGET_SUFFIX "-${BEAM_SUFFIX_LOWER_CASE}" CACHE INTERNAL "")
set(BEAM_DISPLAY_SUFFIX " ${BEAM_SUFFIX_UPPER_CASE}" CACHE INTERNAL "")
elseif(BEAM_DEFAULT_NETWORK STREQUAL "dappnet")
set(BEAM_SUFFIX_LOWER_CASE "dappnet" CACHE INTERNAL "")
set(BEAM_SUFFIX_UPPER_CASE "Dappnet" CACHE INTERNAL "")
set(BEAM_TARGET_SUFFIX "-${BEAM_SUFFIX_LOWER_CASE}" CACHE INTERNAL "")
set(BEAM_DISPLAY_SUFFIX " ${BEAM_SUFFIX_UPPER_CASE}" CACHE INTERNAL "")
elseif(BEAM_DEFAULT_NETWORK STREQUAL "mainnet")
set(BEAM_SUFFIX_LOWER_CASE "" CACHE INTERNAL "")
set(BEAM_SUFFIX_UPPER_CASE "" CACHE INTERNAL "")
set(BEAM_TARGET_SUFFIX "" CACHE INTERNAL "")
set(BEAM_DISPLAY_SUFFIX "" CACHE INTERNAL "")
endif()
message("BRANCH_NAME: ${BRANCH_NAME}")
project(beam-ui VERSION ${BEAM_VERSION}.${VERSION_REVISION})
set(VERSION_MAJOR ${BEAM_VERSION_MAJOR})
set(VERSION_MINOR ${BEAM_VERSION_MINOR})
message("BEAM_UI_VERSION: ${PROJECT_VERSION}")
message("BEAM_TARGET_SUFFIX: ${BEAM_TARGET_SUFFIX}")
file(WRITE ${PROJECT_SOURCE_DIR}/beam_version.gen "${PROJECT_VERSION}")
if(UNIX AND NOT APPLE AND NOT ANDROID)
set(LINUX TRUE)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(MSVC)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4100") # unreferenced formal parameter
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4127") # viewmodel/applications/public.cpp
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") # viewmodel/applications/public.cpp
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4324") # '__blake2b_state': structure was padded due to alignment specifier
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5240") # qcolor.h(233): 'nodiscard': attribute is ignored in this syntactic position
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /O2")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /OPT:REF /INCREMENTAL:NO")
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /OPT:REF /INCREMENTAL:NO")
SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /OPT:REF /INCREMENTAL:NO")
#target_compile_definitions(beam INTERFACE -D_WIN32_WINNT=0x0600)
#add_definitions(-D_WIN32_WINNT=0x0600)
if(BEAM_USE_STATIC_RUNTIME)
# target_compile_options(beam INTERFACE $<IF:$<CONFIG:Debug>,/MTd, /MT>)
# target_link_options(beam INTERFACE $<IF:$<NOT:$<CONFIG:Debug>>, /OPT:REF /INCREMENTAL:NO, >)
# use static runtime
foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
endforeach(flag_var)
endif()
else()
if(NOT ANDROID AND NOT IOS)
if(APPLE)
execute_process(COMMAND uname -m OUTPUT_VARIABLE arch OUTPUT_STRIP_TRAILING_WHITESPACE)
if ("${arch}" STREQUAL "arm64")
set(APPLE_M1 TRUE)
endif()
endif()
if(APPLE_M1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=apple-m1")
else()
if(ARCH_NATIVE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=core2")
endif()
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -pthread -fvisibility=hidden")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb3")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
# disable some warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual") # appears alot in our macro expansions
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-const-variable") # so what?
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") # mostly in 3rd-party libs
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-value") # proto.h
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nonnull") # yas
if(APPLE AND
CMAKE_CXX_COMPILER_ID MATCHES "AppleClang|Clang" AND
(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 15 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 15))
add_compile_definitions(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) # [email protected]/1.76.0_4/include/boost/container_hash/hash.hpp:131:33
endif()
endif()
set(SKIP_INSTALL_ALL ON)
add_subdirectory(3rdparty/zlib EXCLUDE_FROM_ALL)
add_subdirectory(3rdparty/qrcode)
add_subdirectory(3rdparty/quazip)
add_subdirectory(3rdparty/qhttpengine EXCLUDE_FROM_ALL)
add_subdirectory(ui)
########################################################
### PACKAGING ##########################################
########################################################
if (WIN32)
set(CPACK_GENERATOR "NSIS")
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/ui/icon.ico")
set(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/ui/icon.ico")
set(CPACK_NSIS_INSTALLED_ICON_NAME "${PROJECT_SOURCE_DIR}/ui/icon.ico")
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "CreateShortCut \\\"$DESKTOP\\\\Beam Wallet${BEAM_DISPLAY_SUFFIX}.lnk\\\" \\\"$INSTDIR\\\\Beam Wallet${BEAM_DISPLAY_SUFFIX}.exe\\\"")
set(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Beam Wallet${BEAM_DISPLAY_SUFFIX}.lnk\\\" \\\"$INSTDIR\\\\Beam Wallet${BEAM_DISPLAY_SUFFIX}.exe\\\"")
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "Delete \\\"$DESKTOP\\\\Beam Wallet${BEAM_DISPLAY_SUFFIX}.lnk\\\"")
set(CPACK_NSIS_DELETE_ICONS_EXTRA "Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Beam Wallet${BEAM_DISPLAY_SUFFIX}.lnk\\\"")
set(CPACK_NSIS_EXECUTABLES_DIRECTORY .)
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "Beam Wallet${BEAM_DISPLAY_SUFFIX}.exe")
set(CPACK_NSIS_PACKAGE_NAME "Beam Wallet${BEAM_DISPLAY_SUFFIX}")
elseif (APPLE)
set(CPACK_GENERATOR "DragNDrop")
elseif (LINUX)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_NAME "beamwallet${BEAM_SUFFIX_LOWER_CASE}")
set(CPACK_DEBIAN_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Beam <[email protected]>")
set(CPACK_DEBIAN_PACKAGE_SECTION "Network")
endif ()
set(CPACK_PACKAGE_NAME "BeamWallet${BEAM_SUFFIX_UPPER_CASE}")
set(CPACK_PACKAGE_VENDOR "Beam Development Limited")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Scalable confidential cryptocurrency")
set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_REVISION}")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Beam Wallet${BEAM_DISPLAY_SUFFIX}")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/TERMS.txt")
include(CPack)
#if (BEAM_SIGN_PACKAGE AND WIN32)
# add_custom_target(signing ALL COMMENT "Signing Package...")
#
#
# # Signing the installer
# add_custom_target(signing-installer)
# set(BEAM_INSTALLER_NAME ${CPACK_NSIS_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}.exe)
#
# add_custom_command(
# TARGET signing-installer
# COMMAND ${SIGNTOOL_EXECUTABLE} sign ${SIGNTOOL_OPTIONS} ${BEAM_INSTALLER_NAME}
# ## Other optional options:
# # /tr timestampServerUrl
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
# )
#endif()