-
-
Notifications
You must be signed in to change notification settings - Fork 310
/
linux.cmake
241 lines (215 loc) · 8.18 KB
/
linux.cmake
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
option(MLN_WITH_X11 "Build with X11 Support" ON)
option(MLN_WITH_WAYLAND "Build with Wayland Support" OFF)
find_package(CURL REQUIRED)
find_package(ICU OPTIONAL_COMPONENTS i18n)
find_package(ICU OPTIONAL_COMPONENTS uc)
find_package(JPEG REQUIRED)
find_package(PNG REQUIRED)
find_package(PkgConfig REQUIRED)
if (MLN_WITH_X11)
find_package(X11 REQUIRED)
endif ()
find_package(Threads REQUIRED)
pkg_search_module(WEBP libwebp REQUIRED)
pkg_search_module(LIBUV libuv REQUIRED)
if(MLN_WITH_WAYLAND)
# See https://github.com/maplibre/maplibre-native/pull/2022
# MLN_WITH_EGL needs to be set for Wayland, otherwise this CMakeLists will
# call find_package(OpenGL REQUIRED GLX), which is for X11.
set(MLN_WITH_EGL TRUE)
# OPENGL_USE_GLES2 or OPENGL_USE_GLES3 need to be set, otherwise
# FindOpenGL.cmake will include the GLVND library, which is for X11.
set(OPENGL_USE_GLES3 TRUE)
endif()
target_sources(
mbgl-core
PRIVATE
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/gfx/headless_backend.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/gfx/headless_frontend.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/gl/headless_backend.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/i18n/collator.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/i18n/number_format.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/layermanager/layer_manager.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/platform/time.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/asset_file_source.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/database_file_source.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/file_source_manager.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/file_source_request.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/http_file_source.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/local_file_request.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/local_file_source.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/mbtiles_file_source.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/main_resource_loader.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/offline.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/offline_database.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/offline_download.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/online_file_source.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/storage/sqlite3.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/text/bidi.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/text/local_glyph_rasterizer.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/async_task.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/compression.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/filesystem.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/image.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/jpeg_reader.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/webp_reader.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/logging_stderr.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/monotonic_timer.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/png_reader.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/png_writer.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/run_loop.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/string_stdlib.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/thread.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/thread_local.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/timer.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/utf.cpp
${PROJECT_SOURCE_DIR}/platform/linux/src/gl_functions.cpp
)
if(MLN_WITH_EGL)
find_package(OpenGL REQUIRED EGL)
target_sources(
mbgl-core
PRIVATE
${PROJECT_SOURCE_DIR}/platform/linux/src/headless_backend_egl.cpp
)
target_link_libraries(
mbgl-core
PRIVATE
OpenGL::EGL
)
if (MLN_WITH_WAYLAND)
target_compile_definitions(mbgl-core PUBLIC
EGL_NO_X11
MESA_EGL_NO_X11_HEADERS
WL_EGL_PLATFORM
)
endif()
elseif(MLN_WITH_VULKAN)
target_include_directories(
mbgl-core
PRIVATE
${PROJECT_SOURCE_DIR}/vendor/Vulkan-Headers/include
)
target_sources(
mbgl-core
PRIVATE
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/vulkan/headless_backend.cpp
)
else()
find_package(OpenGL REQUIRED GLX)
target_sources(
mbgl-core
PRIVATE
${PROJECT_SOURCE_DIR}/platform/linux/src/headless_backend_glx.cpp
)
target_link_libraries(
mbgl-core
PRIVATE
OpenGL::GLX
)
endif()
if (DEFINED ENV{CI})
message("Building for CI")
target_compile_definitions(
mbgl-core
PRIVATE
CI_BUILD=1
)
endif()
# FIXME: Should not be needed, but now needed by node because of the headless frontend.
target_include_directories(
mbgl-core
PUBLIC ${PROJECT_SOURCE_DIR}/platform/default/include
PRIVATE
${CURL_INCLUDE_DIRS}
${JPEG_INCLUDE_DIRS}
${LIBUV_INCLUDE_DIRS}
${X11_INCLUDE_DIRS}
${WEBP_INCLUDE_DIRS}
)
include(${PROJECT_SOURCE_DIR}/vendor/nunicode.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/sqlite.cmake)
if(NOT ${ICU_FOUND} OR "${ICU_VERSION}" VERSION_LESS 62.0)
message(STATUS "ICU not found or too old, using builtin.")
set(MLN_USE_BUILTIN_ICU TRUE)
include(${PROJECT_SOURCE_DIR}/vendor/icu.cmake)
set_source_files_properties(
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/i18n/number_format.cpp
PROPERTIES
COMPILE_DEFINITIONS
MBGL_USE_BUILTIN_ICU
)
endif()
target_link_libraries(
mbgl-core
PRIVATE
${CURL_LIBRARIES}
${JPEG_LIBRARIES}
${LIBUV_LIBRARIES}
${X11_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${WEBP_LIBRARIES}
$<$<NOT:$<BOOL:${MLN_USE_BUILTIN_ICU}>>:ICU::i18n>
$<$<NOT:$<BOOL:${MLN_USE_BUILTIN_ICU}>>:ICU::uc>
$<$<BOOL:${MLN_USE_BUILTIN_ICU}>:mbgl-vendor-icu>
PNG::PNG
mbgl-vendor-nunicode
mbgl-vendor-sqlite
)
add_subdirectory(${PROJECT_SOURCE_DIR}/bin)
add_subdirectory(${PROJECT_SOURCE_DIR}/expression-test)
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/glfw)
if(MLN_WITH_NODE)
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/node)
endif()
add_executable(
mbgl-test-runner
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/test/main.cpp
)
target_compile_definitions(
mbgl-test-runner
PRIVATE
WORK_DIRECTORY=${PROJECT_SOURCE_DIR}
)
if (DEFINED ENV{CI})
message("Building for CI")
target_compile_definitions(
mbgl-test-runner
PRIVATE
CI_BUILD=1
)
endif()
target_link_libraries(
mbgl-test-runner
PRIVATE
mbgl-compiler-options
-Wl,--whole-archive
mbgl-test
-Wl,--no-whole-archive
)
add_executable(
mbgl-benchmark-runner
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/benchmark/main.cpp
)
target_link_libraries(
mbgl-benchmark-runner
PRIVATE
mbgl-compiler-options
-Wl,--whole-archive
mbgl-benchmark
-Wl,--no-whole-archive
)
add_executable(
mbgl-render-test-runner
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/render-test/main.cpp
)
target_link_libraries(
mbgl-render-test-runner
PRIVATE mbgl-compiler-options mbgl-render-test
)
# Disable benchmarks in CI as they run in VM environment
if(NOT DEFINED ENV{CI})
add_test(NAME mbgl-benchmark-runner COMMAND mbgl-benchmark-runner WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
endif()
add_test(NAME mbgl-test-runner COMMAND mbgl-test-runner WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
install(TARGETS mbgl-render-test-runner RUNTIME DESTINATION bin)