Răsfoiți Sursa

Remove OpenGL::GL dependency for GL3 backends (#684)

Co-authored-by: Michael Ragazzon <[email protected]>
MicroBlock 1 an în urmă
părinte
comite
8ba63fb0ea
2 a modificat fișierele cu 10 adăugiri și 4 ștergeri
  1. 7 3
      Backends/CMakeLists.txt
  2. 3 1
      CMake/DependenciesForBackends.cmake

+ 7 - 3
Backends/CMakeLists.txt

@@ -70,12 +70,16 @@ target_sources(rmlui_backend_SDL_GL3 INTERFACE
 	"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Renderer_GL3.h"
 	"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Renderer_GL3.h"
 	"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Include_GL3.h"
 	"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Include_GL3.h"
 )
 )
-target_link_libraries(rmlui_backend_SDL_GL3 INTERFACE rmlui_backend_common_headers OpenGL::GL SDL2::SDL2 SDL2_image::SDL2_image)
+target_link_libraries(rmlui_backend_SDL_GL3 INTERFACE rmlui_backend_common_headers SDL2::SDL2 SDL2_image::SDL2_image)
 if(UNIX)
 if(UNIX)
 	# The OpenGL 3 renderer implementation uses dlopen/dlclose
 	# The OpenGL 3 renderer implementation uses dlopen/dlclose
 	# This is required in some UNIX and UNIX-like operating systems to load shared object files at runtime
 	# This is required in some UNIX and UNIX-like operating systems to load shared object files at runtime
 	target_link_libraries(rmlui_backend_SDL_GL3 INTERFACE ${CMAKE_DL_LIBS})
 	target_link_libraries(rmlui_backend_SDL_GL3 INTERFACE ${CMAKE_DL_LIBS})
 endif()
 endif()
+if(EMSCRIPTEN)
+	# Only Emscripten requires linking to OpenGL::GL, for other platforms we use 'glad' as an OpenGL loader.
+	target_link_libraries(rmlui_backend_SDL_GL3 INTERFACE OpenGL::GL)
+endif()
 
 
 add_library(rmlui_backend_SDL_VK INTERFACE)
 add_library(rmlui_backend_SDL_VK INTERFACE)
 target_sources(rmlui_backend_SDL_VK INTERFACE
 target_sources(rmlui_backend_SDL_VK INTERFACE
@@ -135,7 +139,7 @@ target_sources(rmlui_backend_GLFW_GL3 INTERFACE
 	"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Renderer_GL3.h"
 	"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Renderer_GL3.h"
 	"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Include_GL3.h"
 	"${CMAKE_CURRENT_LIST_DIR}/RmlUi_Include_GL3.h"
 )
 )
-target_link_libraries(rmlui_backend_GLFW_GL3 INTERFACE rmlui_backend_common_headers OpenGL::GL glfw)
+target_link_libraries(rmlui_backend_GLFW_GL3 INTERFACE rmlui_backend_common_headers glfw)
 if(UNIX)
 if(UNIX)
 	# The OpenGL 3 renderer implementation uses dlopen/dlclose
 	# The OpenGL 3 renderer implementation uses dlopen/dlclose
 	# This is required in some UNIX and UNIX-like operating systems to load shared object files at runtime
 	# This is required in some UNIX and UNIX-like operating systems to load shared object files at runtime
@@ -177,7 +181,7 @@ target_sources(rmlui_backend_BackwardCompatible_GLFW_GL3 INTERFACE
 	"${CMAKE_CURRENT_LIST_DIR}/RmlUi_BackwardCompatible/RmlUi_Renderer_BackwardCompatible_GL3.h"
 	"${CMAKE_CURRENT_LIST_DIR}/RmlUi_BackwardCompatible/RmlUi_Renderer_BackwardCompatible_GL3.h"
 	"${CMAKE_CURRENT_LIST_DIR}/RmlUi_BackwardCompatible/RmlUi_Backend_BackwardCompatible_GLFW_GL3.cpp"
 	"${CMAKE_CURRENT_LIST_DIR}/RmlUi_BackwardCompatible/RmlUi_Backend_BackwardCompatible_GLFW_GL3.cpp"
 )
 )
-target_link_libraries(rmlui_backend_BackwardCompatible_GLFW_GL3 INTERFACE rmlui_backend_common_headers OpenGL::GL glfw)
+target_link_libraries(rmlui_backend_BackwardCompatible_GLFW_GL3 INTERFACE rmlui_backend_common_headers glfw)
 if(UNIX)
 if(UNIX)
 	# The OpenGL 3 renderer implementation uses dlopen/dlclose
 	# The OpenGL 3 renderer implementation uses dlopen/dlclose
 	# This is required in some UNIX and UNIX-like operating systems to load shared object files at runtime
 	# This is required in some UNIX and UNIX-like operating systems to load shared object files at runtime

+ 3 - 1
CMake/DependenciesForBackends.cmake

@@ -163,7 +163,9 @@ if(RMLUI_BACKEND MATCHES "GL2$")
 	report_dependency_found_or_error("OpenGL" OpenGL::GL)
 	report_dependency_found_or_error("OpenGL" OpenGL::GL)
 endif()
 endif()
 
 
-if(RMLUI_BACKEND MATCHES "GL3$")
+# We use 'glad' as an OpenGL loader for GL3 backends, thus we don't normally need to link to OpenGL::GL. The exception
+# is for Emscripten, where we use a custom find module to provide OpenGL support.
+if(EMSCRIPTEN AND RMLUI_BACKEND MATCHES "GL3$")
 	find_package("OpenGL" "3")
 	find_package("OpenGL" "3")
 	report_dependency_found_or_error("OpenGL" OpenGL::GL)
 	report_dependency_found_or_error("OpenGL" OpenGL::GL)
 endif()
 endif()