diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2025-05-28 21:13:10 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2025-05-28 21:13:10 +0200 |
| commit | 3bc379bc4e159df66023ade31931133f7c78cb1f (patch) | |
| tree | d22d29cd7c4d42f2b04c6c189fcb6cab5c8045ae | |
| parent | 1a6322f8e1d74770b504f3912bda8fc022c93a42 (diff) | |
Fix usage of FLTK_BACKEND_WAYLAND and FLTK_USE_WAYLAND
- Do not change or remove the cache variable FLTK_BACKEND_WAYLAND:
this is an option set (and must only be changed) by the user.
- CMake/options.cmake: check Wayland availability if option
FLTK_BACKEND_WAYLAND is ON and set the result variable
FLTK_USE_WAYLAND accordingly.
- Replace FLTK_BACKEND_WAYLAND with FLTK_USE_WAYLAND everywhere
else, except as noted above: in options.cmake.
| -rw-r--r-- | CMake/options.cmake | 49 | ||||
| -rw-r--r-- | CMake/variables.cmake | 2 | ||||
| -rw-r--r-- | CMakeLists.txt | 10 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 18 |
4 files changed, 46 insertions, 33 deletions
diff --git a/CMake/options.cmake b/CMake/options.cmake index 3ff6d06f5..1ef64aad4 100644 --- a/CMake/options.cmake +++ b/CMake/options.cmake @@ -276,27 +276,40 @@ set(HAVE_LIBJPEG 1) if(UNIX) option(FLTK_INSTALL_LINKS "create backwards compatibility links" OFF) list(APPEND FLTK_LDLIBS -lm) + if(NOT APPLE) option(FLTK_BACKEND_WAYLAND "support the Wayland backend" ON) endif(NOT APPLE) + + # Check Wayland requirements and set the result variable FLTK_USE_WAYLAND. + # FLTK_USE_WAYLAND *must* be used *everywhere* else after these checks. + if(FLTK_BACKEND_WAYLAND) + message(STATUS "Checking Wayland requirements ...") + set(FLTK_USE_WAYLAND FALSE) # assume Wayland not OK ... + if(NOT PKG_CONFIG_FOUND) - message(FATAL_ERROR "Option FLTK_BACKEND_WAYLAND requires availability of pkg-config on the build machine.") - endif(NOT PKG_CONFIG_FOUND) + message(FATAL_ERROR "Option FLTK_BACKEND_WAYLAND requires pkg-config on the build host.") + endif() + pkg_check_modules(WLDCLIENT IMPORTED_TARGET wayland-client>=1.18) pkg_check_modules(WLDCURSOR IMPORTED_TARGET wayland-cursor) pkg_check_modules(WLDPROTO IMPORTED_TARGET wayland-protocols>=1.15) pkg_check_modules(XKBCOMMON IMPORTED_TARGET xkbcommon) - if(NOT(WLDCLIENT_FOUND AND WLDCURSOR_FOUND AND WLDPROTO_FOUND AND XKBCOMMON_FOUND)) - message(STATUS "Not all software modules 'wayland-client>=1.18 wayland-cursor wayland-protocols>=1.15 xkbcommon' are present") - message(STATUS "Consequently, FLTK_BACKEND_WAYLAND is turned off.") - unset(FLTK_BACKEND_WAYLAND CACHE) - set(FLTK_BACKEND_WAYLAND 0) - endif(NOT(WLDCLIENT_FOUND AND WLDCURSOR_FOUND AND WLDPROTO_FOUND AND XKBCOMMON_FOUND)) + + if(WLDCLIENT_FOUND AND WLDCURSOR_FOUND AND WLDPROTO_FOUND AND XKBCOMMON_FOUND) + set(FLTK_USE_WAYLAND TRUE) # OK, Wayland can be used + message(STATUS "Checking Wayland requirements: OK") + else() + message(NOTICE "Checking Wayland requirements FAILED!") + message(NOTICE " Not all required software modules for Wayland are present.") + message(NOTICE " The Wayland backend was requested but can't be built.") + message(NOTICE " Please check Wayland requirements (see above) or") + message(NOTICE " set FLTK_BACKEND_WAYLAND=OFF to silence this warning.") + endif() endif(FLTK_BACKEND_WAYLAND) - if(FLTK_BACKEND_WAYLAND) - set(FLTK_USE_WAYLAND 1) + if(FLTK_USE_WAYLAND) if(FLTK_BACKEND_X11) include(FindX11) endif() @@ -373,7 +386,7 @@ if(UNIX) endif(NOT LINUX_INPUT_H) endif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD") - endif(FLTK_BACKEND_WAYLAND) + endif(FLTK_USE_WAYLAND) endif(UNIX) if(WIN32) @@ -625,7 +638,7 @@ if(HAVE_GL) endif() if(FLTK_BUILD_GL) - if(FLTK_BACKEND_WAYLAND) + 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) @@ -636,7 +649,7 @@ if(FLTK_BUILD_GL) message(FATAL_ERROR "*** Aborting ***") endif() - endif(FLTK_BACKEND_WAYLAND) + endif(FLTK_USE_WAYLAND) if(FLTK_BACKEND_X11) set(OPENGL_FOUND TRUE) @@ -689,7 +702,7 @@ if(OPENGL_FOUND) list(APPEND GLLIBS -lglu32 -lopengl32) elseif(APPLE AND NOT FLTK_BACKEND_X11) list(APPEND GLLIBS "-framework OpenGL") - elseif(FLTK_BACKEND_WAYLAND) + elseif(FLTK_USE_WAYLAND) foreach(_lib WLD_EGL PKG_EGL PKG_GLU PKG_GL) list(APPEND GLLIBS ${${_lib}_LDFLAGS}) endforeach(_lib ) @@ -824,9 +837,9 @@ endif(FLTK_USE_XCURSOR) ####################################################################### if(X11_Xft_FOUND) option(FLTK_USE_PANGO "use lib Pango" OFF) - if(NOT FLTK_BACKEND_WAYLAND) + if(NOT FLTK_USE_WAYLAND) option(FLTK_GRAPHICS_CAIRO "all drawing to X11 windows uses Cairo" OFF) - endif(NOT FLTK_BACKEND_WAYLAND) + endif(NOT FLTK_USE_WAYLAND) if(NOT FLTK_GRAPHICS_CAIRO) option(FLTK_USE_XFT "use lib Xft" ON) endif() @@ -886,14 +899,14 @@ if((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND FLTK_USE_PANGO) endif((PANGOXFT_FOUND OR NOT USE_PANGOXFT) AND PANGOCAIRO_FOUND AND CAIRO_FOUND) - if(USE_PANGO AND (FLTK_GRAPHICS_CAIRO OR FLTK_BACKEND_WAYLAND)) + if(USE_PANGO AND (FLTK_GRAPHICS_CAIRO OR FLTK_USE_WAYLAND)) set(FLTK_USE_CAIRO 1) # fl_debug_var(FLTK_USE_CAIRO) endif() endif((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND FLTK_USE_PANGO) -if(FLTK_BACKEND_WAYLAND) +if(FLTK_USE_WAYLAND) # Note: Disable FLTK_USE_LIBDECOR_GTK to get cairo titlebars rather than GTK if(FLTK_USE_LIBDECOR_GTK AND NOT USE_SYSTEM_LIBDECOR) diff --git a/CMake/variables.cmake b/CMake/variables.cmake index 4d1be9f2d..b2993f032 100644 --- a/CMake/variables.cmake +++ b/CMake/variables.cmake @@ -43,7 +43,7 @@ if(WIN32) list(APPEND FLTK_LDLIBS -lole32 -luuid -lcomctl32 -lws2_32 -lwinspool) elseif(APPLE AND NOT FLTK_BACKEND_X11) list(APPEND FLTK_LDLIBS ${FLTK_COCOA_FRAMEWORKS}) -elseif(FLTK_BACKEND_WAYLAND) +elseif(FLTK_USE_WAYLAND) foreach(_lib WLDCURSOR WLDCLIENT XKBCOMMON DBUS) list(APPEND FLTK_LDLIBS "${${_lib}_LDFLAGS}") endforeach() diff --git a/CMakeLists.txt b/CMakeLists.txt index aeec6dfa8..4a45b5cc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,7 @@ endif() # for instance if FLTK is built as a subproject (FetchContent) set(FLTK_VERSION ${FLTK_VERSION} CACHE STRING - "FLTK version: generated, do not change" FORCE) + "FLTK version: generated by CMake, do not change" FORCE) ####################################################################### # basic setup @@ -405,19 +405,19 @@ fl_summary_image("Bundled Libraries" JPEG LIB_jpeg) fl_summary_image("" PNG LIB_png) fl_summary_image("" ZLIB LIB_zlib) -if(FLTK_BACKEND_WAYLAND) +if(FLTK_USE_WAYLAND) if(USE_SYSTEM_LIBDECOR) fl_summary("" "Libdecor = System: ${SYSTEM_LIBDECOR_LINK_LIBRARIES}") else() fl_summary("" "Libdecor = Bundled") endif() -endif(FLTK_BACKEND_WAYLAND) +endif(FLTK_USE_WAYLAND) message("") if(UNIX AND NOT (APPLE AND NOT FLTK_BACKEND_X11)) - if(FLTK_BACKEND_WAYLAND) + if(FLTK_USE_WAYLAND) if(FLTK_BACKEND_X11) fl_summary("Use Wayland" "Yes (can also run as X11 client)") else() @@ -425,7 +425,7 @@ if(UNIX AND NOT (APPLE AND NOT FLTK_BACKEND_X11)) endif(FLTK_BACKEND_X11) else() fl_summary("Use Wayland" "No (X11 is used)") - endif(FLTK_BACKEND_WAYLAND) + endif(FLTK_USE_WAYLAND) fl_summary_yn("All drawing uses Cairo" FLTK_USE_CAIRO) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f84d58d85..ed1cfc276 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -215,7 +215,7 @@ endif(FLTK_USE_X11 AND NOT FLTK_OPTION_PRINT_SUPPORT) set(DRIVER_FILES) -if(FLTK_USE_X11 AND NOT FLTK_BACKEND_WAYLAND) +if(FLTK_USE_X11 AND NOT FLTK_USE_WAYLAND) # X11 (including APPLE with X11) @@ -290,7 +290,7 @@ if(FLTK_USE_X11 AND NOT FLTK_BACKEND_WAYLAND) ) endif(FLTK_USE_CAIRO) -elseif(FLTK_BACKEND_WAYLAND) +elseif(FLTK_USE_WAYLAND) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${CMAKE_CURRENT_BINARY_DIR}") set(DRIVER_FILES drivers/Posix/Fl_Posix_System_Driver.cxx @@ -407,7 +407,7 @@ else() drivers/GDI/Fl_GDI_Image_Surface_Driver.H ) -endif(FLTK_USE_X11 AND NOT FLTK_BACKEND_WAYLAND) +endif(FLTK_USE_X11 AND NOT FLTK_USE_WAYLAND) source_group("Header Files" FILES ${HEADER_FILES}) source_group("Driver Source Files" FILES ${DRIVER_FILES}) @@ -457,7 +457,7 @@ set(GL_DRIVER_FILES drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx ) -if(FLTK_BACKEND_WAYLAND) +if(FLTK_USE_WAYLAND) set(GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx) set(GL_DRIVER_HEADER_FILES drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H) if(FLTK_USE_X11) @@ -473,7 +473,7 @@ elseif(APPLE) elseif(WIN32) set(GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx) set(GL_DRIVER_HEADER_FILES drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H) -endif(FLTK_BACKEND_WAYLAND) +endif(FLTK_USE_WAYLAND) set(GL_DRIVER_HEADER_FILES ${GL_DRIVER_FILES} drivers/OpenGL/Fl_OpenGL_Display_Device.H @@ -531,7 +531,7 @@ if(FLTK_USE_X11) endif(NOT USE_XFT) endif(FLTK_USE_X11) -if(FLTK_BACKEND_WAYLAND) +if(FLTK_USE_WAYLAND) pkg_check_modules(DBUS IMPORTED_TARGET dbus-1) set(IDIRS "${CMAKE_CURRENT_BINARY_DIR}") set(CDEFS "_GNU_SOURCE;HAVE_MEMFD_CREATE;HAVE_MKOSTEMP;HAVE_POSIX_FALLOCATE") @@ -593,7 +593,7 @@ if(FLTK_BACKEND_WAYLAND) ../libdecor/src/plugins/common/libdecor-cairo-blur.c ) endif(NOT USE_SYSTEM_LIBDECOR) -endif(FLTK_BACKEND_WAYLAND) +endif(FLTK_USE_WAYLAND) if(WIN32) list(APPEND CFILES @@ -734,7 +734,7 @@ if(USE_XFT) endif(LIB_fontconfig) endif(USE_XFT) -if(UNIX AND FLTK_BACKEND_WAYLAND) +if(UNIX AND FLTK_USE_WAYLAND) pkg_get_variable(PROTOCOLS wayland-protocols pkgdatadir) # replace "//" with "/" string(REPLACE "//" "/" PROTOCOLS ${PROTOCOLS}) @@ -813,7 +813,7 @@ if(UNIX AND FLTK_BACKEND_WAYLAND) append_optional_libs(PkgConfig::DBUS) endif() -endif(UNIX AND FLTK_BACKEND_WAYLAND) +endif(UNIX AND FLTK_USE_WAYLAND) list(REMOVE_DUPLICATES OPTIONAL_LIBS) list(REMOVE_DUPLICATES OPTIONAL_INCLUDES) |
