-
Notifications
You must be signed in to change notification settings - Fork 139
/
CMakeLists.txt
293 lines (259 loc) · 10.4 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
cmake_minimum_required( VERSION 3.19 )
project( BMQ LANGUAGES C CXX )
# o We need the above line because, per CMake 'project' command
# documentation, "The top-level CMakeLists.txt file for a project must
# contain a literal, direct call to the project() command; loading one
# through the include() command is not sufficient."
# -----------------------------------------------------------------------------
# MODULES
# -----------------------------------------------------------------------------
# Where to find custom CMake Modules
#
list( APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/etc/cmake" )
include( BBVendor )
include( BMQPlugins )
include( TargetBMQStyleUor )
include( BmqPackageProvider )
setup_package_provider()
# -----------------------------------------------------------------------------
# INITIALIZATION
# -----------------------------------------------------------------------------
enable_testing()
set( CMAKE_POSITION_INDEPENDENT_CODE ON )
# Define CXXFlags/LDFlags per build mode, that are OS/compiler specific
if( "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang" )
# Enable as much Clang compiler warnings as we can
add_compile_options(
"-Weverything"
"-Wno-covered-switch-default"
"-Wno-padded"
"-Wno-global-constructors" # bmqp_protocol mask constants
"-Wno-conversion"
"-Wno-undef" # BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
"-Wno-float-equal" # operator== in generated classes
)
if( DEFINED CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD GREATER_EQUAL 17 )
# The below warnings are disabled, but should be revisited and properly
# addressed
add_compile_options(
"-Wno-atomic-implicit-seq-cst"
"-Wno-c++98-compat-pedantic"
"-Wno-deprecated"
"-Wno-disabled-macro-expansion"
"-Wno-extra-semi-stmt"
"-Wno-zero-as-null-pointer-constant"
# to compile hello_world: uncomment or add 'override' specifier (C++11)
# "-Wno-suggest-override"
)
endif()
endif()
if( "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" )
# Disable the warning about ABI change around exception specifications from
# C++17 as there is nothing anyone can do about it; we just should not mix
# C++17 and non C++17 built code.
set_property( DIRECTORY
APPEND
PROPERTY COMPILE_OPTIONS "-Wno-noexcept-type" )
endif()
# Enable '-Werror' for all targets when using GCC or Clang.
# NOTE: o In order to be effective, this must be called before creating the
# targets (i.e. before the 'bbproject_add_group/application').
# o Do it here (after 'bbproject_setup' so that overlays are not
# compiled with -Werror)
set_property( DIRECTORY
APPEND
PROPERTY COMPILE_WARNING_AS_ERROR ON )
if( "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|(Apple)?Clang" )
# Disable warnings about unused functions or variables when not in Debug
# build, so that we don't get warn (and build failure due to warn-as-error)
# for code only used within BSLS_ASSERT_SAFE.
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-Wno-unused-variable")
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-Wno-unused-function")
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-Wno-unused-but-set-variable")
endif()
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# In Debug build, ensure that BSLS_ASSERT_SAFE macro is enabled
add_definitions("-DBSLS_ASSERT_LEVEL_ASSERT_SAFE")
endif()
# This repo contains the canonical source of multiple, independently released,
# UORs (bmq, bmqbrkr, bmqbrkrcfg, bmqtool). When releasing a UOR, that
# specific target is selected through injection of the 'INSTALL_TARGETS'
# variable. Many static analysis tool leverage the generated
# 'compile_commands.json' in order to know which sources to work with.
# Therefore, we should only add the necessary targets based on the UOR being
# built.
#
# To that purpose, we have to 'manually' build the reverse dependencies, so
# that we will only add targets to the intended ones, based on what is
# currently being built. We will set a "BMQ_TARGET_<xyz>_NEEDED" value to
# YES/NO.
# - if INSTALL_TARGETS is empty, this means we are not doing an integration
# build, but just a normal developer build, therefore include all targets
# - otherwise, selectively enable targets based on what is being built
if (NOT DEFINED INSTALL_TARGETS)
# If no specic install targets has been set, then enable them all
set(BMQ_TARGET_BMQBRKR_NEEDED YES)
set(BMQ_TARGET_BMQBRKRCFG_NEEDED YES)
set(BMQ_TARGET_BMQTOOL_NEEDED YES)
set(BMQ_TARGET_BMQSTORAGETOOL_NEEDED YES)
set(BMQ_TARGET_BMQ_NEEDED YES)
set(BMQ_TARGET_MQB_NEEDED YES)
set(BMQ_TARGET_E_BMQBRKR_NEEDED YES)
set(BMQ_TARGET_TUTORIAL_NEEDED YES)
set(BMQ_TARGET_PROMETHEUS_NEEDED NO)
else()
bbproject_check_install_target("bmqbrkr" installBMQBRKR)
bbproject_check_install_target("BMQBRKR_NIGHTLY" installNightly)
if (installNightly)
if (NOT installBMQBRKR)
string(APPEND INSTALL_TARGETS ";BMQBRKR")
set(installBMQBRKR YES)
endif()
endif()
# Disable all by default, and then we'll enable selectively based on the
# content of INSTALL_TARGETS
set(BMQ_TARGET_BMQBRKR_NEEDED NO)
set(BMQ_TARGET_BMQBRKRCFG_NEEDED NO)
set(BMQ_TARGET_BMQTOOL_NEEDED NO)
set(BMQ_TARGET_BMQSTORAGETOOL_NEEDED NO)
set(BMQ_TARGET_BMQ_NEEDED NO)
set(BMQ_TARGET_MQB_NEEDED NO)
set(BMQ_TARGET_TUTORIAL_NEEDED NO)
set(BMQ_TARGET_PROMETHEUS_NEEDED NO)
bbproject_check_install_target("bmq" installBMQ)
bbproject_check_install_target("mqb" installMQB)
bbproject_check_install_target("bmqbrkrcfg" installBMQBRKRCFG)
bbproject_check_install_target("bmqtool" installBMQTOOL)
bbproject_check_install_target("bmqstoragetool" installBMQSTORAGETOOL)
bbproject_check_install_target("prometheus" installPROMETHEUS)
if (installBMQ)
set(BMQ_TARGET_BMQ_NEEDED YES)
endif()
if (installMQB)
set(BMQ_TARGET_BMQ_NEEDED YES)
set(BMQ_TARGET_MQB_NEEDED YES)
endif()
if (installBMQBRKR)
set(BMQ_TARGET_BMQ_NEEDED YES)
set(BMQ_TARGET_MQB_NEEDED YES)
set(BMQ_TARGET_BMQBRKR_NEEDED YES)
set(BMQ_TARGET_E_BMQBRKR_NEEDED YES)
endif()
if (installBMQBRKRCFG)
set(BMQ_TARGET_BMQBRKRCFG_NEEDED YES)
endif()
if (installBMQTOOL)
set(BMQ_TARGET_BMQ_NEEDED YES)
set(BMQ_TARGET_MQB_NEEDED YES)
set(BMQ_TARGET_BMQTOOL_NEEDED YES)
endif()
if (installBMQSTORAGETOOL)
set(BMQ_TARGET_BMQ_NEEDED YES)
set(BMQ_TARGET_MQB_NEEDED YES)
set(BMQ_TARGET_BMQSTORAGETOOL_NEEDED YES)
endif()
if (installPROMETHEUS)
set(BMQ_TARGET_BMQ_NEEDED YES)
set(BMQ_TARGET_MQB_NEEDED YES)
set(BMQ_TARGET_PROMETHEUS_NEEDED YES)
endif()
endif()
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe HEAD
WORKING_DIRECTORY "${local_dir}"
OUTPUT_VARIABLE PROJECT_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
# -----------------------------------------------------------------------------
# DOCUMENTATION
# -----------------------------------------------------------------------------
find_package(Doxygen)
if(DOXYGEN_FOUND)
add_custom_target(docs
ALL
COMMENT "Build public and internal documentation"
)
# API Documentation for libbmq
# Each CMake variable `DOXYGEN_something` becomes a Doxygen configuration
# named `something`.
set(DOXYGEN_ALIASES
"bbref{1}=@ref BloombergLP::\\1 \\\"\\1\\\""
)
set(DOXYGEN_EXTRACT_ALL YES)
set(DOXYGEN_EXTRACT_STATIC YES)
set(DOXYGEN_EXCLUDE_PATTERNS *.t.cpp *.cpp)
set(DOXYGEN_EXCLUDE_SYMBOLS
BloombergLP::bmqimp
BloombergLP::bmqp
BloombergLP::bslmt
BloombergLP::bmqst
)
set(DOXYGEN_SHOW_INCLUDE_FILES NO)
set(DOXYGEN_SORT_MEMBER_DOCS NO)
set(DOXYGEN_PREDEFINED
"BSLS_KEYWORD_FINAL=final"
"BSLS_KEYWORD_DELETED=delete"
"BSLS_KEYWORD_OVERRIDE=override"
"BSLMF_NESTED_TRAIT_DECLARATION(..)="
)
set(DOXYGEN_EXPAND_AS_DEFINED
"BSLS_ASSERT_SAFE_IS_ACTIVE=1"
"BSLS_COMPILER_FEATURES_SUPPORT_GENERALIZED_INITIALIZERS"
"BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY"
"BSLS_LIBRARYFEATURES_HAS_CPP11_UNIQUE_PTR"
)
set(DOXYGEN_SHOW_NAMESPACES NO)
set(DOXYGEN_REPEAT_BRIEF YES)
set(DOXYGEN_INLINE_INHERITED_MEMB YES)
set(DOXYGEN_STRIP_FROM_PATH src/groups/bmq)
set(DOXYGEN_OUTPUT_DIRECTORY apidocs)
set(DOXYGEN_IMAGE_PATH docs/assets/images)
set(DOXYGEN_PROJECT_ICON docs/favicon.ico)
set(DOXYGEN_PROJECT_LOGO docs/assets/images/blazingmq_logo.svg)
set(DOXYGEN_PROJECT_NAME libbmq)
set(DOXYGEN_PROJECT_BRIEF
"C++ SDK for BlazingMQ clients and plugins"
)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE ./README.md)
set(DOXYGEN_REFERENCED_BY_RELATION YES)
set(DOXYGEN_REFERENCES YES)
set(DOXYGEN_ALPHABETICAL_INDEX NO)
set(DOXYGEN_FULL_SIDEBAR YES)
set(DOXYGEN_GENERATE_TREEVIEW YES)
doxygen_add_docs(
apidocs
src/groups/bmq/bmqa
src/groups/bmq/bmqt
src/groups/bmq/bmqpi
README.md
COMMENT "Generate public Doxygen documentation for libbmq"
)
add_dependencies(docs apidocs)
# Internal documentation for both libbmq and libmqb.
unset(DOXYGEN_EXCLUDE_SYMBOLS)
set(DOXYGEN_EXTRACT_PRIVATE YES)
set(DOXYGEN_SHOW_INCLUDE_FILES YES)
set(DOXYGEN_SHOW_NAMESPACES YES)
set(DOXYGEN_GENERATE_TODOLIST YES)
set(DOXYGEN_STRIP_FROM_PATH src/groups)
set(DOXYGEN_OUTPUT_DIRECTORY internaldocs)
doxygen_add_docs(
internaldocs
src/groups/
COMMENT "Generate internal Doxygen documentation for libbmq and libmqb"
)
add_dependencies(docs internaldocs)
endif()
# -----------------------------------------------------------------------------
# PROJECTS
# -----------------------------------------------------------------------------
add_subdirectory( "src/groups" )
add_subdirectory( "src/applications" )
add_subdirectory( "src/tutorials" )
add_subdirectory( "src/plugins" )