From 5df5daf78e135e0c8371012ffe56df5cae357755 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Wed, 20 Dec 2023 16:56:29 +0100 Subject: 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. --- test/CMakeLists.txt | 10 +++++++++- test/forms.cxx | 23 ++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) (limited to 'test') 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 // changed for FLTK +#include // FLTK: includes +#ifdef FLTK_HAVE_FORMS // FLTK: defined in 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 // 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 + +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) -- cgit v1.2.3