diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2025-11-02 15:05:38 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2025-11-02 15:13:29 +0100 |
| commit | f2db90cb77466d6720c348be78e491a7d00c9e8c (patch) | |
| tree | 7a5f620c92b191706d886d793669f5839684e537 /CMake | |
| parent | a128b7c95aad0a287b57a110034ed81b4166ca78 (diff) | |
Fix "CMake: Fallback to libOpenGL (no-X11 OpenGL)" (#1251)
Diffstat (limited to 'CMake')
| -rw-r--r-- | CMake/options.cmake | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/CMake/options.cmake b/CMake/options.cmake index ea265515b..f9855a298 100644 --- a/CMake/options.cmake +++ b/CMake/options.cmake @@ -642,25 +642,42 @@ if(FLTK_BUILD_GL) if(FLTK_USE_WAYLAND) pkg_check_modules(WLD_EGL IMPORTED_TARGET wayland-egl) pkg_check_modules(PKG_EGL IMPORTED_TARGET egl) - pkg_check_modules(PKG_GL IMPORTED_TARGET gl) + if(FLTK_BACKEND_X11) + pkg_check_modules(PKG_GL IMPORTED_TARGET gl) + else() + pkg_check_modules(PKG_GL IMPORTED_TARGET opengl) + endif() pkg_check_modules(PKG_GLU IMPORTED_TARGET glu) if(NOT (WLD_EGL_FOUND AND PKG_EGL_FOUND AND PKG_GL_FOUND AND PKG_GLU_FOUND)) - message(STATUS "Modules 'wayland-egl, egl, gl, and glu' are required to build for the Wayland backend.") + message(STATUS "Modules 'wayland-egl, egl, gl (or opengl), and glu' are required to build for the Wayland backend.") message(FATAL_ERROR "*** Aborting ***") endif() endif(FLTK_USE_WAYLAND) - if(FLTK_BACKEND_X11) + if(FLTK_BACKEND_X11 OR FLTK_USE_WAYLAND) set(OPENGL_FOUND TRUE) - find_library(OPENGL_LIB GL) + if(FLTK_BACKEND_X11) + find_library(OPENGL_LIB GL) + else() + find_library(OPENGL_LIB OpenGL) + endif(FLTK_BACKEND_X11) get_filename_component(PATH_TO_GLLIB ${OPENGL_LIB} DIRECTORY) find_library(GLU_LIB GLU) get_filename_component(PATH_TO_GLULIB ${GLU_LIB} DIRECTORY) - # FIXME: we should find a better way to resolve this issue: - # with GL, must use XQuartz libX11 else "Insufficient GL support" - set(OPENGL_LIBRARIES -L${PATH_TO_GLULIB} -L${PATH_TO_GLLIB} -lX11 -lGLU -lGL) + set(OPENGL_LIBRARIES -L${PATH_TO_GLULIB} -L${PATH_TO_GLLIB}) + if(APPLE) + # FIXME: we should find a better way to resolve this issue: + # with GL, must use XQuartz libX11 else "Insufficient GL support" + set(OPENGL_LIBRARIES ${OPENGL_LIBRARIES} -lX11) + endif(APPLE) + set(OPENGL_LIBRARIES ${OPENGL_LIBRARIES} -lGLU) + if(FLTK_BACKEND_X11) + set(OPENGL_LIBRARIES ${OPENGL_LIBRARIES} -lGL) + else() + set(OPENGL_LIBRARIES ${OPENGL_LIBRARIES} -lOpenGL) + endif(FLTK_BACKEND_X11) find_path(OPENGL_INCLUDE_DIR NAMES GL/gl.h OpenGL/gl.h HINTS ${X11_INCLUDE_DIR}) unset(HAVE_GL_GLU_H CACHE) find_file(HAVE_GL_GLU_H GL/glu.h PATHS ${X11_INCLUDE_DIR}) @@ -669,7 +686,7 @@ if(FLTK_BUILD_GL) if(APPLE) set(HAVE_GL_GLU_H ${HAVE_OPENGL_GLU_H}) endif(APPLE) - endif(FLTK_BACKEND_X11) + endif(FLTK_BACKEND_X11 OR FLTK_USE_WAYLAND) else(FLTK_BUILD_GL) set(OPENGL_FOUND FALSE) set(HAVE_GL FALSE) @@ -711,12 +728,16 @@ if(OPENGL_FOUND) list(APPEND GLLIBS -lGLU -lGL) endif(WIN32) - # check if function glXGetProcAddressARB exists - set(TEMP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) - set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_LIBRARIES}) - check_symbol_exists(glXGetProcAddressARB "glx.h" HAVE_GLXGETPROCADDRESSARB) - set(CMAKE_REQUIRED_LIBRARIES ${TEMP_REQUIRED_LIBRARIES}) - unset(TEMP_REQUIRED_LIBRARIES) + if (FLTK_BACKEND_X11) + # check if function glXGetProcAddressARB exists + set(TEMP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_LIBRARIES}) + check_symbol_exists(glXGetProcAddressARB "glx.h" HAVE_GLXGETPROCADDRESSARB) + set(CMAKE_REQUIRED_LIBRARIES ${TEMP_REQUIRED_LIBRARIES}) + unset(TEMP_REQUIRED_LIBRARIES) + else() + unset(HAVE_GLXGETPROCADDRESSARB CACHE) + endif(FLTK_BACKEND_X11) endif(OPENGL_FOUND) ####################################################################### |
