FLTK logo

[master] 0ba0519 - Have OPTION_USE_WAYLAND / --enable-wayland set to ON by default

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 0ba0519 - Have OPTION_USE_WAYLAND / --enable-wayland set to ON by default "ManoloFLTK" Nov 22, 2022  
 
commit 0ba051994a5b6a928db90a439461a37386e4d8e1
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Fri Nov 18 09:10:22 2022 +0100
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Wed Nov 23 06:17:31 2022 +0100

    Have OPTION_USE_WAYLAND / --enable-wayland set to ON by default

 .github/workflows/build.yml |  4 ++--
 CHANGES.txt                 |  2 +-
 CMake/options.cmake         | 12 ++++++++---
 README.CMake.txt            |  8 +++----
 README.Wayland.txt          | 51 ++++++++++++++++-----------------------------
 configure.ac                | 42 +++++++++++++++++++++++++++++--------
 6 files changed, 67 insertions(+), 52 deletions(-)

diff --git .github/workflows/build.yml .github/workflows/build.yml
index 92ce4b1..1ea37fb 100644
--- .github/workflows/build.yml
+++ .github/workflows/build.yml
@@ -33,7 +33,7 @@ jobs:
       # Note the current convention is to use the -S and -B options here to specify source
       # and build directories, but this is only available with CMake 3.13 and higher.
       # The CMake binaries on the Github Actions machines are (as of this writing) 3.12
-      run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
+      run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOPTION_USE_WAYLAND=OFF
 
     - name: Build
       working-directory: ${{github.workspace}}/build
@@ -63,7 +63,7 @@ jobs:
       # Note the current convention is to use the -S and -B options here to specify source
       # and build directories, but this is only available with CMake 3.13 and higher.
       # The CMake binaries on the Github Actions machines are (as of this writing) 3.12
-      run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOPTION_USE_WAYLAND=1
+      run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
 
     - name: Build
       working-directory: ${{github.workspace}}/build
diff --git CHANGES.txt CHANGES.txt
index 62c1eb5..1a18436 100644
--- CHANGES.txt
+++ CHANGES.txt
@@ -125,7 +125,7 @@ Changes in FLTK 1.4.0                            Released: ??? ?? 2022
     This option is OFF by default.
   - Configure option --enable-wayland allows to build the FLTK library for
     the new Wayland platform while remaining compatible with X11. The
-    corresponding CMake option is OPTION_USE_WAYLAND. This option is OFF by default.
+    corresponding CMake option is OPTION_USE_WAYLAND. This option is ON by default.
   - Configure options --enable-wayland --disable-x11 used together allow to
     build FLTK for the Wayland backend only (no x11 backend). Under CMake, the
     equivalent is to set both OPTION_USE_WAYLAND and OPTION_WAYLAND_ONLY.
diff --git CMake/options.cmake CMake/options.cmake
index cf49148..0536bd2 100644
--- CMake/options.cmake
+++ CMake/options.cmake
@@ -194,7 +194,9 @@ set (HAVE_LIBPNG 1)
 if (UNIX)
   option (OPTION_CREATE_LINKS "create backwards compatibility links" OFF)
   list (APPEND FLTK_LDLIBS -lm)
-  option (OPTION_USE_WAYLAND "support Wayland and X11 backends" OFF)
+  if (NOT APPLE)
+    option (OPTION_USE_WAYLAND "support both Wayland and X11 backends" ON)
+  endif (NOT APPLE)
   if (OPTION_USE_WAYLAND)
     pkg_check_modules(WLDCLIENT wayland-client)
     pkg_check_modules(WLDCURSOR wayland-cursor)
@@ -203,9 +205,13 @@ if (UNIX)
     pkg_check_modules(DBUS dbus-1)
     if (NOT(DBUS_FOUND AND WLDCLIENT_FOUND AND WLDCURSOR_FOUND AND WLDPROTO_FOUND AND XKBCOMMON_FOUND))
       message (STATUS "Not all software modules 'wayland-client wayland-cursor wayland-protocols xkbcommon dbus-1' are present")
-      message (STATUS "Consequently, building for the Wayland backend is not possible.")
-      message (FATAL_ERROR "*** Aborting ***")
+      message (STATUS "Consequently, OPTION_USE_WAYLAND is set to OFF.")
+      unset (OPTION_USE_WAYLAND CACHE)
+      set (OPTION_USE_WAYLAND 0)
     endif (NOT(DBUS_FOUND AND WLDCLIENT_FOUND AND WLDCURSOR_FOUND AND WLDPROTO_FOUND AND XKBCOMMON_FOUND))
+  endif (OPTION_USE_WAYLAND)
+    
+  if (OPTION_USE_WAYLAND)
     option (OPTION_WAYLAND_ONLY "support Wayland backend only" OFF)
     set (FLTK_USE_WAYLAND 1)
     if (NOT OPTION_WAYLAND_ONLY)
diff --git README.CMake.txt README.CMake.txt
index e83dc49..bc9e810 100644
--- README.CMake.txt
+++ README.CMake.txt
@@ -168,12 +168,12 @@ OPTION_USE_CAIRO - default OFF
 
 OPTION_USE_PANGO - default OFF
    Enables use of the Pango library for drawing text. Pango supports all
-   unicode-defined scripts with limited support of right-to-left scripts.
-   This option makes sense only under X11, and also requires Xft.
+   unicode-defined scripts and gives FLTK limited support of right-to-left
+   scripts. This option makes sense only under X11, and also requires Xft.
 
-OPTION_USE_WAYLAND - default OFF
+OPTION_USE_WAYLAND - default ON
    Enables the use of Wayland for all window operations, of Cairo for all
-   graphics and of Pango for text drawing (Linux only). Resulting FLTK
+   graphics and of Pango for text drawing (Linux+FreeBSD only). Resulting FLTK
    apps use Wayland when a Wayland compositor is available at run-time,
    and use X11 for their window operations otherwise, but keep using
    Cairo and Pango - see README.Wayland.txt.
diff --git README.Wayland.txt README.Wayland.txt
index 814a43e..4ab819b 100644
--- README.Wayland.txt
+++ README.Wayland.txt
@@ -38,7 +38,7 @@ CJK text-input methods, as well as dead and compose keys are supported.
 2 Wayland Support for FLTK
 ==========================
 
-On Linux and FreeBSD systems, the FLTK library can be configured so FLTK apps
+On Linux and FreeBSD systems, the FLTK library is by default configured so FLTK apps
 do all their windowing through the Wayland protocol, all their graphics with
 Cairo or EGL, and all text-drawing with Pango. If no Wayland compositor is
 available at run-time, FLTK apps fall back to using X11 for windowing.
@@ -62,30 +62,24 @@ with its Wayland backend only (see below).
  2.1 Configuration
 ------------------
 
-   2.1.1 Configure-based build can be performed as follows:
-Once after "git clone", create the configure file :
-  autoconf -f
+On Linux and FreeBSD systems equipped with the adequate software packages
+(see section 4 below), the default building procedure produces a Wayland/X11
+hybrid library. On systems lacking all or part of Wayland-required packages,
+the default building procedure produces a X11-based library.
 
-Prepare build with :
-  ./configure --enable-wayland
-Add  --disable-x11  to build FLTK for Wayland-only (no x11 backend).
+Use -DOPTION_USE_WAYLAND=OFF with CMake or "configure --disable-wayland" to build
+FLTK for the X11 library when the default would build for Wayland.
 
-Build with :
-  make
-
-   2.1.2 CMake-based build can be performed as follows:
-  cmake -S <path-to-source> -B <path-to-build>  -DOPTION_USE_WAYLAND=1
-
-  cd <path-to-build>; make
+CMake OPTION_WAYLAND_ONLY or "--disable-x11" configure argument can
+be used to produce a Wayland-only library which can be useful, e.g., when
+cross-compiling for systems that lack X11 headers and libraries.
 
 The FLTK Wayland platform uses a library called libdecor which handles window decorations
 (i.e., titlebars, shade). Libdecor is bundled in the FLTK source code and FLTK uses by default
-this form of libdecor. Optionally, OPTION_USE_SYSTEM_LIBDECOR can be turned on to have FLTK
+this form of libdecor. CMake OPTION_USE_SYSTEM_LIBDECOR can be turned on to have FLTK
 use the system's version of libdecor which is available on recent Linux distributions (e.g.,
 Debian Bookworm or more recent in packages libdecor-0-0 and libdecor-0-plugin-1-cairo).
 
-Optionally, OPTION_WAYLAND_ONLY can be turned on to build FLTK for Wayland-only (no x11 backend).
-
  2.2 Known Limitations
 ----------------------
 
@@ -132,7 +126,7 @@ function or variable.
 -----------------------------------------------------------------
 
 The recommended way to prepare and use platform-specific code that would contain
-both X11-specific and Wayland-specific parts is as follows :
+X11-specific and possibly Wayland-specific parts is as follows :
 
 a) Organize platform-specific code as follows :
 
@@ -143,9 +137,12 @@ a) Organize platform-specific code as follows :
   #elif defined(_WIN32)
      *** Windows-specific code ***
   #else
+  #  ifdef FLTK_USE_X11
      *** X11-specific code ***
-
+  #  endif
+  #  ifdef FLTK_USE_WAYLAND
      *** Wayland-specific code ***
+  #  endif
   #endif
 
 b) Make sure to use distinct names for global variables and functions
@@ -241,17 +238,5 @@ These packages are necessary to build the FLTK library and the sway compositor:
 pkg install git autoconf pkgconf xorg urwfonts gnome glew seatd sway \
                 dmenu-wayland dmenu evdev-proto
 
-The FLTK library can be built as follows using either configure or CMake :
-
-1) Using configure
-
-cd <path-to-FLTK-source-tree>
-autoconf -f
-./configure --enable-localzlib --enable-wayland
-make
-
-2) Using CMake
-
-cmake -S <path-to-source> -B <path-to-build> -DOPTION_USE_WAYLAND=1
-
-cd <path-to-build>; make
+If FLTK is built using the configure/make procedure, include argument "--enable-localzlib"
+in the "configure" command.
diff --git configure.ac configure.ac
index 9c36213..64dcaf4 100644
--- configure.ac
+++ configure.ac
@@ -110,7 +110,7 @@ AC_ARG_ENABLE([localzlib], AS_HELP_STRING([--enable-localzlib], [use local ZLIB
 
 AC_ARG_ENABLE([pango], AS_HELP_STRING([--enable-pango], [turn on Pango support]))
 
-AC_ARG_ENABLE([wayland], AS_HELP_STRING([--enable-wayland], [turn on hybrid Wayland/X11 support]))
+AC_ARG_ENABLE([wayland], AS_HELP_STRING([--disable-wayland], [turn off hybrid Wayland/X11 support]))
 
 AC_ARG_ENABLE([usecairo], AS_HELP_STRING([--enable-usecairo], [all drawing to X11 windows uses Cairo]))
 
@@ -977,16 +977,40 @@ AS_CASE([$host_os_gui], [cygwin* | mingw*], [
         AC_DEFINE([HAVE_PTHREAD])
         THREADS="threads$EXEEXT"
     ])
-
-    AS_IF([test x$enable_wayland = xyes], [
-      dnl Prepare for Wayland...
-
+    
+    AS_IF([test x$enable_wayland != xno], [
       AS_IF([test x$PKGCONFIG = x], [
-          dnl pkg-config is not available, issue warning and abort...
+        dnl pkg-config is not available, issue warning and possibly abort...
+        AS_IF([test x$enable_wayland = xyes], [
           AC_MSG_WARN([--enable-wayland: please install pkg-config.])
           AC_MSG_ERROR([Aborting.])
+        ],[
+          AC_MSG_WARN([pkg-config is not found. Continuing with --disable-wayland])
+          enable_wayland="no"
+        ])
+      ],[
+        missing="no"
+        AS_IF([$PKGCONFIG --exists wayland-client],[],[missing="yes"])
+        AS_IF([$PKGCONFIG --exists wayland-protocols],[],[missing="yes"])
+        AS_IF([$PKGCONFIG --exists wayland-cursor],[],[missing="yes"])
+        AS_IF([$PKGCONFIG --exists xkbcommon],[],[missing="yes"])
+        AS_IF([$PKGCONFIG --exists dbus-1],[],[missing="yes"])
+        AS_IF([$PKGCONFIG --exists pangocairo],[],[missing="yes"])
+        AS_IF([test x$missing = xyes], [
+            AC_MSG_WARN([These packages 'wayland-client wayland-protocols wayland-cursor xkbcommon dbus-1 pangocairo' are required to build FLTK for wayland.])
+            AC_MSG_WARN([At least one of them is missing.])
+          AS_IF([test x$enable_wayland = xyes], [
+            AC_MSG_ERROR([Building for Wayland is not possible. Aborting.])
+          ],[
+            AC_MSG_WARN([Continuing with --disable-wayland])
+            enable_wayland="no"
+          ])
+        ])
       ])
+    ])
 
+    AS_IF([test x$enable_wayland != xno], [
+      dnl Prepare for Wayland...
       dnl Turn option usecairo ON
       AC_DEFINE([FLTK_USE_CAIRO])
       AC_MSG_NOTICE([Turning on the usecairo option])
@@ -1001,7 +1025,7 @@ AS_CASE([$host_os_gui], [cygwin* | mingw*], [
        ])
       CFLAGS="$CFLAGS -DUSE_SYSTEM_LIBDECOR=0"
       CXXFLAGS="$CXXFLAGS -DUSE_SYSTEM_LIBDECOR=0"
-      LIBS="$LIBS $($PKGCONFIG --libs wayland-cursor) $($PKGCONFIG --libs wayland-client) $($PKGCONFIG --libs xkbcommon) $($PKGCONFIG --libs pangoxft) "
+      LIBS="$LIBS $($PKGCONFIG --libs wayland-cursor) $($PKGCONFIG --libs wayland-client) $($PKGCONFIG --libs xkbcommon) $($PKGCONFIG --libs pangocairo) "
       AS_IF([test x$enable_x11 != xno], [LIBS="$LIBS $($PKGCONFIG --libs x11)"] )
       LIBS="$LIBS $($PKGCONFIG --libs dbus-1) -ldl"
       CXXFLAGS="$CXXFLAGS -I../libdecor/src"
@@ -1145,7 +1169,7 @@ AS_CASE([$host_os_gui], [cygwin* | mingw*], [
 
     dnl Check for the Xft library unless disabled...
     xft_found=no
-    AS_IF([test x$enable_xft != xno], [
+    AS_IF([test x$enable_xft != xno -a x$enable_wayland = xno], [
         # Try pkg-config first (freetype2 deprecated freetype-config from some version on)
         FT_FLAGS=""
         AS_IF([test "x$PKGCONFIG" != x], [
@@ -1645,7 +1669,7 @@ AS_CASE([$host_os_gui], [cygwin* | mingw*], [
 ], [darwin*], [
     graphics="Quartz"
 ], [*], [
-    AS_IF([test x$enable_wayland != xyes], [
+    AS_IF([test x$enable_wayland = xno], [
         graphics="X11"
     ])
     AS_IF([test x$xft_found = xyes], [
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.