mirror of
https://github.com/fltk/fltk.git
synced 2026-06-01 23:06:54 +08:00
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:
+34
-3
@@ -491,11 +491,42 @@ else()
|
|||||||
set(FLTK_HAVE_FORMS 0)
|
set(FLTK_HAVE_FORMS 0)
|
||||||
endif()
|
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(FLTK_OPTION_PEN_SUPPORT)
|
||||||
set(FLTK_HAVE_PEN_SUPPORT 1)
|
if(WIN32)
|
||||||
else()
|
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)
|
set(FLTK_HAVE_PEN_SUPPORT 0)
|
||||||
endif()
|
endif(FLTK_OPTION_PEN_SUPPORT)
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
if(DOXYGEN_FOUND)
|
if(DOXYGEN_FOUND)
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
}
|
||||||
+1
-1
@@ -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("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 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("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 "")
|
message(STATUS "")
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -362,7 +362,8 @@
|
|||||||
* FLTK_HAVE_PEN_SUPPORT
|
* FLTK_HAVE_PEN_SUPPORT
|
||||||
*
|
*
|
||||||
* Do we have pen/tablet support for the current platform?
|
* 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)
|
* 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.
|
* publicly accessibe. Move this to 'fl_config.h' to make it public.
|
||||||
|
|||||||
+5
-5
@@ -421,24 +421,24 @@ else()
|
|||||||
|
|
||||||
# Optional Pen/Tablet Support
|
# Optional Pen/Tablet Support
|
||||||
|
|
||||||
if(FLTK_OPTION_PEN_SUPPORT)
|
if(FLTK_HAVE_PEN_SUPPORT)
|
||||||
list(APPEND DRIVER_FILES
|
list(APPEND DRIVER_FILES
|
||||||
drivers/WinAPI/Fl_WinAPI_Pen_Driver.cxx
|
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)
|
endif(FLTK_USE_X11 AND NOT FLTK_USE_WAYLAND)
|
||||||
|
|
||||||
# Common Pen/Tablet Support Files
|
# Common Pen/Tablet Support Files
|
||||||
|
|
||||||
if(FLTK_OPTION_PEN_SUPPORT)
|
if(FLTK_HAVE_PEN_SUPPORT)
|
||||||
list(APPEND DRIVER_FILES
|
list(APPEND DRIVER_FILES
|
||||||
drivers/Base/Fl_Base_Pen_Events.cxx
|
drivers/Base/Fl_Base_Pen_Events.cxx
|
||||||
)
|
)
|
||||||
list(APPEND DRIVER_HEADER_FILES
|
list(APPEND DRIVER_HEADER_FILES
|
||||||
drivers/Base/Fl_Base_Pen_Events.H
|
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("Header Files" FILES ${HEADER_FILES})
|
||||||
source_group("Private Header Files" FILES ${PRIVATE_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_Native_File_Chooser_MAC.mm
|
||||||
Fl_MacOS_Sys_Menu_Bar.mm
|
Fl_MacOS_Sys_Menu_Bar.mm
|
||||||
)
|
)
|
||||||
if(FLTK_OPTION_PEN_SUPPORT)
|
if(FLTK_HAVE_PEN_SUPPORT)
|
||||||
list(APPEND MMFILES
|
list(APPEND MMFILES
|
||||||
drivers/Cocoa/Fl_Cocoa_Pen_Events.mm
|
drivers/Cocoa/Fl_Cocoa_Pen_Events.mm
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -184,7 +184,7 @@ fl_create_example(output output.cxx fltk::fltk)
|
|||||||
fl_create_example(overlay overlay.cxx fltk::fltk)
|
fl_create_example(overlay overlay.cxx fltk::fltk)
|
||||||
fl_create_example(pack pack.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)
|
fl_create_example(penpal penpal.cxx fltk::fltk)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user