build: Use OpenGLES CMake module to gate OpenGL|ES support

This commit is contained in:
Ryan Pavlik 2020-07-17 11:44:50 -05:00
parent ccbd087dc2
commit 47a66e1bdf
2 changed files with 11 additions and 2 deletions

View file

@ -40,6 +40,7 @@ find_package(Threads)
find_package(ZLIB)
find_package(cJSON)
find_package(Systemd)
find_package(OpenGLES COMPONENTS V3)
# @TODO Turn into a find_package LIBUVC file.
pkg_check_modules(LIBUVC libuvc)
@ -82,9 +83,10 @@ cmake_dependent_option(CMAKE_INTERPROCEDURAL_OPTIMIZATION "Enable inter-procedur
cmake_dependent_option(XRT_HAVE_WAYLAND "Enable Wayland support" ON "WAYLAND_FOUND AND WAYLAND_SCANNER_FOUND AND WAYLAND_PROTOCOLS_FOUND" OFF)
cmake_dependent_option(XRT_HAVE_XLIB "Enable xlib support" ON "X11_FOUND" OFF)
cmake_dependent_option(XRT_HAVE_XCB "Enable xcb support" ON "XCB_FOUND" OFF)
cmake_dependent_option(XRT_HAVE_OPENGL "Enable OpenGL Graphics API support" ON "OPENGL_FOUND" OFF)
cmake_dependent_option(XRT_HAVE_OPENGLES "Enable OpenGL-ES Graphics API support" ON "XRT_HAVE_OPENGL OR ANDROID" OFF)
cmake_dependent_option(XRT_HAVE_VULKAN "Enable Vulkan Graphics API support (also needed for compositor)" ON "VULKAN_FOUND" OFF)
cmake_dependent_option(XRT_HAVE_OPENGL "Enable OpenGL Graphics API support" ON "OPENGL_FOUND" OFF)
cmake_dependent_option(XRT_HAVE_OPENGLES "Enable OpenGL-ES Graphics API support" ON "OpenGLES_FOUND" OFF)
cmake_dependent_option(XRT_HAVE_EGL "Enable OpenGL on EGL Graphics API support" ON "EGL_FOUND; XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES" OFF)
cmake_dependent_option(XRT_HAVE_DBUS "Enable dbus support (for BLE support)" ON "DBUS_FOUND" OFF)
cmake_dependent_option(XRT_FEATURE_COMPOSITOR_MAIN "Build main compositor host functionality" ON "XRT_HAVE_VULKAN; XRT_HAVE_WAYLAND OR XRT_HAVE_XCB" OFF)
@ -139,6 +141,10 @@ list(APPEND AVAILABLE_DRIVERS ARDUINO DUMMY HDK HYDRA NS OHMD PSMV PSVR RS V4L2
# Flags
###
if(XRT_HAVE_OPENGLES AND NOT XRT_HAVE_EGL)
message(FATAL_ERROR "XRT_HAVE_OPENGLES requires XRT_HAVE_EGL but XRT_HAVE_EGL is disabled")
endif()
if(XRT_HAVE_SDL2)
# Arch work around
if(NOT DEFINED SDL2_LIBRARIES)

View file

@ -132,6 +132,9 @@ if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES)
target_link_libraries(aux_ogl PUBLIC aux-includes)
# for GLAD
target_link_libraries(aux_ogl PUBLIC xrt-external-glad)
if(XRT_HAVE_OPENGLES)
target_link_libraries(aux_ogl PUBLIC OpenGLES::OpenGLESv3 EGL::EGL)
endif()
endif()
# OS library.