diff options
| -rw-r--r-- | CMake/options.cmake | 37 | ||||
| -rw-r--r-- | CMake/pen-support.c | 41 | ||||
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | config.h.in | 3 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 10 | ||||
| -rw-r--r-- | test/CMakeLists.txt | 2 |
6 files changed, 84 insertions, 11 deletions
diff --git a/CMake/options.cmake b/CMake/options.cmake index 27cffd038..f005f8b0e 100644 --- a/CMake/options.cmake +++ b/CMake/options.cmake @@ -491,11 +491,42 @@ else() set(FLTK_HAVE_FORMS 0) endif() +# Note: on some Windows build systems (notably "classic" MinGW 32-bit) +# Pen/Tablet support is not available, hence we use try_compile() to +# figure this out. +# +# CMake variables: +# - FLTK_OPTION_PEN_SUPPORT: user option (cache; default ON/TRUE) +# - PEN_DRIVER_SUPPORTED : Windows only; result of try_compile() +# - FLTK_HAVE_PEN_SUPPORT : final result for building Pen/Tablet support, +# also used to set config variable in config.h + if(FLTK_OPTION_PEN_SUPPORT) - set(FLTK_HAVE_PEN_SUPPORT 1) -else() + if(WIN32) + try_compile(PEN_DRIVER_SUPPORTED + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/CMake/pen-support.c + ) + # fl_debug_var(PEN_DRIVER_SUPPORTED) + if(PEN_DRIVER_SUPPORTED) + set(FLTK_HAVE_PEN_SUPPORT 1) + else() + set(FLTK_HAVE_PEN_SUPPORT 0) + endif() + else(WIN32) # all other platforms + set(FLTK_HAVE_PEN_SUPPORT 1) + endif(WIN32) + + # generate a warning if Pen/Tablet support was requested but can't be compiled + + if(NOT FLTK_HAVE_PEN_SUPPORT) + message(STATUS "WARNING: Pen/Tablet support requested (FLTK_OPTION_PEN_SUPPORT) but not available") + message(STATUS " ... Pen/Tablet support has been disabled!") + endif() + +else(FLTK_OPTION_PEN_SUPPORT) # option disabled by user set(FLTK_HAVE_PEN_SUPPORT 0) -endif() +endif(FLTK_OPTION_PEN_SUPPORT) ####################################################################### if(DOXYGEN_FOUND) diff --git a/CMake/pen-support.c b/CMake/pen-support.c new file mode 100644 index 000000000..3c3bed0be --- /dev/null +++ b/CMake/pen-support.c @@ -0,0 +1,41 @@ +/* + Test Pen/Tablet support availability (Windows). + + Copyright 2026 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 + file is missing or damaged, see the license at: + + https://www.fltk.org/COPYING.php + + Please see the following page on how to report bugs and issues: + + https://www.fltk.org/bugs.php +*/ + +/* + CMake test function: test if this can be compiled. + If compilation fails, then Pen/Tablet support can't be built and is disabled. +*/ + +/* We require Windows 8 or later features for Pen/Tablet support */ + +# if !defined(WINVER) || (WINVER < 0x0602) +# ifdef WINVER +# undef WINVER +# endif +# define WINVER 0x0602 +# endif +# if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0602) +# ifdef _WIN32_WINNT +# undef _WIN32_WINNT +# endif +# define _WIN32_WINNT 0x0602 +# endif + +#include <windows.h> + +int main() { + return POINTER_CHANGE_FIRSTBUTTON_DOWN; /* required symbol */ +} diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f41e5db8..347324563 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -397,7 +397,7 @@ fl_summary_build("Static libraries" lib TRUE "n/a") fl_summary_build("Shared libraries" lib FLTK_BUILD_SHARED_LIBS FLTK_BUILD_SHARED_LIBS) fl_summary_build("The forms library" lib FLTK_BUILD_FORMS FLTK_BUILD_FORMS) fl_summary_build("The OpenGL library" lib FLTK_USE_GL FLTK_BUILD_GL) -fl_summary_build("Pen/tablet support" lib FLTK_OPTION_PEN_SUPPORT FLTK_OPTION_PEN_SUPPORT) +fl_summary_build("Pen/tablet support" lib FLTK_HAVE_PEN_SUPPORT FLTK_OPTION_PEN_SUPPORT) message(STATUS "") diff --git a/config.h.in b/config.h.in index 9f235f7d1..16fb08f2c 100644 --- a/config.h.in +++ b/config.h.in @@ -362,7 +362,8 @@ * FLTK_HAVE_PEN_SUPPORT * * Do we have pen/tablet support for the current platform? - * See CMake option FLTK_OPTION_PEN_SUPPORT + * See CMake option FLTK_OPTION_PEN_SUPPORT, but note that a build test + * (try_compile()) is performed to test if the option is available * * Note: this option is "hidden" in 'config.h', i.e. it's not (yet) * publicly accessibe. Move this to 'fl_config.h' to make it public. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bae8d0e81..cf4196185 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -421,24 +421,24 @@ else() # Optional Pen/Tablet Support - if(FLTK_OPTION_PEN_SUPPORT) + if(FLTK_HAVE_PEN_SUPPORT) list(APPEND DRIVER_FILES drivers/WinAPI/Fl_WinAPI_Pen_Driver.cxx ) - endif(FLTK_OPTION_PEN_SUPPORT) + endif(FLTK_HAVE_PEN_SUPPORT) endif(FLTK_USE_X11 AND NOT FLTK_USE_WAYLAND) # Common Pen/Tablet Support Files -if(FLTK_OPTION_PEN_SUPPORT) +if(FLTK_HAVE_PEN_SUPPORT) list(APPEND DRIVER_FILES drivers/Base/Fl_Base_Pen_Events.cxx ) list(APPEND DRIVER_HEADER_FILES drivers/Base/Fl_Base_Pen_Events.H ) -endif(FLTK_OPTION_PEN_SUPPORT) +endif(FLTK_HAVE_PEN_SUPPORT) source_group("Header Files" FILES ${HEADER_FILES}) source_group("Private Header Files" FILES ${PRIVATE_HEADER_FILES}) @@ -645,7 +645,7 @@ if(APPLE AND NOT FLTK_BACKEND_X11) Fl_Native_File_Chooser_MAC.mm Fl_MacOS_Sys_Menu_Bar.mm ) - if(FLTK_OPTION_PEN_SUPPORT) + if(FLTK_HAVE_PEN_SUPPORT) list(APPEND MMFILES drivers/Cocoa/Fl_Cocoa_Pen_Events.mm ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4522c99bc..f3f5a45ca 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -184,7 +184,7 @@ fl_create_example(output output.cxx fltk::fltk) fl_create_example(overlay overlay.cxx fltk::fltk) fl_create_example(pack pack.cxx fltk::fltk) -if(FLTK_OPTION_PEN_SUPPORT) +if(FLTK_HAVE_PEN_SUPPORT) fl_create_example(penpal penpal.cxx fltk::fltk) endif() |
