-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
260 lines (230 loc) · 5.37 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
# Copyright (c) 2019-2022 The Open-Transactions developers
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
cmake_minimum_required(VERSION 3.21.0)
cmake_policy(
SET
CMP0091
NEW
)
set(CMAKE_OSX_DEPLOYMENT_TARGET 11)
project(metier)
set(METIER_APPSTREAM_ID "org.opentransactions.metier")
set(METIER_APPSTREAM_NAME "Métier")
set(METIER_APP_DOMAIN "opentransactions.org")
set(METIER_CLI_COMMAND "metierctl")
set(METIER_GUI_OUTPUT_NAME ${PROJECT_NAME})
set(METIER_VERSION_MAJOR 23)
set(METIER_VERSION_MINOR 0)
set(METIER_VERSION_PATCH 0)
execute_process(
COMMAND
echo
release_version=${METIER_VERSION_MAJOR}.${METIER_VERSION_MINOR}.${METIER_VERSION_PATCH}
OUTPUT_FILE release_version.txt
)
execute_process(
COMMAND echo app_name=${METIER_GUI_OUTPUT_NAME}
OUTPUT_FILE ${PROJECT_BINARY_DIR}/app_name.txt
)
execute_process(
COMMAND echo cli_name=${METIER_CLI_COMMAND}
OUTPUT_FILE ${PROJECT_BINARY_DIR}/cli_name.txt
)
execute_process(
COMMAND echo bundle_id=${METIER_APPSTREAM_ID}
OUTPUT_FILE ${PROJECT_BINARY_DIR}/bundle_id.txt
)
list(
APPEND
CMAKE_MODULE_PATH
"${${PROJECT_NAME}_SOURCE_DIR}/cmake"
)
include(open-transactions-common)
# -----------------------------------------------------------------------------
# Setup
set_build_type()
set_out_of_source_build()
update_git_submodules()
# -----------------------------------------------------------------------------
# Set option defaults
if(CMAKE_BUILD_TYPE STREQUAL "Debug"
OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"
)
set(METIER_PEDANTIC_DEFAULT ON)
set(CMAKE_VERBOSE_MAKEFILE ON)
else()
set(METIER_PEDANTIC_DEFAULT OFF)
endif()
if(WIN32)
set(OT_USE_VCPKG_TARGETS_DEFAULT ON)
else()
set(OT_USE_VCPKG_TARGETS_DEFAULT OFF)
endif()
# -----------------------------------------------------------------------------
# Options
option(
METIER_PEDANTIC_BUILD
"Treat compiler warnings as errors."
${METIER_PEDANTIC_DEFAULT}
)
option(
METIER_BUNDLED_OPENTXS
"Use submodule version of libopentxs"
ON
)
option(
OT_USE_VCPKG_TARGETS
"Assume dependencies are managed by vcpkg"
${OT_USE_VCPKG_TARGETS_DEFAULT}
)
option(
METIER_QML_INTERFACE
"Use Qt Quick interface instead of Qt Widgets"
OFF
)
# -----------------------------------------------------------------------------
# Set compiler options
set(METIER_ORIGINAL_C_FLAGS "${CMAKE_C_FLAGS}")
set(METIER_ORIGINAL_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set_compiler_flags(20 ${METIER_PEDANTIC_BUILD})
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-extra-semi-stmt -Wno-noexcept -Wno-redundant-parens -Wno-reserved-identifier")
endif()
# -----------------------------------------------------------------------------
# Print system information and build options
print_build_details(METIER_PEDANTIC_BUILD METIER_BUILD_TESTS)
if(METIER_QML_INTERFACE)
message(STATUS "Interface type: Qml")
else()
message(STATUS "Interface type: Widgets")
endif()
# -----------------------------------------------------------------------------
# Dependencies
find_system_libraries()
find_package(
Boost
1.75.0
REQUIRED
COMPONENTS
date_time
json
program_options
)
find_package(
QT
NAMES
Qt6
Qt5
COMPONENTS
Core
Gui
Network
Widgets
REQUIRED
)
if(METIER_QML_INTERFACE)
find_package(
Qt${QT_VERSION_MAJOR}
COMPONENTS
Qml
Quick
QuickControls2
QmlImportScanner
Svg
REQUIRED
)
endif()
if(OT_USE_VCPKG_TARGETS)
set(METIER_ZMQ_PACKAGE "ZeroMQ")
set(METIER_ZMQ_TARGET "libzmq-static")
else()
set(METIER_ZMQ_PACKAGE "unofficial-zeromq")
set(METIER_ZMQ_TARGET "libzmq")
endif()
if(METIER_BUNDLED_OPENTXS)
find_package(
Boost
1.75.0
QUIET
OPTIONAL_COMPONENTS
container
filesystem
iostreams
json
stacktrace_basic
system
thread
)
find_package(ZLIB QUIET)
find_package("${METIER_ZMQ_PACKAGE}" QUIET)
find_package(
OpenSSL
1.0.1
QUIET
)
find_package(unofficial-sodium QUIET)
find_package(Protobuf QUIET)
find_package(lmdb QUIET)
find_package(
Qt${QT_VERSION_MAJOR}
COMPONENTS
Core
Gui
Qml
Widgets
QUIET
)
find_package(TBB QUIET)
else()
find_package(opentxs REQUIRED)
find_package(
Boost
1.75.0
QUIET
OPTIONAL_COMPONENTS
container
filesystem
iostreams
json
stacktrace_basic
system
thread
)
find_package(ZLIB QUIET)
find_package("${METIER_ZMQ_PACKAGE}" QUIET)
find_package(
OpenSSL
1.0.1
QUIET
)
if(WIN32)
find_package(pthread QUIET)
endif()
find_package(unofficial-secp256k1 QUIET)
find_package(unofficial-sodium QUIET)
find_package(Protobuf QUIET)
find_package(lmdb QUIET)
find_package(
Qt${QT_VERSION_MAJOR} QUIET
COMPONENTS
Core
Gui
Qml
Widgets
)
find_package(SQLite3 QUIET)
find_package(TBB QUIET)
endif()
# -----------------------------------------------------------------------------
# Source Definitions
set_common_defines()
add_definitions("${QT_DEFINITIONS}")
# -----------------------------------------------------------------------------
# Build source
add_library(metier-common OBJECT "")
add_subdirectory(deps)
add_subdirectory(licenses)
add_subdirectory(src)
add_subdirectory(package)