forked from osmandapp/OsmAnd-core
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
405 lines (389 loc) · 11.9 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
project(OsmAndCore)
# Bump this number each time a new source file is committed to repository, source file removed from repository or renamed: 116
set(target_specific_sources "")
set(target_specific_public_definitions "")
set(target_specific_public_includes "")
set(target_specific_public_libraries "")
set(target_specific_private_definitions "")
set(target_specific_dependencies "")
# Target specific
if (CMAKE_TARGET_OS STREQUAL "linux")
find_library(dl_LIBRARY dl)
find_library(rt_LIBRARY rt)
set(target_specific_public_libraries ${target_specific_public_libraries}
${dl_LIBRARY}
${rt_LIBRARY}
)
elseif (CMAKE_TARGET_OS STREQUAL "macosx")
find_library(objc_LIBRARY objc)
find_library(Cocoa_LIBRARY Cocoa)
find_library(CoreServices_LIBRARY CoreServices)
find_library(SystemConfiguration_LIBRARY SystemConfiguration)
find_library(CFNetwork_LIBRARY CFNetwork)
find_library(Security_LIBRARY Security)
find_library(z_LIBRARY z)
set(target_specific_public_libraries ${target_specific_public_libraries}
"${Cocoa_LIBRARY}/Cocoa"
"${CoreServices_LIBRARY}/CoreServices"
"${SystemConfiguration_LIBRARY}/SystemConfiguration"
"${CFNetwork_LIBRARY}/CFNetwork"
"${Security_LIBRARY}/Security"
${z_LIBRARY}
${objc_LIBRARY}
)
elseif (CMAKE_TARGET_OS STREQUAL "android")
find_library(dl_LIBRARY dl)
find_library(gnustl_shared_LIBRARY gnustl_shared)
find_library(log_LIBRARY log)
find_library(c_LIBRARY c)
find_library(gcc_LIBRARY gcc)
find_library(m_LIBRARY m)
set(target_specific_public_libraries ${target_specific_public_libraries}
${gnustl_shared_LIBRARY}
${log_LIBRARY}
${c_LIBRARY}
${gcc_LIBRARY}
${m_LIBRARY}
${dl_LIBRARY}
)
elseif (CMAKE_TARGET_OS STREQUAL "windows")
# This is not done via find_library() since under Linux it won't find needed library
#find_library(ws2_32_LIBRARY ws2_32)
set(target_specific_public_libraries ${target_specific_public_libraries}
#{ws2_32_LIBRARY}
ws2_32
)
endif()
if (CMAKE_COMPILER_FAMILY STREQUAL "msvc")
# Set warning level 4
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} /W4")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
# Force warning to be an error "deletion of pointer to incomplete type 'type'; no destructor called"
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} /we4150")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /we4150")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we4150")
# Disable following warnings:
# - C4290: 'C++ exception specification ignored except to indicate a function is not __declspec(nothrow)'
# - C4201: 'nonstandard extension used : nameless struct/union'
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} /wd4290 /wd4201")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4290 /wd4201")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4290 /wd4201")
elseif (CMAKE_COMPILER_FAMILY STREQUAL "gcc" OR CMAKE_COMPILER_FAMILY STREQUAL "clang")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()
if (CMAKE_TARGET_OS STREQUAL "linux" OR
CMAKE_TARGET_OS STREQUAL "macosx" OR
CMAKE_TARGET_OS STREQUAL "windows" OR
CMAKE_TARGET_OS STREQUAL "ios" OR
CMAKE_TARGET_OS STREQUAL "android")
file(GLOB sources_opengl "src/Map/OpenGL/*.c*")
file(GLOB headers_opengl "src/Map/OpenGL/*.h*")
set(target_specific_sources ${target_specific_sources}
${headers_opengl}
${sources_opengl}
)
set(target_specific_private_definitions ${target_specific_private_definitions}
-DOSMAND_OPENGL_RENDERERS_SUPPORTED
)
endif()
if (CMAKE_TARGET_OS STREQUAL "linux" OR
CMAKE_TARGET_OS STREQUAL "macosx" OR
CMAKE_TARGET_OS STREQUAL "windows")
find_package(OpenGL REQUIRED)
set(target_specific_public_definitions ${target_specific_public_definitions}
${OPENGL_DEFINITIONS}
)
set(target_specific_private_definitions ${target_specific_private_definitions}
-DOSMAND_OPENGL2PLUS_RENDERER_SUPPORTED
)
set(target_specific_public_includes ${target_specific_public_includes}
${OPENGL_INCLUDE_DIRS}
)
set(target_specific_public_libraries ${target_specific_public_libraries}
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
glew_static
)
set(target_specific_dependencies ${target_specific_dependencies}
glew_static
)
file(GLOB sources_opengl2plus "src/Map/OpenGL/OpenGL2plus/*.c*")
file(GLOB headers_opengl2plus "src/Map/OpenGL/OpenGL2plus/*.h*")
set(target_specific_sources ${target_specific_sources}
${headers_opengl2plus}
${sources_opengl2plus}
)
endif()
if (CMAKE_TARGET_OS STREQUAL "ios" OR
CMAKE_TARGET_OS STREQUAL "android")
set(target_specific_private_definitions ${target_specific_private_definitions}
-DOSMAND_OPENGLES2_RENDERER_SUPPORTED
)
file(GLOB sources_opengles2 "src/Map/OpenGL/OpenGLES2/*.c*")
file(GLOB headers_opengles2 "src/Map/OpenGL/OpenGLES2/*.h*")
set(target_specific_sources ${target_specific_sources}
${headers_opengles2}
${sources_opengles2}
)
if (CMAKE_TARGET_OS STREQUAL "android")
find_library(EGL_LIBRARY EGL)
find_library(GLESv2_LIBRARY GLESv2)
set(target_specific_public_libraries ${target_specific_public_libraries}
${EGL_LIBRARY}
${GLESv2_LIBRARY}
)
endif()
endif()
file(GLOB includes
"include/proper/*.h*"
"include/*.h*"
"include/OsmAndCore/*.h*"
"include/OsmAndCore/Data/*.h*"
"include/OsmAndCore/Map/*.h*"
#"include/OsmAndCore/Routing/*.h*"
"include/OsmAndCore/Search/*.h*")
file(GLOB headers
"src/*.h*"
"src/Data/*.h*"
"src/Map/*.h*"
#"src/Routing/*.h*"
"src/Search/*.h*")
file(GLOB sources
"src/*.c*"
"src/Data/*.c*"
"src/Map/*.c*"
#"src/Routing/*.c*"
"src/Search/*.c*")
set(merged_sources
${includes}
${headers}
${sources}
${sources_map}
${target_specific_sources}
"protos/OBF.pb.h"
)
set(merged_dependencies
skia_static
protobuf_static
gdal_static
icu4c_static
archive_static
${target_specific_dependencies}
)
set(merged_compile_definitions_public
-DGLM_SWIZZLE
${target_specific_public_definitions}
)
set(merged_compile_definitions_private
${target_specific_private_definitions}
)
set(merged_include_dirs_private
"${OSMAND_ROOT}/core/include/OsmAndCore"
"${OSMAND_ROOT}/core/include/OsmAndCore/Data"
"${OSMAND_ROOT}/core/include/OsmAndCore/Routing"
"${OSMAND_ROOT}/core/include/OsmAndCore/Map"
"${OSMAND_ROOT}/core/include/OsmAndCore/Search"
"${OSMAND_ROOT}/core/src"
"${OSMAND_ROOT}/core/src/Data"
"${OSMAND_ROOT}/core/src/Routing"
"${OSMAND_ROOT}/core/src/Map"
"${OSMAND_ROOT}/core/src/Search"
"${OSMAND_ROOT}/core/protos"
)
set(merged_include_dirs_public
"${OSMAND_ROOT}/core/include"
${target_specific_public_includes}
)
set(merged_link_libs_public
skia_static
protobuf_static
gdal_static
icu4c_static
archive_static
glm_headers_only
boost_static_precompiled
${target_specific_public_libraries}
)
if (OSMAND_OWN_SHIPPED_QT)
# When using embedded Qt, we need to use tools from either static or shared
# version of qt.
if (CMAKE_SHARED_LIBS_ALLOWED_ON_TARGET)
find_package(Qt5Core REQUIRED PATHS "${OSMAND_OWN_SHIPPED_QT_SHARED}/lib/cmake" NO_DEFAULT_PATH)
elseif (CMAKE_STATIC_LIBS_ALLOWED_ON_TARGET)
find_package(Qt5Core REQUIRED PATHS "${OSMAND_OWN_SHIPPED_QT_STATIC}/lib/cmake" NO_DEFAULT_PATH)
endif()
else()
# If not using embedded QT, find packages it as usual
find_package(Qt5Core REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5Sql REQUIRED)
endif()
if (CMAKE_SHARED_LIBS_ALLOWED_ON_TARGET)
# 'OsmAndCore_shared' - linking to Qt shared libraries (or any if not own-shipped), OsmAndCore shared
add_library(OsmAndCore_shared SHARED
${merged_sources})
add_dependencies(OsmAndCore_shared
${merged_dependencies})
target_compile_definitions(OsmAndCore_shared
PRIVATE
-DOSMAND_CORE_INTERNAL
-DOSMAND_CORE_EXPORTS
${merged_compile_definitions_private}
PUBLIC
${merged_compile_definitions_public}
)
target_include_directories(OsmAndCore_shared
PRIVATE
${merged_include_dirs_private}
PUBLIC
${merged_include_dirs_public}
)
if (OSMAND_OWN_SHIPPED_QT)
target_include_directories(OsmAndCore_shared
PUBLIC
"${OSMAND_OWN_SHIPPED_QT_SHARED}/include"
"${OSMAND_OWN_SHIPPED_QT_SHARED}/include/QtCore"
"${OSMAND_OWN_SHIPPED_QT_SHARED}/include/QtNetwork"
"${OSMAND_OWN_SHIPPED_QT_SHARED}/include/QtSql"
)
target_link_libraries(OsmAndCore_shared
LINK_PUBLIC
${Qt5Sql_SHARED_LIBRARIES}
${Qt5Network_SHARED_LIBRARIES}
${Qt5Core_SHARED_LIBRARIES}
)
else()
target_link_libraries(OsmAndCore_shared
LINK_PUBLIC
Qt5::Sql
Qt5::Network
Qt5::Core
)
endif()
target_link_libraries(OsmAndCore_shared
LINK_PUBLIC
${merged_link_libs_public}
)
endif()
if (CMAKE_STATIC_LIBS_ALLOWED_ON_TARGET AND
CMAKE_SHARED_LIBS_ALLOWED_ON_TARGET)
# 'OsmAndCore_static' - linking to Qt shared libraries (or any if not own-shipped), OsmAndCore static
add_library(OsmAndCore_static STATIC
${merged_sources})
add_dependencies(OsmAndCore_static
${merged_dependencies})
target_compile_definitions(OsmAndCore_static
PRIVATE
-DOSMAND_CORE_INTERNAL
${merged_compile_definitions_private}
PUBLIC
-DOSMAND_CORE_STATIC
${merged_compile_definitions_public}
)
target_include_directories(OsmAndCore_static
PRIVATE
${merged_include_dirs_private}
PUBLIC
${merged_include_dirs_public}
)
if (OSMAND_OWN_SHIPPED_QT)
target_include_directories(OsmAndCore_static
PUBLIC
"${OSMAND_OWN_SHIPPED_QT_SHARED}/include"
"${OSMAND_OWN_SHIPPED_QT_SHARED}/include/QtCore"
"${OSMAND_OWN_SHIPPED_QT_SHARED}/include/QtNetwork"
"${OSMAND_OWN_SHIPPED_QT_SHARED}/include/QtSql"
)
target_link_libraries(OsmAndCore_static
LINK_PUBLIC
${Qt5Sql_SHARED_LIBRARIES}
${Qt5Network_SHARED_LIBRARIES}
${Qt5Core_SHARED_LIBRARIES}
)
else()
target_link_libraries(OsmAndCore_static
LINK_PUBLIC
Qt5::Sql
Qt5::Network
Qt5::Core
)
endif()
target_link_libraries(OsmAndCore_static
LINK_PUBLIC
${merged_link_libs_public}
)
endif()
if (CMAKE_STATIC_LIBS_ALLOWED_ON_TARGET AND
OSMAND_OWN_SHIPPED_QT)
if (CMAKE_SHARED_LIBS_ALLOWED_ON_TARGET)
# 'OsmAndCore_shared_standalone' - linking to Qt static libraries, OsmAndCore shared
add_library(OsmAndCore_shared_standalone SHARED
${merged_sources})
add_dependencies(OsmAndCore_shared_standalone
${merged_dependencies})
target_compile_definitions(OsmAndCore_shared_standalone
PRIVATE
-DOSMAND_CORE_INTERNAL
-DOSMAND_CORE_EXPORTS
${merged_compile_definitions_private}
PUBLIC
${merged_compile_definitions_public}
)
target_include_directories(OsmAndCore_shared_standalone
PRIVATE
${merged_include_dirs_private}
PUBLIC
${merged_include_dirs_public}
)
target_include_directories(OsmAndCore_shared_standalone
PUBLIC
"${OSMAND_OWN_SHIPPED_QT_STATIC}/include"
"${OSMAND_OWN_SHIPPED_QT_STATIC}/include/QtCore"
"${OSMAND_OWN_SHIPPED_QT_STATIC}/include/QtNetwork"
"${OSMAND_OWN_SHIPPED_QT_STATIC}/include/QtSql"
)
target_link_libraries(OsmAndCore_shared_standalone
LINK_PUBLIC
${Qt5Sql_STATIC_LIBRARIES}
${Qt5Network_STATIC_LIBRARIES}
${Qt5Core_STATIC_LIBRARIES}
${merged_link_libs_public}
)
endif()
# 'OsmAndCore_static_standalone' - linking to Qt static libraries, OsmAndCore static
add_library(OsmAndCore_static_standalone STATIC
${merged_sources})
add_dependencies(OsmAndCore_static_standalone
${merged_dependencies})
target_compile_definitions(OsmAndCore_static_standalone
PRIVATE
-DOSMAND_CORE_INTERNAL
${merged_compile_definitions_private}
PUBLIC
-DOSMAND_CORE_STATIC
${merged_compile_definitions_public}
)
target_include_directories(OsmAndCore_static_standalone
PRIVATE
${merged_include_dirs_private}
PUBLIC
${merged_include_dirs_public}
)
target_include_directories(OsmAndCore_static_standalone
PUBLIC
"${OSMAND_OWN_SHIPPED_QT_STATIC}/include"
"${OSMAND_OWN_SHIPPED_QT_STATIC}/include/QtCore"
"${OSMAND_OWN_SHIPPED_QT_STATIC}/include/QtNetwork"
"${OSMAND_OWN_SHIPPED_QT_STATIC}/include/QtSql"
)
target_link_libraries(OsmAndCore_static_standalone
LINK_PUBLIC
${Qt5Sql_STATIC_LIBRARIES}
${Qt5Network_STATIC_LIBRARIES}
${Qt5Core_STATIC_LIBRARIES}
${merged_link_libs_public}
)
endif()