CMake: add try_compile() to figure out if Pen/Tablet is supported
This test is specifically intended to disable Pen/Tablet support on classic MinGW (32-bit) platforms that lack required symbol definitions although Pen/Tablet support might be supported by the Windows system. This test can be extended for other platforms, but for now it's performed only on Windows.
This commit is contained in:
parent
bed38ba3f5
commit
e9966b7e31
@ -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)
|
||||
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(FLTK_OPTION_PEN_SUPPORT)
|
||||
|
||||
#######################################################################
|
||||
if(DOXYGEN_FOUND)
|
||||
|
||||
41
CMake/pen-support.c
Normal file
41
CMake/pen-support.c
Normal file
@ -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 */
|
||||
}
|
||||
@ -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 "")
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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
|
||||
)
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user