[Buildsystem] Only build KMSDRM support if EGL+OpenGL is detected by 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
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b9b9eb6..59ca6be 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1180,6 +1180,8 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS)
CheckOpenGLESX11()
CheckWayland()
CheckVivante()
+ # Need to check EGL before checking KMSDRM because KMSDRM depends on it.
+ CheckEGLKMSDRM()
CheckKMSDRM()
endif()
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index a9434c8..56f0a6a 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -759,6 +759,25 @@ endmacro()
# Requires:
# - PkgCheckModules
+macro(CheckEGLKMSDRM)
+ if (HAVE_VIDEO_OPENGLES OR HAVE_VIDEO_OPENGL)
+ pkg_check_modules(EGL egl)
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${EGL_CFLAGS}")
+ check_c_source_compiles("
+ #define EGL_API_FB
+ #define MESA_EGL_NO_X11_HEADERS
+ #define EGL_NO_X11
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGL_EGL)
+ if(HAVE_VIDEO_OPENGL_EGL)
+ set(SDL_VIDEO_OPENGL_EGL 1)
+ endif()
+ endif()
+endmacro()
+
+# Requires:
+# - PkgCheckModules
macro(CheckOpenGLESX11)
pkg_check_modules(EGL egl)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${EGL_CFLAGS}")
@@ -1152,7 +1171,7 @@ endmacro(CheckRPI)
macro(CheckKMSDRM)
if(VIDEO_KMSDRM)
pkg_check_modules(KMSDRM libdrm gbm egl)
- if(KMSDRM_FOUND)
+ if(KMSDRM_FOUND AND HAVE_VIDEO_OPENGL_EGL)
link_directories(
${KMSDRM_LIBRARY_DIRS}
)