Closed vanfanel closed 6 months ago
Thanks!
According to https://cmake.org/cmake/help/latest/policy/CMP0072.html, CMake should handle this automatically. Is it broken?
EDIT: I changed the target from OpenGL::GL
to OpenGL::OpenGL
which should work equally as your pull request if I'm not mistaken.
@deathkiller Sadly, even if I greatly prefer your way (in fact yout way is the correct way!), that doesn't work.
First problem is that doing find_package(OpenGL REQUIRED)
on a system without GLX, fails:
CMake Error at /usr/local/lib/python3.11/dist-packages/cmake/data/share/cmake-3.29/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find OpenGL (missing: OPENGL_glx_LIBRARY)
Call Stack (most recent call first):
/usr/local/lib/python3.11/dist-packages/cmake/data/share/cmake-3.29/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
/usr/local/lib/python3.11/dist-packages/cmake/data/share/cmake-3.29/Modules/FindOpenGL.cmake:579 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
cmake/ncine_imported_targets.cmake:210 (find_package)
CMakeLists.txt:73 (include)
...and since that fails, then OPENGL_FOUND is never set true, and thus this is never true and GL linkage fails:
I am using latest stable CMAKE here:
root@debian:~/src/j2/jazz2-native/b4# cmake --version
cmake version 3.29.3
...so it may be broken indeed. Maybe it's a CMake or MESA problem?
I think it's because the line here - https://github.com/Kitware/CMake/blob/master/Modules/FindOpenGL.cmake#L474, but I don't know why it's done like this.
I tried to set OPENGL_USE_OPENGL
in the latest commit, so the whole condition should be false and OPENGL_glx_LIBRARY
should be skipped. Let me know if it's any better.
@deathkiller Yes, that works. Thanks a lot. I had already opened a thread in https://discourse.cmake.org/t/gnu-linux-debian-12-cmake-fails-to-find-opengl-when-mesa-has-been-built-without-glx-support/10901 so I will add your findings there.
Really, thanks for going WAY out of your way and investigating this with me! :)
Great! Now, I'm not sure if I should prefer old OpenGL::GL
target or new OpenGL::OpenGL
target in official releases. Do you think there will be some compatibility problems with the new one?
Great! Now, I'm not sure if I should prefer old
OpenGL::GL
target or newOpenGL::OpenGL
target in official releases. Do you think there will be some compatibility problems with the new one?
There should be no problems with the OpenGL::OpenGL
target, every major distro has moved to GLVND years ago anyway or has both GLX and GLVND.
GLX is a legacy thing by now, bound to the dying X11 Xorg server. I wouldn't worry about it for a moment.
Modern Wayland-based GNU/Linux systems don't need to support legacy X11-based GLX OpenGL implementation: for full OpenGL, there's GLVND which MESA is commonly built with.
This allows jazz2-native to build on lightweight Wayland-based GNU/Linux systems that have no X11/GLX libs, but simply modern GLVND on KMS/DRM (=no desktop enviroment) or Wayland.
This does not break X11/GLX compatibility: on legacy X11-based systems, GLX is still used.