Skip to content

Commit 6b1dc9c

Browse files
committed
use cmake built-in FindOpenGL module for GLES with cmake 3.23+
1 parent d3928a7 commit 6b1dc9c

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ else()
169169
message(FATAL_ERROR "OpenGL ES 3 support is currently only available for Linux platforms. You're building for ${CMAKE_SYSTEM_NAME}.")
170170
endif()
171171

172-
# We use a local find script for OpenGL::GLES3 until the proposed changes are merged upstream.
173-
list(APPEND CMAKE_MODULE_PATH "${PROJECTM_SOURCE_DIR}/cmake/gles")
172+
if (CMAKE_VERSION VERSION_LESS_EQUAL "3.26" OR CMAKE_SYSTEM_NAME STREQUAL Android)
173+
# We use a local find script for OpenGL::GLES3 until the proposed changes are merged upstream.
174+
list(APPEND CMAKE_MODULE_PATH "${PROJECTM_SOURCE_DIR}/cmake/gles")
175+
endif()
174176
find_package(OpenGL REQUIRED COMPONENTS GLES3)
175177
if(NOT TARGET OpenGL::GLES3)
176178
message(FATAL_ERROR "No suitable GLES3 library was found.")

cmake/gles/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# GLES3 Find Script
22

33
The OpenGL CMake find script in this directory contains additional code to find GLES versions 1 to 3. It was taken from
4-
CMake 3.22 and patched accordingly. A merge request is underway upstream, so ideally, this will be part of CMake 3.23+.
4+
CMake 3.22 and patched accordingly. A merge request was accepted upstream, it is part of CMake 3.27.
55

6-
In the meantime, we'll use this script as a local copy if GLES3 support is requested. Will add a version check once it's
7-
in upstream CMake so this file will only be used if the CMake version used to build projectM is too low.
6+
We use this script for CMake lower than 3.27 as a local copy if GLES3 support is requested to provide compatibility. A version check
7+
compares the current CMake version so this file will only be used if the CMake version used to build projectM is too low.

src/libprojectM/projectM4Config.cmake.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ include(CMakeFindDependencyMacro)
66

77
if(NOT "@ENABLE_EMSCRIPTEN@") # ENABLE_EMSCRIPTEN
88
if("@ENABLE_GLES@") # ENABLE_GLES
9-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
10-
find_dependency(OpenGL COMPONENTS GLES3)
9+
if (CMAKE_VERSION VERSION_LESS_EQUAL "3.26" OR CMAKE_SYSTEM_NAME STREQUAL Android)
10+
set(PROJECTM4_PREV_MODULE_PATH ${CMAKE_MODULE_PATH})
11+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
12+
find_dependency(OpenGL COMPONENTS GLES3)
13+
set(CMAKE_MODULE_PATH ${PROJECTM4_PREV_MODULE_PATH})
14+
else()
15+
find_dependency(OpenGL COMPONENTS GLES3)
16+
endif()
1117
else()
1218
find_dependency(OpenGL)
1319
endif()

0 commit comments

Comments
 (0)