Skip to content

Commit

Permalink
Egl option (#135)
Browse files Browse the repository at this point in the history
* minimal changes to get platform linux to compile again

* adapt mbgl-glfw api for keyss to mbgl-offline and mbgl-render, use maptiler configuration for all three binaries

* add an option to compile with the egl backend on linux
  • Loading branch information
xabbu42 committed Aug 19, 2021
1 parent 408946a commit c0d76c6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -21,6 +21,7 @@ option(MBGL_WITH_QT "Build Mapbox GL Qt bindings" OFF)
option(MBGL_WITH_SANITIZER "Use [address|thread|undefined] here" OFF)
option(MBGL_WITH_RTTI "Compile with runtime type information" OFF)
option(MBGL_WITH_OPENGL "Build with OpenGL renderer" ON)
option(MBGL_WITH_EGL "Build with EGL renderer" OFF)
option(MBGL_WITH_WERROR "Make all compilation warnings errors" ON)

add_library(
Expand Down
7 changes: 7 additions & 0 deletions platform/glfw/CMakeLists.txt
Expand Up @@ -29,6 +29,13 @@ if(MBGL_WITH_OPENGL)
)
endif()

if(MBGL_WITH_EGL)
target_compile_definitions(
mbgl-glfw
PRIVATE MBGL_WITH_EGL=1
)
endif()

target_include_directories(
mbgl-glfw
PRIVATE
Expand Down
29 changes: 26 additions & 3 deletions platform/linux/linux.cmake
Expand Up @@ -2,7 +2,6 @@ find_package(CURL REQUIRED)
find_package(ICU OPTIONAL_COMPONENTS i18n)
find_package(ICU OPTIONAL_COMPONENTS uc)
find_package(JPEG REQUIRED)
find_package(OpenGL REQUIRED GLX)
find_package(PNG REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(X11 REQUIRED)
Expand Down Expand Up @@ -50,9 +49,34 @@ target_sources(
${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
${PROJECT_SOURCE_DIR}/platform/linux/src/headless_backend_glx.cpp
)

if(MBGL_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
)
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()

# FIXME: Should not be needed, but now needed by node because of the headless frontend.
target_include_directories(
mbgl-core
Expand Down Expand Up @@ -91,7 +115,6 @@ target_link_libraries(
$<$<NOT:$<BOOL:${MBGL_USE_BUILTIN_ICU}>>:ICU::i18n>
$<$<NOT:$<BOOL:${MBGL_USE_BUILTIN_ICU}>>:ICU::uc>
$<$<BOOL:${MBGL_USE_BUILTIN_ICU}>:mbgl-vendor-icu>
OpenGL::GLX
PNG::PNG
mbgl-vendor-nunicode
mbgl-vendor-sqlite
Expand Down

0 comments on commit c0d76c6

Please sign in to comment.