Make the 'Forms' compatibility library 'fltk_forms' optional

This library is no longer needed in FLTK itself. There is only one
demo program (test/forms.cxx) that uses it if it is built. The demo
program displays a message if fltk_forms is not available.

The default is 'enabled' for backwards compatibility but this may
be changed to 'disabled' in a future version.
This commit is contained in:
Albrecht Schlosser 2023-12-20 16:56:29 +01:00
parent 9023648e6c
commit 5df5daf78e
11 changed files with 152 additions and 59 deletions

View File

@ -396,14 +396,22 @@ option (OPTION_BUILD_SHARED_LIBS
)
#######################################################################
option (OPTION_PRINT_SUPPORT "allow print support" ON)
option (OPTION_FILESYSTEM_SUPPORT "allow file system support" ON)
option (FLTK_BUILD_FORMS "Build forms compatibility library" ON)
option (FLTK_BUILD_FLUID "Build FLUID" ON)
option (FLTK_BUILD_FLTK_OPTIONS "Build fltk-options" ON)
option (FLTK_BUILD_TEST "Build test/demo programs" ON)
option (FLTK_BUILD_EXAMPLES "Build example programs" OFF)
if (FLTK_BUILD_FORMS)
set (FLTK_HAVE_FORMS 1)
else ()
set (FLTK_HAVE_FORMS 0)
endif ()
if (DEFINED OPTION_BUILD_EXAMPLES)
message (WARNING
"'OPTION_BUILD_EXAMPLES' is obsolete, please use 'FLTK_BUILD_TEST' instead.")

View File

@ -227,6 +227,12 @@ else ()
message (STATUS "Shared libraries will not be built (set OPTION_BUILD_SHARED_LIBS=ON to build)")
endif ()
if (FLTK_BUILD_FORMS)
message (STATUS "The forms library will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib")
else ()
message (STATUS "The forms library will not be built (set FLTK_BUILD_FORMS=ON to build)")
endif ()
if (FLTK_BUILD_FLUID)
message (STATUS "FLUID will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fluid")
else ()

View File

@ -1,7 +1,7 @@
//
// Forms emulation header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2011 by Bill Spitzak and others.
// Copyright 1998-2023 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@ -47,7 +47,8 @@ typedef Fl_Window FL_FORM;
#define FL_CANCEL 0
#define FL_INVALID 0
#define FL_IGNORE -1
//#define FL_CLOSE -2 // this variable is never used in FLTK Forms. It is removed becaus it conflicts with the window FL_CLOSE event
// #define FL_CLOSE -2 // this variable is never used in FLTK Forms. It is removed
// because it conflicts with the window FL_CLOSE event
#define FL_LCOL FL_BLACK
#define FL_COL1 FL_GRAY

View File

@ -93,7 +93,7 @@ AS_IF([test x$enable_cp936 = xyes], [
CFLAGS="$CFLAGS -DCP936"
])
AC_ARG_ENABLE([cygwin], AS_HELP_STRING([--enable-cygwin], [use the Cygwin libraries (default=no)]))
AC_ARG_ENABLE([cygwin], AS_HELP_STRING([--enable-cygwin], [use the Cygwin DLL (default=no)]))
AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [turn on debugging]))
AS_IF([test x$enable_debug = xyes], [
@ -102,6 +102,8 @@ AS_IF([test x$enable_debug = xyes], [
DEBUGFLAG=""
])
AC_ARG_ENABLE([forms], AS_HELP_STRING([--disable-forms], [build Forms compatibility library (default=yes)]))
AC_ARG_ENABLE([gl], AS_HELP_STRING([--disable-gl], [turn off OpenGL support]))
AC_ARG_ENABLE([localjpeg], AS_HELP_STRING([--enable-localjpeg], [use local JPEG library (default=auto)]))
@ -170,7 +172,6 @@ AS_IF([test "x$with_archflags" != x], [
CFLAGS="$CFLAGS $with_archflags"
])
dnl FLTK build options to be used in Makefiles (defined in makeinclude)
BUILD=""
@ -200,24 +201,37 @@ AS_CASE([$host_os], [cygwin*], [
dnl Define the libraries and link options we will need.
LINKFLTK="../lib/libfltk.a"
LINKFLTKFORMS="../lib/libfltk_forms.a"
LINKFLTKGL="../lib/libfltk_gl.a"
LINKFLTKIMG="../lib/libfltk_images.a"
GLDEMOS="gldemos"
LIBEXT=".a"
LIBNAME="../lib/libfltk.a"
FLLIBNAME="../lib/libfltk_forms.a"
GLLIBNAME="../lib/libfltk_gl.a"
IMGLIBNAME="../lib/libfltk_images.a"
CAIROLIBNAME="../lib/libfltk_cairo.a"
LIBBASENAME="libfltk.a"
FLLIBBASENAME="libfltk_forms.a"
GLLIBBASENAME="libfltk_gl.a"
IMGLIBBASENAME="libfltk_images.a"
CAIROLIBBASENAME="libfltk_cairo.a"
dnl set library names etc. for the optional forms library and set 'build_forms'
dnl to make conditional code independent of the default value of 'enable_forms'
dnl which is 'yes' (enabled) in 1.4.0 (default may be changed later)
AS_IF([test x$enable_forms != xno], [
build_forms="yes"
LINKFLTKFORMS="../lib/libfltk_forms.a"
FLLIBNAME="../lib/libfltk_forms.a"
FLLIBBASENAME="libfltk_forms.a"
AC_DEFINE([FLTK_HAVE_FORMS])
], [
build_forms="no"
LINKFLTKFORMS=""
FLLIBNAME=""
FLLIBBASENAME=""
])
dnl Check for Cairo library unless disabled...
CAIRODIR=""
@ -261,7 +275,6 @@ AC_SUBST(CAIROLIBS)
AC_SUBST(LINKFLTKCAIRO)
AC_SUBST(FLTKCAIROOPTION)
AC_SUBST(FLLIBNAME)
AC_SUBST(GLDEMOS)
AC_SUBST(GLLIBNAME)
AC_SUBST(IMGLIBNAME)
@ -269,12 +282,10 @@ AC_SUBST(CAIROLIBNAME)
AC_SUBST(LIBEXT)
AC_SUBST(LIBNAME)
AC_SUBST(LINKFLTK)
AC_SUBST(LINKFLTKFORMS)
AC_SUBST(LINKFLTKGL)
AC_SUBST(LINKFLTKIMG)
AC_SUBST(LIBBASENAME)
AC_SUBST(FLLIBBASENAME)
AC_SUBST(GLLIBBASENAME)
AC_SUBST(IMGLIBBASENAME)
AC_SUBST(CAIROLIBBASENAME)
@ -432,7 +443,7 @@ AS_IF([test "x$enable_shared" = xyes], [
DSOCOMMAND="\$(CXX) \$(DSOFLAGS) -Wl,-soname,\$@ \$(LDLIBS) -shared $DEBUGFLAG -o"
])
LINKSHARED="-L../src $FLTKCAIROOPTION -lfltk_images$SHAREDSUFFIX -lfltk_forms$SHAREDSUFFIX -lfltk$SHAREDSUFFIX"
LINKSHARED="-L../src $FLTKCAIROOPTION -lfltk_images$SHAREDSUFFIX -lfltk$SHAREDSUFFIX"
], [
DSOCOMMAND="echo"
DSOLINK=""
@ -445,9 +456,21 @@ AS_IF([test "x$enable_shared" = xyes], [
SHAREDSUFFIX=""
FLUID="fluid"
FLTK_OPTIONS="fltk-options"
LINKSHARED="$LINKFLTKCAIRO ../lib/libfltk_images.a ../lib/libfltk_forms.a ../lib/libfltk.a"
LINKSHARED="$LINKFLTKCAIRO ../lib/libfltk_images.a ../lib/libfltk.a"
])
dnl reset FLDSONAME if the Forms compatibility library is disabled (not built):
dnl overwrite the variable because this is easier than adding conditional code above
AS_IF([test x$build_forms = xno], [
FLDSONAME=""
])
AC_SUBST([FLLIBNAME])
AC_SUBST([FLLIBBASENAME])
AC_SUBST([FLDSONAME])
AC_SUBST([LINKFLTKFORMS])
AC_SUBST([LINKSHARED])
dnl Define the fluid executable used when building the test programs.
dnl In a native build we use the fluid executable created during the build,
@ -463,12 +486,10 @@ AC_SUBST([DSOCOMMAND])
AC_SUBST([DSOFLAGS])
AC_SUBST([DSOLINK])
AC_SUBST([DSONAME])
AC_SUBST([FLDSONAME])
AC_SUBST([GLDSONAME])
AC_SUBST([IMGDSONAME])
AC_SUBST([CAIRODSONAME])
AC_SUBST([SHAREDSUFFIX])
AC_SUBST([LINKSHARED])
AC_SUBST([FLUID])
AC_SUBST([FLUID_BUILD])
AC_SUBST([FLTK_OPTIONS])
@ -1791,12 +1812,13 @@ AS_IF([test x$enable_fluid != xno], [
echo " Build fluid: NO"
])
dnl
echo "Cross-compiling: $fltk_cross_compiling"
AS_IF([test "$fltk_cross_compiling" = "yes"], [
echo "Cross-compiling: YES"
echo " Build: $build -> Host: $host"
], [
echo "Cross-compiling: NO"
])
dnl
echo " Graphics: $graphics"
dnl
AS_IF([test x$JPEG = x], [
@ -1814,6 +1836,13 @@ AS_IF([test x$ZLIB = x], [
], [
echo " ZLIB=Builtin"
])
AS_IF([test x$build_forms = xyes], [
echo "Forms library: YES"
], [
echo "Forms library: NO"
])
AS_IF([test x$enable_cairo = xyes], [
echo " CAIRO=lib"
])

View File

@ -2,7 +2,7 @@
/*
* Build configuration file for the Fast Light Tool Kit (FLTK).
*
* Copyright 1998-2021 by Bill Spitzak and others.
* Copyright 1998-2023 by Bill Spitzak and others.
*
* This library is free software. Distribution and use rights are outlined in
* the file "COPYING" which should have been included with this file. If this
@ -46,6 +46,15 @@
#cmakedefine FLTK_HAVE_CAIROEXT 1
/*
* FLTK_HAVE_FORMS
*
* Do we have the Forms compatibility library available?
*/
#cmakedefine FLTK_HAVE_FORMS 1
/*
* FLTK_USE_X11
*

View File

@ -1,7 +1,7 @@
/*
* Build configuration file for the Fast Light Tool Kit (FLTK).
*
* Copyright 1998-2021 by Bill Spitzak and others.
* Copyright 1998-2023 by Bill Spitzak and others.
*
* This library is free software. Distribution and use rights are outlined in
* the file "COPYING" which should have been included with this file. If this
@ -45,6 +45,15 @@
#undef FLTK_HAVE_CAIROEXT
/*
* FLTK_HAVE_FORMS
*
* Do we have the Forms compatibility library available?
*/
#undef FLTK_HAVE_FORMS
/*
* FLTK_USE_X11
*

View File

@ -25,7 +25,7 @@ OBJECTS = $(CPPFILES:.cxx=.o)
all: $(FLTK_OPTIONS) fltk-options$(EXEEXT)
fltk-options$(EXEEXT): $(OBJECTS) $(LIBNAME) $(FLLIBNAME)
fltk-options$(EXEEXT): $(OBJECTS) $(LIBNAME)
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(CXXFLAGS) -o $@ $(OBJECTS) $(LINKFLTKIMG) $(LDFLAGS) $(LDLIBS)
$(OSX_ONLY) $(RM) -r -f fltk-options.app
@ -34,7 +34,7 @@ fltk-options$(EXEEXT): $(OBJECTS) $(LIBNAME) $(FLLIBNAME)
$(OSX_ONLY) $(INSTALL) icons/fltk-options.icns fltk-options.app/Contents/Resources
$(OSX_ONLY) $(INSTALL) fltk-options.plist fltk-options.app/Contents/Info.plist
fltk-options-shared$(EXEEXT): $(OBJECTS) ../src/$(DSONAME) ../src/$(FLDSONAME)
fltk-options-shared$(EXEEXT): $(OBJECTS) ../src/$(DSONAME)
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(CXXFLAGS) -o $@ $(OBJECTS) $(LINKSHARED) $(LDFLAGS) $(LDLIBS)

View File

@ -66,8 +66,7 @@ OBJECTS = $(CPPFILES:.cxx=.o)
all: $(FLUID) fluid$(EXEEXT)
fluid$(EXEEXT): $(OBJECTS) $(LIBNAME) $(FLLIBNAME) \
$(IMGLIBNAME)
fluid$(EXEEXT): $(OBJECTS) $(LIBNAME) $(IMGLIBNAME)
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(CXXFLAGS) -o $@ $(OBJECTS) $(LINKFLTKIMG) $(LDFLAGS) $(LDLIBS)
$(OSX_ONLY) $(RM) -r -f fluid.app
@ -76,8 +75,7 @@ fluid$(EXEEXT): $(OBJECTS) $(LIBNAME) $(FLLIBNAME) \
$(OSX_ONLY) $(INSTALL) icons/fluid.icns fluid.app/Contents/Resources
$(OSX_ONLY) $(INSTALL) fluid.plist fluid.app/Contents/Info.plist
fluid-shared$(EXEEXT): $(OBJECTS) ../src/$(DSONAME) ../src/$(FLDSONAME) \
../src/$(IMGDSONAME)
fluid-shared$(EXEEXT): $(OBJECTS) ../src/$(DSONAME) ../src/$(IMGDSONAME)
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(CXXFLAGS) -o $@ $(OBJECTS) $(LINKSHARED) $(LDFLAGS) $(LDLIBS)

View File

@ -406,14 +406,18 @@ set (CPPFILES
${DRIVER_FILES}
)
set (FORMS_FILES
if (FLTK_BUILD_FORMS)
set (FORMS_FILES
forms_compatibility.cxx
forms_bitmap.cxx
forms_free.cxx
forms_fselect.cxx
forms_pixmap.cxx
forms_timer.cxx
)
)
else ()
set (FORMS_FILES "")
endif ()
set (GLCPPFILES
Fl_Gl_Choice.cxx
@ -759,8 +763,10 @@ endif()
#######################################################################
FL_ADD_LIBRARY (fltk_forms STATIC "${FORMS_FILES}")
target_link_libraries (fltk_forms fltk)
if (FLTK_BUILD_FORMS)
FL_ADD_LIBRARY (fltk_forms STATIC "${FORMS_FILES}")
target_link_libraries (fltk_forms fltk)
endif ()
#######################################################################
@ -806,8 +812,10 @@ if (OPTION_BUILD_SHARED_LIBS AND NOT MSVC)
###################################################################
if (FLTK_BUILD_FORMS)
FL_ADD_LIBRARY (fltk_forms SHARED "${FORMS_FILES}")
target_link_libraries (fltk_forms_SHARED fltk_SHARED)
endif ()
###################################################################

View File

@ -75,6 +75,14 @@ else ()
set (GLDEMO_SHARED fltk_SHARED)
endif ()
# Similar approach for the 'forms' demo (shared lib not supported)
if (FLTK_BUILD_FORMS)
set (FORMS_LIBS fltk_forms) # implies 'fltk' as well
else ()
set (FORMS_LIBS fltk)
endif ()
#######################################################################
CREATE_EXAMPLE (adjuster adjuster.cxx fltk)
@ -106,7 +114,7 @@ CREATE_EXAMPLE (flex_demo flex_demo.cxx fltk)
CREATE_EXAMPLE (flex_login flex_login.cxx fltk)
CREATE_EXAMPLE (fltk-versions fltk-versions.cxx fltk)
CREATE_EXAMPLE (fonts fonts.cxx fltk)
CREATE_EXAMPLE (forms forms.cxx "fltk_forms;fltk")
CREATE_EXAMPLE (forms forms.cxx "${FORMS_LIBS}")
CREATE_EXAMPLE (fullscreen fullscreen.cxx "${GLDEMO_LIBS}")
CREATE_EXAMPLE (grid_alignment grid_alignment.cxx fltk)
CREATE_EXAMPLE (grid_buttons grid_buttons.cxx fltk)

View File

@ -19,10 +19,13 @@
// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H> // FLTK: includes <FL/fl_config.h>
#ifdef FLTK_HAVE_FORMS // FLTK: defined in <FL/fl_config.h> since FLTK 1.4.0
#include <FL/forms.H> // changed for FLTK
static int border = 1; // changed from FL_TRANSIENT for FLTK
// (this is so the close box and Esc work to close the window)
// (this is so the close box and Esc work to close the window)
typedef struct { Fl_Boxtype val; const char *name; } VN_struct;
@ -173,4 +176,18 @@ int main(int argc, char *argv[]) {
;
return 0;
}
#else // (!FLTK_HAVE_FORMS)
#include <FL/fl_ask.H>
int main(int argc, char **argv) {
fl_message_title("This program needs the Forms compatibility library");
fl_message(
"Please configure FLTK with Forms enabled (--enable-forms)\n"
"or the CMake option FLTK_BUILD_FORMS=ON.");
return 0;
}
#endif // (FLTK_HAVE_FORMS)