mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
Fix: don't link to OpenGL with SDL2 as backend; SDL2 dynamically loads it (#8745)
Although for developers this doesn't change anything, for our linux-generic binary it changes everything. Without this, the OpenGL dynamic library is dragged in as dependency, and as it depends on X11, that will be dragged in too. This is not something we prefer to have, as that won't run on as many machines as it could. SDL2 doesn't depend on OpenGL directly, as it tries to load it in on runtime. If found, it would work in exactly the same way as if we would link to OpenGL ourselves. As such, this is the best of both worlds: our linux-generics have less linked dependencies, and developers won't notice any difference. As a side-effect, if someone uses linux-generic on a machine that does not have any OpenGL package installed, it will gracefully fall back to the default backend of SDL instead.
This commit is contained in:
parent
d068d61f3c
commit
dc7ba33b51
@ -249,7 +249,16 @@ if(NOT OPTION_DEDICATED)
|
||||
link_package(Fontconfig TARGET Fontconfig::Fontconfig)
|
||||
link_package(ICU_lx)
|
||||
link_package(ICU_i18n)
|
||||
|
||||
if(SDL2_FOUND AND OPENGL_FOUND AND UNIX)
|
||||
# SDL2 dynamically loads OpenGL if needed, so do not link to OpenGL when
|
||||
# on Linux. For Windows, we need to link to OpenGL as we also have a win32
|
||||
# driver using it.
|
||||
add_definitions(-DWITH_OPENGL)
|
||||
message(STATUS "OpenGL found -- -DWITH_OPENGL -- (via SDL2)")
|
||||
else()
|
||||
link_package(OpenGL TARGET OpenGL::GL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
|
Loading…
Reference in New Issue
Block a user