diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2023-12-20 16:56:29 +0100 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2023-12-20 17:33:37 +0100 |
| commit | 5df5daf78e135e0c8371012ffe56df5cae357755 (patch) | |
| tree | afd619b32d1f35b949f07b9dd35f0184400a1f93 | |
| parent | 9023648e6c182a4142894b3e6c1b309b699b0629 (diff) | |
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.
| -rw-r--r-- | CMake/options.cmake | 20 | ||||
| -rw-r--r-- | CMakeLists.txt | 26 | ||||
| -rw-r--r-- | FL/forms.H | 5 | ||||
| -rw-r--r-- | configure.ac | 63 | ||||
| -rw-r--r-- | fl_config.cmake.in | 11 | ||||
| -rw-r--r-- | fl_config.in | 11 | ||||
| -rw-r--r-- | fltk-options/Makefile | 4 | ||||
| -rw-r--r-- | fluid/Makefile | 6 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 32 | ||||
| -rw-r--r-- | test/CMakeLists.txt | 10 | ||||
| -rw-r--r-- | test/forms.cxx | 23 |
11 files changed, 152 insertions, 59 deletions
diff --git a/CMake/options.cmake b/CMake/options.cmake index 8e8ee02e4..0a774b09b 100644 --- a/CMake/options.cmake +++ b/CMake/options.cmake @@ -396,13 +396,21 @@ 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_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) +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 diff --git a/CMakeLists.txt b/CMakeLists.txt index d2ae79f14..210cfa0d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,34 +219,40 @@ message ("") set (_descr "${PROJECT_NAME} ${FLTK_VERSION} generated by CMake ${CMAKE_VERSION}") feature_summary (WHAT ALL DESCRIPTION "Configuration Summary for ${_descr} --\n") -message (STATUS "Static libraries will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib") +message (STATUS "Static libraries will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib") if (OPTION_BUILD_SHARED_LIBS) - message (STATUS "Shared libraries will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib") + message (STATUS "Shared libraries will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib") else () - message (STATUS "Shared libraries will not be built (set OPTION_BUILD_SHARED_LIBS=ON to build)") + 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") + message (STATUS "FLUID will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fluid") else () - message (STATUS "FLUID will not be built (set FLTK_BUILD_FLUID=ON to build)") + message (STATUS "FLUID will not be built (set FLTK_BUILD_FLUID=ON to build)") endif () if (FLTK_BUILD_FLTK_OPTIONS) - message (STATUS "fltk-options will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fltk-options") + message (STATUS "fltk-options will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fltk-options") else () - message (STATUS "fltk-options will not be built (set FLTK_BUILD_FLTK_OPTIONS=ON to build)") + message (STATUS "fltk-options will not be built (set FLTK_BUILD_FLTK_OPTIONS=ON to build)") endif () if (FLTK_BUILD_TEST) - message (STATUS "Test programs will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/test") + message (STATUS "Test programs will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/test") endif () if (FLTK_BUILD_EXAMPLES) - message (STATUS "Example programs will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/examples") + message (STATUS "Example programs will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/examples") else () - message (STATUS "Example programs will not be built (set FLTK_BUILD_EXAMPLES=ON to build)") + message (STATUS "Example programs will not be built (set FLTK_BUILD_EXAMPLES=ON to build)") endif () message (STATUS "") diff --git a/FL/forms.H b/FL/forms.H index 594ef0c6d..9523b4da5 100644 --- a/FL/forms.H +++ b/FL/forms.H @@ -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 diff --git a/configure.ac b/configure.ac index afeac90d0..fe9b7aeb6 100644 --- a/configure.ac +++ b/configure.ac @@ -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)])) @@ -145,9 +147,9 @@ AC_ARG_ENABLE([xrender], AS_HELP_STRING([--disable-xrender], [turn off Xrender s AC_ARG_ENABLE([fluid], AS_HELP_STRING([--disable-fluid], [turn off fluid building])) AS_CASE([$host_os], [cygwin* | mingw*], [ - AC_ARG_ENABLE([gdiplus], AS_HELP_STRING([--disable-gdiplus], [don't use GDI+ for antialiased graphics])) + AC_ARG_ENABLE([gdiplus], AS_HELP_STRING([--disable-gdiplus], [don't use GDI+ for antialiased graphics])) - gdiplus_found=no + gdiplus_found=no AS_IF([test x$enable_gdiplus != xno], [ AC_CHECK_HEADERS([wtypes.h gdiplus.h], [ AC_DEFINE([USE_GDIPLUS]) @@ -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" ]) diff --git a/fl_config.cmake.in b/fl_config.cmake.in index a6e3b086e..3fdcea274 100644 --- a/fl_config.cmake.in +++ b/fl_config.cmake.in @@ -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 @@ -47,6 +47,15 @@ /* + * FLTK_HAVE_FORMS + * + * Do we have the Forms compatibility library available? +*/ + +#cmakedefine FLTK_HAVE_FORMS 1 + + +/* * FLTK_USE_X11 * * Do we use X11 for the current platform? diff --git a/fl_config.in b/fl_config.in index 444d85212..03c3abf57 100644 --- a/fl_config.in +++ b/fl_config.in @@ -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 @@ -46,6 +46,15 @@ /* + * FLTK_HAVE_FORMS + * + * Do we have the Forms compatibility library available? +*/ + +#undef FLTK_HAVE_FORMS + + +/* * FLTK_USE_X11 * * Do we use X11 for the current platform? diff --git a/fltk-options/Makefile b/fltk-options/Makefile index 0c7c9c6da..06b3b710b 100644 --- a/fltk-options/Makefile +++ b/fltk-options/Makefile @@ -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) diff --git a/fluid/Makefile b/fluid/Makefile index 0fa834ebf..75a785e71 100644 --- a/fluid/Makefile +++ b/fluid/Makefile @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index be2634d62..47d576ac3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -406,14 +406,18 @@ set (CPPFILES ${DRIVER_FILES} ) -set (FORMS_FILES - forms_compatibility.cxx - forms_bitmap.cxx - forms_free.cxx - forms_fselect.cxx - forms_pixmap.cxx - forms_timer.cxx -) +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) ################################################################### - FL_ADD_LIBRARY (fltk_forms SHARED "${FORMS_FILES}") - target_link_libraries (fltk_forms_SHARED fltk_SHARED) + if (FLTK_BUILD_FORMS) + FL_ADD_LIBRARY (fltk_forms SHARED "${FORMS_FILES}") + target_link_libraries (fltk_forms_SHARED fltk_SHARED) + endif () ################################################################### diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index be40319ce..7fea98adc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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) diff --git a/test/forms.cxx b/test/forms.cxx index 84f623649..e19fade77 100644 --- a/test/forms.cxx +++ b/test/forms.cxx @@ -19,10 +19,13 @@ // https://www.fltk.org/bugs.php // -#include <FL/forms.H> // changed for FLTK +#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 -static int border = 1; // changed from FL_TRANSIENT for FLTK -// (this is so the close box and Esc work to close the window) +#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) 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) |
