-
Notifications
You must be signed in to change notification settings - Fork 255
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
298 lines (244 loc) · 7.12 KB
/
CMakeLists.txt
File metadata and controls
298 lines (244 loc) · 7.12 KB
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
message(
STATUS "CMake version: "
${CMAKE_VERSION})
cmake_minimum_required(
VERSION 3.10 # include_guard command was introduced
# VERSION 3.11 for VS 2017 generator, 3.14 for VS 2019, 3.21 for VS 2022
FATAL_ERROR)
# ############################# Project generate options ###########################################################
project(
esmini
DESCRIPTION "esmini"
LANGUAGES C
CXX)
set(ENABLE_COLORED_DIAGNOSTICS
OFF
CACHE BOOL
"Enable colorful diagnostic messages from the compiler in console")
set(ENABLE_WARNINGS_AS_ERRORS
OFF
CACHE BOOL
"Make compile warnings be treated as errors")
set(ENABLE_CCACHE
OFF
CACHE BOOL
"Enable CCACHE")
set(ENABLE_COVERAGE
OFF
CACHE BOOL
"Enable code coverage (Will force no optimizations)")
set(ENABLE_SANITIZERS
OFF
CACHE BOOL
"Enable sanitizers (Only valid for Linux and Mac OS)")
set(ENABLE_INCLUDE_WHAT_YOU_USE
ON
CACHE BOOL
"Enable iwyu")
set(DOWNLOAD_EXTERNALS
ON
CACHE BOOL
"Download external packages")
set(USE_OSG
ON
CACHE BOOL
"If projects that depend on osg should be compiled.")
set(USE_OSI
ON
CACHE BOOL
"If code that depend on osi should be compiled.")
set(USE_SUMO
ON
CACHE BOOL
"If code that depend on sumo should be compiled.")
set(USE_GTEST
ON
CACHE BOOL
"If unit test suites based on googletest should be compiled.")
set(DYN_PROTOBUF
OFF
CACHE BOOL
"Set for dynamic linking of protobuf library (.so/.dll)")
set(USE_IMPLOT
ON
CACHE BOOL
"If implot for replayer gui or esmini real-time plotting should be compiled.")
set(BUILD_ODRPLOT
ON
CACHE BOOL
"If odrplot should be compiled.")
set(BUILD_REPLAYER
ON
CACHE BOOL
"If replayer should be compiled.")
set(BUILD_EXAMPLES
ON
CACHE BOOL
"If examples should be compiled.")
set(ESMINI_BUILD_VERSION
"N/A - client build"
CACHE STRING
"Esmini CI Build Version")
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING
"build mode")
set(FMT_INSTALL
OFF
CACHE BOOL
"If FMT should be installed")
# ############################### Setting project rules ############################################################
set_property(
GLOBAL
PROPERTY USE_FOLDERS
ON)
include(support/cmake/rule/project_options.cmake)
if(${CMAKE_SYSTEM_NAME}
MATCHES
"Linux")
set(LINUX
true)
else()
set(LINUX
false)
endif()
if(NOT
(LINUX
OR APPLE
OR MINGW
OR MSVC))
message(FATAL_ERROR "Unrecognized platform therefore there isn't an installation directory. Stopping the cmake process.")
endif()
# ############################### Loading common packages ############################################################
include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/common/color.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/common/locations.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/common/definitions.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/common/flags.cmake)
set_project_internal_paths()
set_project_external_paths()
set_project_os_specific_paths()
set_project_includes()
set_project_library_paths()
set_definitions()
set_special_build_flags()
# ############################### Loading utils packages ##############################################################
include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/utils/get_subdirectories.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/utils/set_folder.cmake)
# ############################### Downloading cloud packages #########################################################
if(DOWNLOAD_EXTERNALS)
include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/cloud/set_cloud_links.cmake)
set_cloud_links()
include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/cloud/download.cmake)
message(STATUS "Downloading dependencies...")
download(
osg
${EXTERNALS_OSG_PATH}
${EXTERNALS_OSG_OS_SPECIFIC_PATH}
"*"
"${OSG_PACKAGE_URL}")
download(
osi
${EXTERNALS_OSI_PATH}
${EXTERNALS_OSI_OS_SPECIFIC_PATH}
"*"
"${OSI_PACKAGE_URL}")
download(
sumo
${EXTERNALS_SUMO_PATH}
${EXTERNALS_SUMO_OS_SPECIFIC_PATH}
"*"
"${SUMO_PACKAGE_URL}")
download(
implot
${EXTERNALS_IMPLOT_PATH}
${EXTERNALS_IMPLOT_OS_SPECIFIC_PATH}
"*"
"${IMPLOT_PACKAGE_URL}")
download(
models
${RESOURCES_PATH}
${MODELS_PATH}
"models"
"${MODELS_PACKAGE_URL}")
if(NOT
(APPLE
OR MINGW))
download(
googletest
${EXTERNALS_GOOGLETEST_PATH}
${EXTERNALS_GOOGLETEST_OS_SPECIFIC_PATH}
"*"
"${GTEST_PACKAGE_URL}")
endif()
endif()
# ############################### Loading external packages ##########################################################
if(USE_GTEST)
include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/external/gtest.cmake)
set_gtest_libs()
endif()
if(USE_OSG)
include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/external/osg.cmake)
set_osg_libs()
endif()
if(USE_OSI)
include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/external/osi.cmake)
set_osi_libs()
endif()
if(USE_SUMO)
include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/external/sumo.cmake)
set_sumo_libs()
endif()
if(USE_IMPLOT)
include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/external/implot.cmake)
set_implot_libs()
endif()
# ############################### Resolve submodules #################################################################
if(NOT
EXISTS
"test/OSC-ALKS-scenarios/.git"
OR NOT
EXISTS
"test/OSC-NCAP-scenarios/.git"
OR NOT
EXISTS
"externals/fmt/.git")
execute_process(
COMMAND git submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
# ############################### Add submodules #####################################################################
set(YAML_LIBRARIES
yaml)
set(FMT_LIBRARIES
fmt)
set(CMAKE_POSITION_INDEPENDENT_CODE
ON)
set(FMT_SHARED
OFF)
if(LINUX)
set(FMT_LIBRARIES
${FMT_LIBRARIES}
"-lstdc++fs")
endif()
add_subdirectory(externals/fmt)
# target_compile_options( fmt PRIVATE -fPIC)
# ############################### OTHERS #############################################################################
# Add variables to global scope, e.g. when esmini is used as submodule
set(EXTERNALS_PUGIXML_PATH
${EXTERNALS_PUGIXML_PATH}
CACHE INTERNAL
"")
set(EXTERNALS_EXPR_PATH
${EXTERNALS_EXPR_PATH}
CACHE INTERNAL
"")
set(EXTERNALS_YAML_PATH
${EXTERNALS_YAML_PATH}
CACHE INTERNAL
"")
set(EXTERNALS_FMT_PATH
${EXTERNALS_FMT_PATH}
CACHE INTERNAL
"")
# ############################### Compiling targets ##################################################################
add_subdirectory(EnvironmentSimulator)