Introduce "Modern CMake" in FLTK

This is a big commit and there are too many changes to list them all.
The main changes are:

- rename all CMake build options to 'FLTK_*'
- export library targets with namespace (prefix) 'fltk::'
- standardize shared library target names with suffix '-shared'
- set public build properties on libraries for consumers
- document library names and aliases in README.CMake.txt
- document changes in "Migrating Code from FLTK 1.3 to 1.4"
- partial backwards compatibility for old user projects

Included but not directly related changes:

- fix Windows (Visual Studio) DLL build
- add CMake function fl_debug_target() to show target properties
- don't build test programs if FLTK is a subproject
- internal: reformat CMake code: remove space before '('

Thanks to Matthias and Manolo for their help, testing, and feeback.
This commit is contained in:
Albrecht Schlosser 2024-02-07 18:30:11 +01:00
parent 1cf6fdfa85
commit fd5cd80935
53 changed files with 3571 additions and 2749 deletions

View File

@ -36,7 +36,7 @@ jobs:
# Note the current convention is to use the -S and -B options here to specify source # Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher. # and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12 # The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOPTION_USE_WAYLAND=OFF -DCMAKE_CXX_STANDARD=98 -DCMAKE_CXX_EXTENSIONS=OFF -DCMAKE_C_FLAGS_INIT="-Wall -Wunused" -DCMAKE_CXX_FLAGS_INIT="-Wall -Wunused" run: cmake $GITHUB_WORKSPACE -D CMAKE_BUILD_TYPE=$BUILD_TYPE -D FLTK_OPTION_USE_WAYLAND=OFF -D CMAKE_CXX_STANDARD=98 -D CMAKE_CXX_EXTENSIONS=OFF -D CMAKE_C_FLAGS_INIT="-Wall -Wunused" -D CMAKE_CXX_FLAGS_INIT="-Wall -Wunused"
- name: Build - name: Build
working-directory: ${{github.workspace}}/build working-directory: ${{github.workspace}}/build
@ -130,7 +130,7 @@ jobs:
- name: Configure CMake - name: Configure CMake
working-directory: ${{github.workspace}}/build working-directory: ${{github.workspace}}/build
run: cmake -D OPTION_USE_SYSTEM_LIBJPEG:BOOL=OFF -D OPTION_USE_SYSTEM_LIBPNG:BOOL=OFF -D OPTION_USE_SYSTEM_ZLIB:BOOL=OFF .. run: cmake -D FLTK_USE_SYSTEM_LIBJPEG:BOOL=OFF -D FLTK_USE_SYSTEM_LIBPNG:BOOL=OFF -D FLTK_USE_SYSTEM_ZLIB:BOOL=OFF ..
- name: Build - name: Build
working-directory: ${{github.workspace}}/build working-directory: ${{github.workspace}}/build

View File

@ -63,7 +63,7 @@ build-cmake:
- date - date
- gcc --version - gcc --version
- mkdir build && cd build - mkdir build && cd build
- cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DFLTK_BUILD_EXAMPLES=ON -DOPTION_USE_PANGO=ON -DOPTION_CAIRO=ON .. - cmake -G Ninja -D CMAKE_BUILD_TYPE=Debug -D FLTK_BUILD_EXAMPLES=ON -D FLTK_USE_PANGO=ON -D FLTK_OPTION_CAIRO_WINDOW=ON ..
- date - date
- time ninja - time ninja
- date - date

View File

@ -1,4 +1,4 @@
Changes in FLTK 1.4.0 Released: ??? ?? 2022 Changes in FLTK 1.4.0 Released: Feb ?? 2024
General Information about this Release General Information about this Release
@ -9,13 +9,17 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2022
CMake can be used to generate Makefiles, IDE project files, and CMake can be used to generate Makefiles, IDE project files, and
several other build systems by using different "generators" provided several other build systems by using different "generators" provided
by CMake (for instance Ninja, CodeBlocks, Eclipse, KDevelop3, Xcode, etc.). by CMake (for instance Ninja, CodeBlocks, Eclipse, KDevelop3, Xcode, etc.).
See README.CMake.txt for more information. FLTK uses "Modern CMake" since release 1.4.0 which simplifies user
project build systems significantly.
See README.CMake.txt and documentation chapter "Migrating Code from
FLTK 1.3 to 1.4" for more information.
- autoconf/configure is still supported by the FLTK team for backwards - autoconf/configure is still supported by the FLTK team for backwards
compatibility with older systems that lack CMake support. compatibility with older systems that lack CMake support. Support of
autoconf/configure will be dropped in FLTK 1.5.0.
- FLTK 1.4 introduces a new platform, Wayland, available for recent Linux - FLTK 1.4 introduces a new platform, Wayland, available for recent Linux
distributions and FreeBSD. More information in README.Wayland.txt distributions and FreeBSD. For details see README.Wayland.txt.
New Features and Extensions New Features and Extensions
@ -137,23 +141,23 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2022
which allows to draw most scripts supported by Unicode, including CJK which allows to draw most scripts supported by Unicode, including CJK
and right-to-left scripts. FLTK now outputs PostScript that draws and right-to-left scripts. FLTK now outputs PostScript that draws
those scripts in vectorial form. The corresponding CMake option is those scripts in vectorial form. The corresponding CMake option is
OPTION_USE_PANGO. The corresponding configure option is --enable-pango. FLTK_USE_PANGO. The corresponding configure option is --enable-pango.
This option is OFF by default. This option is OFF by default.
- Configure option --enable-wayland allows to build the FLTK library for - Configure option --enable-wayland allows to build the FLTK library for
the new Wayland platform while remaining compatible with X11. The the new Wayland platform while remaining compatible with X11. The
corresponding CMake option is OPTION_USE_WAYLAND. This option is ON by default. corresponding CMake option is FLTK_BACKEND_WAYLAND. This option is ON by default.
- Configure options --enable-wayland --disable-x11 used together allow to - Configure options --enable-wayland --disable-x11 used together allow to
build FLTK for the Wayland backend only (no x11 backend). Under CMake, the build FLTK for the Wayland backend only (no x11 backend). Under CMake, the
equivalent is to set both OPTION_USE_WAYLAND and OPTION_WAYLAND_ONLY. equivalent option is to set FLTK_BACKEND_WAYLAND=ON and FLTK_BACKEND_X11=OFF.
- The new configure option --disable-gdiplus removes the possibility to draw - The new configure option --disable-gdiplus removes the possibility to draw
antialiased lines and curves on the Windows platform. The corresponding CMake antialiased lines and curves on the Windows platform. The corresponding CMake
option is OPTION_USE_GDIPLUS. option is FLTK_GRAPHICS_GDIPLUS.
- The library can be built without support for reading SVG images or writing - The library can be built without support for reading SVG images or writing
graphics in SVG format using the --disable-svg configure option graphics in SVG format using the --disable-svg configure option
or turning off OPTION_USE_SVG in CMake. or turning off FLTK_OPTION_SVG in CMake.
- The library can be built without support for PostScript, thus reducing - The library can be built without support for PostScript, thus reducing
its size, using the --disable-print configure option or turning off its size, using the --disable-print configure option or turning off
OPTION_PRINT_SUPPORT in CMake. That makes classes Fl_PostScript_File_Device, FLTK_OPTION_PRINT_SUPPORT in CMake. That makes classes Fl_PostScript_File_Device,
Fl_EPS_File_Surface and Fl_Printer (under X11 platform only) ineffective. Fl_EPS_File_Surface and Fl_Printer (under X11 platform only) ineffective.
- FLTK's ABI version can be configured with 'configure' and CMake. - FLTK's ABI version can be configured with 'configure' and CMake.
See documentation in README.abi-version.txt. See documentation in README.abi-version.txt.
@ -161,7 +165,7 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2022
Bundled libraries Bundled libraries
- Bundled image libraries have been upgraded to newer versions. - Bundled image libraries have been upgraded to newer versions.
For details see README.bundled-libs.txt. For details see documentation/src/bundled-libs.dox or online docs.
1.4.0 ABI FEATURES 1.4.0 ABI FEATURES

View File

@ -1,8 +1,8 @@
# #
# FLTK-Functions.cmake # FLTK-Functions.cmake
# Written by Michael Surette # Originally written by Michael Surette
# #
# Copyright 1998-2021 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -15,21 +15,36 @@
# https://www.fltk.org/bugs.php # https://www.fltk.org/bugs.php
# #
####################################################################### ################################################################################
# functions used by the build system and exported for the end-user # functions used by the build system and exported for the end-user
####################################################################### ################################################################################
# USAGE: FLTK_RUN_FLUID TARGET_NAME "FLUID_SOURCE [.. FLUID_SOURCE]" ################################################################################
#
# fltk_run_fluid: Run fluid to compile fluid (.fl) files
#
# Usage: fltk_run_fluid(SOURCES "FLUID_SOURCE [.. FLUID_SOURCE]")
#
# Input: The CMake variable "FL_FILES" must contain a list of input
# file names. Only names ending in ".fl" are considered and
# compiled to their ".cxx" and ".h" files which are stored
# in the current build directory.
#
# Output: "SOURCES" is used as a CMake variable name that is assigned the
# names of the compiled ".cxx" files as a ";" separated list in the
# parent scope (the caller's scope).
#
################################################################################
function (FLTK_RUN_FLUID TARGET SOURCES) function(fltk_run_fluid SOURCES FL_FILES)
if(NOT FLTK_FLUID_EXECUTABLE) if(NOT FLTK_FLUID_EXECUTABLE)
message (WARNING "Not building ${SOURCES}. FLUID executable not found.") message(WARNING "Not building ${FL_FILES}. FLUID executable not found.")
return() return()
endif (NOT FLTK_FLUID_EXECUTABLE) endif()
set(CXX_FILES) set(CXX_FILES)
foreach (src ${SOURCES}) foreach(src ${FL_FILES})
if("${src}" MATCHES "\\.fl$") if("${src}" MATCHES "\\.fl$")
string(REGEX REPLACE "(.*).fl" \\1 basename ${src}) string(REGEX REPLACE "(.*).fl" \\1 basename ${src})
add_custom_command( add_custom_command(
@ -39,20 +54,32 @@ function (FLTK_RUN_FLUID TARGET SOURCES)
MAIN_DEPENDENCY ${src} MAIN_DEPENDENCY ${src}
) )
list(APPEND CXX_FILES "${basename}.cxx") list(APPEND CXX_FILES "${basename}.cxx")
endif ("${src}" MATCHES "\\.fl$") endif()
endforeach() endforeach()
set (${TARGET} ${CXX_FILES} PARENT_SCOPE) set(${SOURCES} ${CXX_FILES} PARENT_SCOPE)
endfunction (FLTK_RUN_FLUID TARGET SOURCES) endfunction(fltk_run_fluid SOURCES FL_FILES)
#######################################################################
# sets the bundle icon for OSX bundles ################################################################################
#
# fltk_set_bundle_icon: Set the bundle icon for macOS bundles
#
# This function sets macOS specific target properties. These properties are
# ignored on other platforms.
#
# Usage: fltk_set_bundle_icon(TARGET ICON_PATH)
#
# TARGET must be a valid CMake target that has been created before this
# function is called. It must not be an alias name.
#
################################################################################
function (FLTK_SET_BUNDLE_ICON TARGET ICON_PATH) function(fltk_set_bundle_icon TARGET ICON_PATH)
get_filename_component(ICON_NAME "${ICON_PATH}" NAME) get_filename_component(ICON_NAME "${ICON_PATH}" NAME)
set_target_properties ("${TARGET}" PROPERTIES set_target_properties(${TARGET}
PROPERTIES
MACOSX_BUNDLE_ICON_FILE "${ICON_NAME}" MACOSX_BUNDLE_ICON_FILE "${ICON_NAME}"
RESOURCE "${ICON_PATH}" RESOURCE "${ICON_PATH}"
) )
endfunction (FLTK_SET_BUNDLE_ICON TARGET ICON_PATH) endfunction(fltk_set_bundle_icon TARGET ICON_PATH)

View File

@ -8,7 +8,7 @@
# #
# FLTK_VERSION - FLTK version string ("x.y.z") # FLTK_VERSION - FLTK version string ("x.y.z")
# FLTK_INCLUDE_DIRS - FLTK include directories # FLTK_INCLUDE_DIRS - FLTK include directories
# FLTK_LIBRARIES - list of FLTK libraries built (not yet implemented) # FLTK_LIBRARIES - list of built FLTK libraries
# FLTK_FLUID_EXECUTABLE - needed by the function FLTK_RUN_FLUID # FLTK_FLUID_EXECUTABLE - needed by the function FLTK_RUN_FLUID
# (or the deprecated fltk_wrap_ui() CMake command) # (or the deprecated fltk_wrap_ui() CMake command)
# #
@ -21,28 +21,118 @@
# changed in future versions. This includes the list of defined variables # changed in future versions. This includes the list of defined variables
# above that may be changed if necessary. # above that may be changed if necessary.
# #
# Note: FLTK 1.4.0 introduced "Modern CMake", therefore usage of most if not
# all of the variables mentioned above is no longer needed in user projects.
# Please use the CMake target names fltk::fltk, fltk::images, etc. instead.
# Please see README.CMake.txt for mor info on how to do this.
#
# Optional: Create backwards compatible aliases for libraries and fluid.
# This is enabled in FLTK 1.4.0 to simplify migration of user projects
# from "classic" (1.3.x) to "modern" CMake and will likely be removed
# in a later FLTK version (maybe 1.4.x, x>2, or 1.5.0).
set(FLTK_CREATE_COMPATIBILITY_ALIASES TRUE)
set(FLTK_VERSION @FLTK_VERSION@) set(FLTK_VERSION @FLTK_VERSION@)
include(${CMAKE_CURRENT_LIST_DIR}/FLTK-Targets.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FLTK-Targets.cmake)
set(FLTK_INCLUDE_DIRS "@INCLUDE_DIRS@") set(FLTK_INCLUDE_DIRS "@INCLUDE_DIRS@")
set(FLTK_LIBRARIES "@FLTK_LIBRARIES@")
# for compatibility with CMake's FindFLTK.cmake # For compatibility with CMake's FindFLTK.cmake:
set(FLTK_INCLUDE_DIR "${FLTK_INCLUDE_DIRS}") set(FLTK_INCLUDE_DIR "${FLTK_INCLUDE_DIRS}")
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
find_file(FLUID_PATH
# Find a fluid executable on the build host to be able to build fluid programs
find_program(FLTK_FLUID_HOST
NAMES fluid fluid.exe NAMES fluid fluid.exe
PATHS ENV PATH PATHS ENV PATH
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_FIND_ROOT_PATH
) )
add_executable(fluid IMPORTED)
set_target_properties(fluid if(FLTK_FLUID_HOST)
PROPERTIES IMPORTED_LOCATION ${FLUID_PATH}
if(0) # Experimental: currently not used
# Import a special 'fluid' target called 'fluid-host' (fltk::fluid-host)
# Note: this is "the same as" the CMake variable FLTK_FLUID_EXECUTABLE
add_executable(fluid-host IMPORTED)
set_target_properties(fluid-host
PROPERTIES IMPORTED_LOCATION ${FLTK_FLUID_HOST}
) )
set (FLTK_FLUID_EXECUTABLE ${FLUID_PATH}) add_executable(fltk::fluid-host ALIAS fluid-host)
set(FLTK_FLUID_EXECUTABLE fltk::fluid-host)
else()
set(FLTK_FLUID_EXECUTABLE "${FLTK_FLUID_HOST}")
endif()
else() # fluid not found on build host
message(STATUS "FLTKConfig.cmake (cross-compiling): fluid not found on the build host")
# note: this assigns "FLTK_FLUID_HOST-NOTFOUND" and running fluid will fail
set(FLTK_FLUID_EXECUTABLE "${FLTK_FLUID_HOST}")
endif()
else(CMAKE_CROSSCOMPILING)
if(FLTK_CREATE_COMPATIBILITY_ALIASES)
function(_fltk_make_alias target from)
if(TARGET ${from} AND NOT TARGET ${target})
# message(STATUS "FLTKConfig.cmake - create alias: ${target} from ${from}")
get_target_property(ttype ${from} TYPE)
if(ttype STREQUAL "EXECUTABLE")
add_executable(${target} ALIAS ${from})
else()
add_library(${target} ALIAS ${from})
endif()
endif()
endfunction(_fltk_make_alias target)
if(NOT TARGET fltk::fltk)
message(FATAL "FLTKConfig.cmake: target fltk::fltk does not exist!")
endif()
_fltk_make_alias(fltk fltk::fltk)
_fltk_make_alias(fltk-shared fltk::fltk-shared)
_fltk_make_alias(fluid fltk::fluid)
_fltk_make_alias(fluid-cmd fltk::fluid-cmd)
_fltk_make_alias(fltk-options fltk::options)
_fltk_make_alias(fltk-options-cmd fltk::options-cmd)
foreach(target cairo forms gl images jpeg png z)
_fltk_make_alias(fltk_${target} fltk::${target})
_fltk_make_alias(fltk_${target}-shared fltk::${target}-shared)
endforeach()
endif() # Create aliases ...
# set FLTK_FLUID_EXECUTABLE: try to use the fltk::target name if it
# exists and fall back to 'fluid-cmd' or 'fluid' if not. This will
# eventually call the build host's fluid if found in the users's PATH
if(TARGET fltk::fluid-cmd) # Windows only
set(FLTK_FLUID_EXECUTABLE fltk::fluid-cmd)
elseif(TARGET fltk::fluid)
set(FLTK_FLUID_EXECUTABLE fltk::fluid)
elseif(WIN32)
set(FLTK_FLUID_EXECUTABLE fluid-cmd)
else() else()
set(FLTK_FLUID_EXECUTABLE fluid) set(FLTK_FLUID_EXECUTABLE fluid)
endif()
endif(CMAKE_CROSSCOMPILING) endif(CMAKE_CROSSCOMPILING)
# Debug: should be commented out
# message(STATUS "FLTKConfig.cmake: FLTK_FLUID_EXECUTABLE = '${FLTK_FLUID_EXECUTABLE}'")

View File

@ -1,8 +1,9 @@
# #
# Support file to uninstall the FLTK project using CMake # Support file to uninstall the FLTK project using CMake
#
# Originally written by Michael Surette # Originally written by Michael Surette
# #
# Copyright 1998-2023 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -50,7 +51,7 @@ foreach (file ${files})
message(STATUS " Status = '${rm_retval}'") message(STATUS " Status = '${rm_retval}'")
message(STATUS " Output = '${rm_out}'") message(STATUS " Output = '${rm_out}'")
message(STATUS " Error = '${rm_err}'") message(STATUS " Error = '${rm_err}'")
message (FATAL_ERROR "Exiting with fatal error.") message(FATAL_ERROR "Exiting - uninstall may be incomplete.")
endif() endif()
endforeach(file) endforeach(file)

View File

@ -1,8 +1,9 @@
# #
# Export CMake file to build the FLTK project using CMake (www.cmake.org) # Export CMake file to build the FLTK project using CMake (www.cmake.org)
#
# Originally written by Michael Surette # Originally written by Michael Surette
# #
# Copyright 1998-2022 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -22,27 +23,49 @@
# Set the fluid executable path used to create .cxx/.h from .fl files # Set the fluid executable path used to create .cxx/.h from .fl files
if(FLTK_BUILD_FLUID AND NOT CMAKE_CROSSCOMPILING) if(FLTK_BUILD_FLUID AND NOT CMAKE_CROSSCOMPILING)
# use the fluid executable we build # Use the fluid executable we build using its namespaced target name
if(WIN32) if(WIN32)
set (FLTK_FLUID_EXECUTABLE fluid-cmd) set(FLTK_FLUID_EXECUTABLE fltk::fluid-cmd)
set(FLUID_EXPORT fluid fluid-cmd) # export fluid and fluid-cmd set(FLUID_EXPORT fluid fluid-cmd) # export fluid and fluid-cmd
else() else()
set (FLTK_FLUID_EXECUTABLE fluid) set(FLTK_FLUID_EXECUTABLE fltk::fluid)
set(FLUID_EXPORT fluid) # export fluid set(FLUID_EXPORT fluid) # export fluid
endif() endif()
else() else()
# find a fluid executable on the host system # We don't build fluid /or/ we are cross-compiling (or both):
find_file(FLUID_PATH # we need to find a fluid executable on the build host.
# The search is restricted to the user's PATH (environment).
find_program(FLTK_FLUID_HOST
NAMES fluid fluid.exe NAMES fluid fluid.exe
PATHS ENV PATH PATHS ENV PATH
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_FIND_ROOT_PATH
) )
set (FLTK_FLUID_EXECUTABLE ${FLUID_PATH}) if(NOT FLTK_FLUID_HOST)
message(STATUS "Warning: fluid not found on the build system!")
endif()
# Note: this *may* assign "FLTK_FLUID_HOST-NOTFOUND"
set(FLTK_FLUID_EXECUTABLE "${FLTK_FLUID_HOST}")
set(FLUID_EXPORT "") # don't export fluid set(FLUID_EXPORT "") # don't export fluid
endif(FLTK_BUILD_FLUID AND NOT CMAKE_CROSSCOMPILING) endif(FLTK_BUILD_FLUID AND NOT CMAKE_CROSSCOMPILING)
if(0) # Debug
message(STATUS "##############################################################")
message(STATUS "[export.cmake] INFO: Did we find fluid?")
fl_debug_var(FLTK_FLUID_HOST)
fl_debug_var(FLTK_FLUID_EXECUTABLE)
fl_debug_var(FLTK_BUILD_FLUID)
fl_debug_var(CMAKE_CROSSCOMPILING)
message(STATUS "##############################################################")
endif()
# generate FLTK-Targets.cmake for build directory use # generate FLTK-Targets.cmake for build directory use
export (TARGETS ${FLUID_EXPORT} ${FLTK_LIBRARIES} FILE ${CMAKE_CURRENT_BINARY_DIR}/FLTK-Targets.cmake) export(TARGETS
${FLUID_EXPORT} ${FLTK_LIBRARIES}
FILE
${CMAKE_CURRENT_BINARY_DIR}/FLTK-Targets.cmake
NAMESPACE
fltk::)
# generate FLTK-Functions.cmake for build directory use # generate FLTK-Functions.cmake for build directory use
configure_file( configure_file(
@ -53,9 +76,10 @@ configure_file (
# generate FLTKConfig.cmake for build directory use # generate FLTKConfig.cmake for build directory use
set(INCLUDE_DIRS "${FLTK_INCLUDE_DIRS}") set(INCLUDE_DIRS "${FLTK_INCLUDE_DIRS}")
if (FLTK_HAVE_CAIRO) if(FLTK_HAVE_CAIRO OR FLTK_USE_CAIRO)
list(APPEND INCLUDE_DIRS ${PKG_CAIRO_INCLUDE_DIRS}) list(APPEND INCLUDE_DIRS ${PKG_CAIRO_INCLUDE_DIRS})
endif() endif()
list(REMOVE_DUPLICATES INCLUDE_DIRS)
set(CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR}) set(CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR})
configure_file( configure_file(
@ -80,8 +104,8 @@ configure_file(
@ONLY @ONLY
) )
# Set execute permissions on fltk-config in build dir # Set execute permissions on fltk-config in the build directory.
# Note: file(CHMOD) available since CMake 3.19, # Note: file(CHMOD) is available since CMake 3.19,
# use fallback before CMake 3.19 # use fallback before CMake 3.19
if(CMAKE_VERSION VERSION_LESS 3.19) if(CMAKE_VERSION VERSION_LESS 3.19)
@ -121,7 +145,7 @@ configure_file(
@ONLY @ONLY
) )
if (OPTION_CREATE_LINKS) if(FLTK_INSTALL_LINKS)
# Set PREFIX_INCLUDE to the proper value. # Set PREFIX_INCLUDE to the proper value.
if(IS_ABSOLUTE ${FLTK_INCLUDEDIR}) if(IS_ABSOLUTE ${FLTK_INCLUDEDIR})
set(PREFIX_INCLUDE ${FLTK_INCLUDEDIR}) set(PREFIX_INCLUDE ${FLTK_INCLUDEDIR})
@ -132,4 +156,4 @@ if (OPTION_CREATE_LINKS)
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/install-symlinks.cmake.in" "${CMAKE_CURRENT_SOURCE_DIR}/CMake/install-symlinks.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/install-symlinks.cmake" "${CMAKE_CURRENT_BINARY_DIR}/install-symlinks.cmake"
@ONLY) @ONLY)
endif (OPTION_CREATE_LINKS) endif(FLTK_INSTALL_LINKS)

View File

@ -1,8 +1,8 @@
# #
# Macro used by the CMake build system for the Fast Light Tool Kit (FLTK). # Macro used by the CMake build system for the Fast Light Tool Kit (FLTK).
# Written by Michael Surette # Originally written by Michael Surette
# #
# Copyright 1998-2020 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -16,68 +16,188 @@
# #
####################################################################### #######################################################################
# FL_ADD_LIBRARY - add a static or shared library to the build # fl_add_library - add a static or shared library to the build
#======================================================================
#
# Input:
#
# LIBNAME: name of the library, including 'fltk_' prefix if applicable.
#
# LIBTYPE: either "STATIC" or "SHARED"
#
# SOURCES: Files needed to build the library
#
# Output:
#
# FLTK_LIBRARIES or FLTK_LIBRARIES_SHARED (in parent scope)
#
# This function adds the given library to the build, adds it to
# either FLTK_LIBRARIES or FLTK_LIBRARIES_SHARED, respectively,
# and "exports" the modified variable to the parent scope.
#
# For each library an alias is defined (see comment below).
#
####################################################################### #######################################################################
macro (FL_ADD_LIBRARY LIBNAME LIBTYPE LIBFILES) function (fl_add_library LIBNAME LIBTYPE SOURCES)
if (${LIBTYPE} STREQUAL "SHARED") # message(STATUS "Building library **************** ${LIBNAME} ${LIBTYPE}")
set (TARGET_NAME ${LIBNAME}_SHARED)
else () set(suffix "")
set (TARGET_NAME ${LIBNAME}) if(LIBTYPE STREQUAL "SHARED")
endif (${LIBTYPE} STREQUAL "SHARED") set(suffix "-shared")
endif()
set(TARGET_NAME ${LIBNAME}${suffix})
## Strip 'fltk_' from target name (if it exists in the name)
## and use the result as EXPORT_NAME property. This makes it
## easy to export library targets fltk::fltk and fltk::images
## rather than fltk::fltk_images.
string(REPLACE "fltk_" "" EXPORT_NAME ${TARGET_NAME})
if(MSVC) if(MSVC)
set(OUTPUT_NAME_DEBUG "${LIBNAME}d") set(OUTPUT_NAME_DEBUG "${LIBNAME}d")
set (OUTPUT_NAME_RELEASE "${LIBNAME}")
else() else()
set(OUTPUT_NAME_DEBUG "${LIBNAME}") set(OUTPUT_NAME_DEBUG "${LIBNAME}")
set (OUTPUT_NAME_RELEASE "${LIBNAME}")
endif(MSVC) endif(MSVC)
add_library(${TARGET_NAME} ${LIBTYPE} ${LIBFILES}) set(OUTPUT_NAME_RELEASE "${LIBNAME}")
add_library(${TARGET_NAME} ${LIBTYPE} ${SOURCES})
# Create an alias 'fltk::alias_name' for the library
# where 'alias_name' is the library name without the prefix 'fltk_'
#
# e.g. 'fltk' -> 'fltk::fltk'
# and 'fltk-shared' -> 'fltk::fltk-shared'
# but 'fltk_images' -> 'fltk::images'
# and 'fltk_images-shared' -> 'fltk::images-shared'
if(NOT (LIBNAME STREQUAL "fltk"))
string(REPLACE "fltk_" "" alias_name ${LIBNAME})
else()
set(alias_name ${LIBNAME})
endif()
set(alias_name "fltk::${alias_name}${suffix}")
add_library (${alias_name} ALIAS ${TARGET_NAME})
if(0)
fl_debug_var(TARGET_NAME)
fl_debug_var(LIBTYPE)
fl_debug_var(alias_name)
# fl_debug_var(SOURCES)
endif()
# Target properties for all libraries # Target properties for all libraries
# Set 'PRIVATE' target compile definitions for the library # Set 'PRIVATE' target compile definitions for the library
# so they are not inherited by consumers # so they are not inherited by consumers
target_compile_definitions(${TARGET_NAME} target_compile_definitions (${TARGET_NAME} PRIVATE "FL_LIBRARY")
PRIVATE "FL_LIBRARY")
# additional target properties for static libraries # Set PUBLIC include and linker directories
if (${LIBTYPE} STREQUAL "STATIC") if(0) # DEBUG
message(STATUS "fl_add_library and alias : fltk::${alias_name} ALIAS ${TARGET_NAME}")
fl_debug_var(TARGET_NAME)
fl_debug_var(FLTK_INCLUDE_DIRS)
fl_debug_var(CMAKE_CURRENT_BINARY_DIR)
fl_debug_var(CMAKE_CURRENT_SOURCE_DIR)
fl_debug_var(FLTK_BUILD_INCLUDE_DIRECTORIES)
endif()
# Special handling for the core 'fltk' library,
# no matter if it's SHARED or STATIC
# FIXME: maybe this should be in src/CMakeLists.txt (?)
if(LIBNAME STREQUAL "fltk")
target_include_directories(${TARGET_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/..>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>
)
### FIXME: why does the simplified else() block not work?
### Needs investigation, using 'if(1)' for now...
if(1)
foreach(dir ${FLTK_BUILD_INCLUDE_DIRECTORIES})
target_include_directories(${TARGET_NAME} PRIVATE
$<BUILD_INTERFACE:${dir}>
)
endforeach()
else()
### This generates a wrong string in property INTERFACE_INCLUDE_DIRECTORIES:
### ... $<INSTALL_INTERFACE:include>;/git/fltk/modern-cmake/src/$<BUILD_INTERFACE:/usr/include/freetype2; ...
### ... --- OK ---------------------^^^^^^^ WRONG ^^^^^^^^^^^^^^-------- would be OK -------------------- ...
### End of string: ';/usr/include/libpng16' (WRONG: missing '>')
### I don't see anything wrong with this statement though but
### maybe I'm missing something. Albrecht, Jan 22 2024
target_include_directories(${TARGET_NAME} PRIVATE
$<BUILD_INTERFACE:${FLTK_BUILD_INCLUDE_DIRECTORIES}>
)
fl_debug_target(${TARGET_NAME})
endif()
target_link_directories(${TARGET_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../lib>
$<INSTALL_INTERFACE:lib>
)
if(APPLE AND NOT FLTK_BACKEND_X11)
target_link_libraries(${TARGET_NAME} PUBLIC "-framework Cocoa")
endif()
# we must link fltk with cairo if Cairo or Wayland is enabled (or both)
if(FLTK_HAVE_CAIRO OR FLTK_USE_CAIRO)
target_include_directories(${TARGET_NAME} PUBLIC ${PKG_CAIRO_INCLUDE_DIRS})
target_link_directories(${TARGET_NAME} PUBLIC ${PKG_CAIRO_LIBRARY_DIRS})
endif()
endif(LIBNAME STREQUAL "fltk")
# Set additional target properties for static libraries
if(LIBTYPE STREQUAL "STATIC")
set_target_properties(${TARGET_NAME} set_target_properties(${TARGET_NAME}
PROPERTIES PROPERTIES
OUTPUT_NAME ${LIBNAME} OUTPUT_NAME ${LIBNAME}
OUTPUT_NAME_DEBUG ${OUTPUT_NAME_DEBUG} OUTPUT_NAME_DEBUG ${OUTPUT_NAME_DEBUG}
OUTPUT_NAME_RELEASE ${OUTPUT_NAME_RELEASE} OUTPUT_NAME_RELEASE ${OUTPUT_NAME_RELEASE}
EXPORT_NAME ${EXPORT_NAME}
) )
endif (${LIBTYPE} STREQUAL "STATIC") endif(LIBTYPE STREQUAL "STATIC")
# additional target properties for shared (dynamic) libraries (DLL's) # Set additional target properties for shared (dynamic) libraries (DLL's)
if (${LIBTYPE} STREQUAL "SHARED") if(LIBTYPE STREQUAL "SHARED")
set_target_properties(${TARGET_NAME} set_target_properties(${TARGET_NAME} PROPERTIES
PROPERTIES
VERSION ${FLTK_VERSION} VERSION ${FLTK_VERSION}
SOVERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR} SOVERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
OUTPUT_NAME ${LIBNAME} OUTPUT_NAME ${LIBNAME}
OUTPUT_NAME_DEBUG ${OUTPUT_NAME_DEBUG} OUTPUT_NAME_DEBUG ${OUTPUT_NAME_DEBUG}
OUTPUT_NAME_RELEASE ${OUTPUT_NAME_RELEASE} OUTPUT_NAME_RELEASE ${OUTPUT_NAME_RELEASE}
EXPORT_NAME ${EXPORT_NAME}
) )
# MSVC only: # Visual Studio only:
if(MSVC) if(MSVC)
set_target_properties(${TARGET_NAME} set_target_properties(${TARGET_NAME} PROPERTIES
PROPERTIES OUTPUT_NAME ${LIBNAME}_dll
OUTPUT_NAME lib${LIBNAME} OUTPUT_NAME_DEBUG ${LIBNAME}_dlld
OUTPUT_NAME_DEBUG lib${OUTPUT_NAME_DEBUG} OUTPUT_NAME_RELEASE ${LIBNAME}_dll
OUTPUT_NAME_RELEASE lib${OUTPUT_NAME_RELEASE}
# PREFIX "lib" # for MSVC static/shared coexistence *DOES NOT WORK*
) )
target_compile_definitions (${TARGET_NAME} PRIVATE FL_DLL)
endif(MSVC) endif(MSVC)
endif (${LIBTYPE} STREQUAL "SHARED") endif(LIBTYPE STREQUAL "SHARED")
# Debug library output names (optional) # Debug library output names (optional)
set(DEBUG_ONAME 0) set(DEBUG_ONAME 0)
@ -87,37 +207,48 @@ macro (FL_ADD_LIBRARY LIBNAME LIBTYPE LIBFILES)
get_target_property (XX_ONAME ${TARGET_NAME} OUTPUT_NAME) get_target_property (XX_ONAME ${TARGET_NAME} OUTPUT_NAME)
get_target_property (XX_ONAME_DEBUG ${TARGET_NAME} OUTPUT_NAME_DEBUG) get_target_property (XX_ONAME_DEBUG ${TARGET_NAME} OUTPUT_NAME_DEBUG)
get_target_property (XX_ONAME_RELEASE ${TARGET_NAME} OUTPUT_NAME_RELEASE) get_target_property (XX_ONAME_RELEASE ${TARGET_NAME} OUTPUT_NAME_RELEASE)
get_target_property (XX_EXPORT_NAME ${TARGET_NAME} EXPORT_NAME)
message(STATUS "--- DEBUG_ONAME ---")
fl_debug_var(TARGET_NAME) fl_debug_var(TARGET_NAME)
fl_debug_var(XX_NAME) fl_debug_var(XX_NAME)
fl_debug_var(XX_ONAME) fl_debug_var(XX_ONAME)
fl_debug_var(XX_ONAME_DEBUG) fl_debug_var(XX_ONAME_DEBUG)
fl_debug_var(XX_ONAME_RELEASE) fl_debug_var(XX_ONAME_RELEASE)
message (STATUS "---") fl_debug_var(XX_EXPORT_NAME)
message(STATUS "--- /DEBUG_ONAME ---")
endif(DEBUG_ONAME) endif(DEBUG_ONAME)
if(MSVC) if(MSVC)
if (OPTION_LARGE_FILE) if(FLTK_OPTION_LARGE_FILE)
set_target_properties(${TARGET_NAME} fl_debug_var(FLTK_OPTION_LARGE_FILE)
PROPERTIES fl_debug_var(TARGET_NAME)
set_target_properties(${TARGET_NAME} PROPERTIES
LINK_FLAGS /LARGEADDRESSAWARE LINK_FLAGS /LARGEADDRESSAWARE
) )
endif (OPTION_LARGE_FILE) endif(FLTK_OPTION_LARGE_FILE)
if (${LIBTYPE} STREQUAL "SHARED")
target_compile_definitions(${TARGET_NAME}
PRIVATE "FL_DLL")
endif ()
endif(MSVC) endif(MSVC)
install (TARGETS ${TARGET_NAME} install(TARGETS ${TARGET_NAME} EXPORT FLTK-Targets
EXPORT FLTK-Targets
RUNTIME DESTINATION ${FLTK_BINDIR} RUNTIME DESTINATION ${FLTK_BINDIR}
LIBRARY DESTINATION ${FLTK_LIBDIR} LIBRARY DESTINATION ${FLTK_LIBDIR}
ARCHIVE DESTINATION ${FLTK_LIBDIR} ARCHIVE DESTINATION ${FLTK_LIBDIR}
) )
if(LIBTYPE STREQUAL "SHARED")
list(APPEND FLTK_LIBRARIES_SHARED "${TARGET_NAME}")
set(FLTK_LIBRARIES_SHARED "${FLTK_LIBRARIES_SHARED}" PARENT_SCOPE)
else()
list(APPEND FLTK_LIBRARIES "${TARGET_NAME}") list(APPEND FLTK_LIBRARIES "${TARGET_NAME}")
set (FLTK_LIBRARIES ${FLTK_LIBRARIES} PARENT_SCOPE) set(FLTK_LIBRARIES "${FLTK_LIBRARIES}" PARENT_SCOPE)
endif()
endmacro (FL_ADD_LIBRARY LIBNAME LIBTYPE LIBFILES) if(0)
fl_debug_var(fl_add_library_DEBUG)
fl_debug_var(FLTK_LIBRARIES)
fl_debug_var(FLTK_LIBRARIES_SHARED)
fl_debug_var(fl_add_library_END)
message("")
endif()
endfunction (fl_add_library LIBNAME LIBTYPE SOURCES)

View File

@ -2,7 +2,7 @@
# A function used by the CMake build system for the Fast Light Tool Kit (FLTK). # A function used by the CMake build system for the Fast Light Tool Kit (FLTK).
# Originally written by Michael Surette # Originally written by Michael Surette
# #
# Copyright 1998-2023 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -17,7 +17,7 @@
################################################################################ ################################################################################
# #
# function CREATE_EXAMPLE - Create a test/demo (example) program # function fl_create_example - Create a test/demo (example) program
# #
# Input: # Input:
# #
@ -42,15 +42,12 @@
# These files must reside in the subdirectory 'mac-resources'. # These files must reside in the subdirectory 'mac-resources'.
# #
# - LIBRARIES: # - LIBRARIES:
# List of libraries (CMake target names), separated by ';'. Needs # List of libraries (CMake target names), separated by ';'. Must be
# quotes if more than one library is required, e.g. "fltk_gl;fltk" # quoted if more than one library is required, e.g. "fltk::gl;fltk::images"
#
# CREATE_EXAMPLE can have an optional fourth argument with a list of options
# - these options are currently not used
# #
################################################################################ ################################################################################
function (CREATE_EXAMPLE NAME SOURCES LIBRARIES) function (fl_create_example NAME SOURCES LIBRARIES)
set(srcs) # source files set(srcs) # source files
set(flsrcs) # fluid source (.fl) files set(flsrcs) # fluid source (.fl) files
@ -61,18 +58,11 @@ function (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
# create macOS bundle? 0 = no, 1 = yes # create macOS bundle? 0 = no, 1 = yes
if (APPLE AND (NOT OPTION_APPLE_X11)) if(APPLE AND NOT FLTK_BACKEND_X11)
set(MAC_BUNDLE 1) set(MAC_BUNDLE 1)
else() else()
set(MAC_BUNDLE 0) set(MAC_BUNDLE 0)
endif (APPLE AND (NOT OPTION_APPLE_X11)) endif()
# rename target name "help" (reserved since CMake 2.8.12)
# FIXME: not necessary in FLTK 1.4 but left for compatibility (06/2020)
if (${TARGET_NAME} STREQUAL "help")
set (TARGET_NAME "test_help")
endif (${TARGET_NAME} STREQUAL "help")
# filter input files for different handling (fluid, icon, plist, source) # filter input files for different handling (fluid, icon, plist, source)
@ -117,25 +107,35 @@ function (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
endif(MAC_BUNDLE) endif(MAC_BUNDLE)
set_target_properties (${TARGET_NAME} PROPERTIES OUTPUT_NAME ${NAME}) set_target_properties (${TARGET_NAME} PROPERTIES OUTPUT_NAME ${NAME})
target_link_libraries (${TARGET_NAME} ${LIBRARIES}) target_link_libraries (${TARGET_NAME} PRIVATE ${LIBRARIES})
# make sure we're "exporting" global symbols like 'fl_disable_wayland', # make sure we're "exporting" global symbols like 'fl_disable_wayland',
# see also README.Wayland.txt and CMake policy CMP0065. # see also README.Wayland.txt and CMake policy CMP0065.
set_target_properties (${TARGET_NAME} PROPERTIES ENABLE_EXPORTS TRUE) set_target_properties (${TARGET_NAME} PROPERTIES ENABLE_EXPORTS TRUE)
# we must link all programs with cairo if option CAIROEXT is enabled ### *FIXME* Remove the entire 'if' block below when verified:
if(0) # This should no longer be necessary (implied by linking the libs)
# we must link all programs with Cairo if option CAIROEXT is enabled
if(FLTK_HAVE_CAIROEXT) if(FLTK_HAVE_CAIROEXT)
target_link_libraries (${TARGET_NAME} ${PKG_CAIRO_LIBRARIES}) target_link_libraries(${TARGET_NAME} PRIVATE ${PKG_CAIRO_LIBRARIES})
endif() endif()
if(FLTK_HAVE_CAIRO AND PKG_CAIRO_LIBRARY_DIRS) if(FLTK_HAVE_CAIRO AND PKG_CAIRO_LIBRARY_DIRS)
target_link_directories (${TARGET_NAME} PUBLIC ${PKG_CAIRO_LIBRARY_DIRS}) target_link_directories(${TARGET_NAME} PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
endif() endif()
if (USE_GDIPLUS) # can only be true on Windows endif() # This should no longer be necessary (implied by linking the libs)
target_link_libraries (${TARGET_NAME} gdiplus)
endif () # Search the current binary directory for header files created by CMake
# or fluid and the source folder for other headers included by test programs
target_include_directories(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
if(MAC_BUNDLE) if(MAC_BUNDLE)
if(PLIST) if(PLIST)
@ -173,26 +173,15 @@ function (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
unset(WRAPPER) unset(WRAPPER)
endif(MAC_BUNDLE) endif(MAC_BUNDLE)
if (MSVC AND TARGET fltk_SHARED) ##############################################################################
set (DllDir "$<SHELL_PATH:$<TARGET_FILE_DIR:fltk_SHARED>>") # MSVC: Add fltk-shared (DLL) path to Environment 'PATH' for debugging
## fl_debug_var (DllDir) ##############################################################################
if(MSVC AND TARGET fltk-shared)
set(DllDir "$<SHELL_PATH:$<TARGET_FILE_DIR:fltk-shared>>")
set_target_properties(${TARGET_NAME} PROPERTIES set_target_properties(${TARGET_NAME} PROPERTIES
VS_DEBUGGER_ENVIRONMENT "PATH=${DllDir};$ENV{PATH}" VS_DEBUGGER_ENVIRONMENT "PATH=${DllDir};$ENV{PATH}"
) )
endif() endif()
######################################################################
# Parse optional fourth argument, see description above.
######################################################################
# code left commented out as an example
# *unused* # if (${ARGC} GREATER 3)
# *unused* # foreach (OPTION ${ARGV3})
# *unused* # if (${OPTION} STREQUAL "xxx")
# *unused* # # do something ...
# *unused* # endif ()
# *unused* # endforeach ()
# *unused* # endif ()
endfunction () endfunction ()

View File

@ -1,7 +1,7 @@
# #
# Macro used by the CMake build system for the Fast Light Tool Kit (FLTK). # Function used by the CMake build system for the Fast Light Tool Kit (FLTK).
# #
# Copyright 1998-2022 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -15,10 +15,42 @@
# #
####################################################################### #######################################################################
# fl_debug_var - a macro to output debugging info # fl_expand_name - a function to expand a variable name with spaces
####################################################################### #######################################################################
# #
# This macro displays the name and value of a CMake variable. # This function returns a string comprising of the given name and
# enough spaces to have at least the given minimal length (min_len).
# Currently min_len must not be greater than 50.
#
# If the string is already at least min_len it is not changed,
# otherwise the string is returned to the given variable (out)
# in the parent scope.
#
# Syntax:
# fl_expand_name (out in min_len)
#
# Example:
# fl_expand_name (var WIN32 30)
# fl_expand_name (var UNIX 40)
#
#######################################################################
function (fl_expand_name out in min_len)
string(LENGTH "${in}" len)
if(len LESS min_len)
set(spaces " ")
set(temp "${in}")
set(temp "${in}${spaces}${spaces}")
string(SUBSTRING "${temp}" 0 ${min_len} temp)
set(${out} "${temp}" PARENT_SCOPE)
endif()
endfunction (fl_expand_name)
#######################################################################
# fl_debug_var - a function to output debugging info
#######################################################################
#
# This function displays the name and value of a CMake variable.
# The variable name is expanded with spaces to be (at least) # The variable name is expanded with spaces to be (at least)
# <min_len> (currently 30) characters wide for better readability. # <min_len> (currently 30) characters wide for better readability.
# VARNAME must be a string literal, e.g. WIN32 or "WIN32". # VARNAME must be a string literal, e.g. WIN32 or "WIN32".
@ -32,15 +64,52 @@
# #
####################################################################### #######################################################################
macro (fl_debug_var name) function (fl_debug_var name)
set (min_len 32)
set(var "${name}") set(var "${name}")
string(LENGTH "${var}" len) fl_expand_name(var "${name}" 40)
while (len LESS min_len)
# add one space until min_len is reached
# ** string(APPEND var " ") # requires CMake 3.4.x (otherwise loop...)
set (var "${var} ")
string(LENGTH "${var}" len)
endwhile (len LESS min_len)
message(STATUS "${var} = '${${name}}'") message(STATUS "${var} = '${${name}}'")
endmacro (fl_debug_var) endfunction (fl_debug_var)
#######################################################################
# fl_debug_target - a function to output info about a target
#######################################################################
#
# This function displays properties of a CMake target.
#
# Currently there's a fixed number of properties.
#
# Syntax:
# fl_debug_target(target)
#
# Example:
# fl_debug_target(fltk)
# fl_debug_target(fluid)
# fl_debug_target(fltk_image)
# fl_debug_target(fltk::forms)
#
#######################################################################
function (fl_debug_target name)
message(STATUS "+++ fl_debug_target (${name})")
set(var "${name}")
fl_expand_name(var "${name}" 40)
if(TARGET ${name})
message(STATUS "${var} = <target>")
foreach(prop
ALIASED_TARGET
INTERFACE_INCLUDE_DIRECTORIES
INTERFACE_LINK_DIRECTORIES
INTERFACE_LINK_LIBRARIES)
get_target_property (${prop} ${name} ${prop})
if(NOT ${prop})
set(${prop} "")
endif()
fl_debug_var(${prop})
endforeach()
else()
message(STATUS "${var} = <not a target>")
endif()
message(STATUS "")
endfunction (fl_debug_target)

View File

@ -2,7 +2,7 @@
# Installation support for building the FLTK project using CMake (www.cmake.org) # Installation support for building the FLTK project using CMake (www.cmake.org)
# Originally written by Michael Surette # Originally written by Michael Surette
# #
# Copyright 1998-2022 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -44,9 +44,9 @@ install (DIRECTORY
PATTERN "*.[hH]" PATTERN "*.[hH]"
) )
if (OPTION_CREATE_LINKS) if(FLTK_INSTALL_LINKS)
install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/install-symlinks.cmake) install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/install-symlinks.cmake)
endif (OPTION_CREATE_LINKS) endif(FLTK_INSTALL_LINKS)
# generate FLTKConfig.cmake for installed directory use # generate FLTKConfig.cmake for installed directory use
set(INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include) set(INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include)
@ -59,6 +59,7 @@ set (CONFIG_PATH ${CMAKE_INSTALL_PREFIX}/${FLTK_CONFIG_PATH})
install(EXPORT FLTK-Targets install(EXPORT FLTK-Targets
DESTINATION ${FLTK_CONFIG_PATH} DESTINATION ${FLTK_CONFIG_PATH}
FILE FLTK-Targets.cmake FILE FLTK-Targets.cmake
NAMESPACE fltk::
) )
configure_file( configure_file(

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
# #
# Resource definitions to build the FLTK project using CMake (www.cmake.org) # Resource definitions to build the FLTK project using CMake (www.cmake.org)
# Written by Michael Surette # Originally written by Michael Surette
# #
# Copyright 1998-2021 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -53,6 +53,9 @@ if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD")
list(APPEND CMAKE_REQUIRED_INCLUDES /usr/local/include) list(APPEND CMAKE_REQUIRED_INCLUDES /usr/local/include)
endif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD") endif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD")
# fl_debug_var(CMAKE_HOST_SYSTEM_NAME)
# fl_debug_var(CMAKE_REQUIRED_INCLUDES)
fl_find_header (HAVE_ALSA_ASOUNDLIB_H alsa/asoundlib.h) fl_find_header (HAVE_ALSA_ASOUNDLIB_H alsa/asoundlib.h)
fl_find_header (HAVE_DLFCN_H dlfcn.h) fl_find_header (HAVE_DLFCN_H dlfcn.h)
fl_find_header (HAVE_GL_GLU_H GL/glu.h) fl_find_header (HAVE_GL_GLU_H GL/glu.h)
@ -148,7 +151,7 @@ find_path (FREETYPE_PATH freetype.h PATH_SUFFIXES freetype2)
find_path (FREETYPE_PATH freetype/freetype.h PATH_SUFFIXES freetype2) find_path (FREETYPE_PATH freetype/freetype.h PATH_SUFFIXES freetype2)
if(FREETYPE_PATH) if(FREETYPE_PATH)
include_directories (${FREETYPE_PATH}) list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${FREETYPE_PATH})
endif(FREETYPE_PATH) endif(FREETYPE_PATH)
mark_as_advanced (FREETYPE_PATH) mark_as_advanced (FREETYPE_PATH)
@ -156,9 +159,9 @@ mark_as_advanced (FREETYPE_PATH)
####################################################################### #######################################################################
# libraries # libraries
find_library (LIB_dl dl) find_library (LIB_dl dl)
if ((NOT APPLE) OR OPTION_APPLE_X11) if((NOT APPLE) OR FLTK_BACKEND_X11)
find_library (LIB_fontconfig fontconfig) find_library (LIB_fontconfig fontconfig)
endif ((NOT APPLE) OR OPTION_APPLE_X11) endif((NOT APPLE) OR FLTK_BACKEND_X11)
find_library (LIB_freetype freetype) find_library (LIB_freetype freetype)
find_library (LIB_GL GL) find_library (LIB_GL GL)
find_library (LIB_MesaGL MesaGL) find_library (LIB_MesaGL MesaGL)

View File

@ -2,7 +2,7 @@
# CMakeLists.txt to build the FLTK project using CMake (www.cmake.org) # CMakeLists.txt to build the FLTK project using CMake (www.cmake.org)
# Originally written by Michael Surette # Originally written by Michael Surette
# #
# Copyright 1998-2023 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -26,13 +26,6 @@ set (ARCHIVE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib)
# Search for modules in the FLTK source dir first # Search for modules in the FLTK source dir first
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
set (FLTK_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
include_directories (${FLTK_INCLUDE_DIRS})
# Remember root of FLTK source directory in case we're in a subdirectory.
# Used for instance to find the source directory for doxygen docs
set (FLTK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
# Setup install locations (requires CMake 2.8.4) # Setup install locations (requires CMake 2.8.4)
include(GNUInstallDirs) include(GNUInstallDirs)
@ -52,10 +45,42 @@ set (FLTK_DOCDIR ${CMAKE_INSTALL_DATADIR}/doc CACHE PATH
####################################################################### #######################################################################
# initialize internally used variables # Initialize variables needed to collect include directories etc..
# some of these variables are used to *append* other values later # Some of these variables are used to *append* other values later
####################################################################### #######################################################################
set(FLTK_BUILD_INCLUDE_DIRECTORIES "")
set(FLTK_IMAGE_INCLUDE_DIRECTORIES "")
set(FLTK_IMAGE_LIBRARIES "")
set(FLTK_IMAGE_LIBRARIES_SHARED "")
set(FLTK_CFLAGS "")
set(FLTK_LIBRARIES "")
set(FLTK_LIBRARIES_SHARED "")
# Remember root of FLTK source directory in case we're later in a subdirectory.
# Used for instance to find the source directory for doxygen docs
set(FLTK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if(FLTK_SOURCE_DIR STREQUAL ${CMAKE_SOURCE_DIR})
set(FLTK_IS_TOPLEVEL TRUE)
else()
set(FLTK_IS_TOPLEVEL FALSE)
endif()
# Note: FLTK_INCLUDE_DIRS is used to export the required include directories
# in FLTKConfig.cmake etc.
# ### FIXME ### check if we really need this ...
set(FLTK_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
# FLTK_BUILD_INCLUDE_DIRECTORIES is used to build the main FLTK lib
set(FLTK_BUILD_INCLUDE_DIRECTORIES)
# Some of these variables are used to *append* other values later
set(FLTK_LDLIBS "") set(FLTK_LDLIBS "")
set(FLTK_LIBRARIES "") set(FLTK_LIBRARIES "")
set(GLLIBS "") set(GLLIBS "")
@ -72,7 +97,7 @@ set (STATICIMAGELIBS "")
# set where config files go # set where config files go
if(WIN32 AND NOT CYGWIN) if(WIN32 AND NOT CYGWIN)
set(FLTK_CONFIG_PATH CMake) set(FLTK_CONFIG_PATH CMake)
elseif (APPLE AND NOT OPTION_APPLE_X11) elseif(APPLE AND NOT FLTK_BACKEND_X11)
set(FLTK_CONFIG_PATH FLTK.framework/Resources/CMake) set(FLTK_CONFIG_PATH FLTK.framework/Resources/CMake)
else() else()
set(FLTK_CONFIG_PATH ${FLTK_DATADIR}/fltk) set(FLTK_CONFIG_PATH ${FLTK_DATADIR}/fltk)
@ -94,14 +119,14 @@ if (APPLE)
set(HAVE_VSNPRINTF 1) set(HAVE_VSNPRINTF 1)
set(HAVE_SCANDIR 1) set(HAVE_SCANDIR 1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
if (OPTION_APPLE_X11) if(FLTK_BACKEND_X11)
if(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0)) # a.k.a. macOS version 10.13 if(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0)) # a.k.a. macOS version 10.13
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCPP_HAS_THREAD_API_PTHREAD") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCPP_HAS_THREAD_API_PTHREAD")
endif(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0)) endif(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0))
else() else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework Cocoa") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework Cocoa")
endif (OPTION_APPLE_X11) endif(FLTK_BACKEND_X11)
endif(APPLE) endif(APPLE)
if(WIN32) if(WIN32)

View File

@ -1,8 +1,8 @@
# #
# This file sets variables for common use in export.cmake and install.cmake # This file sets variables for common use in export.cmake and install.cmake
# Written by Michael Surette # Originally written by Michael Surette
# #
# Copyright 1998-2020 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -32,6 +32,7 @@ if (DEBUG_VARIABLES_CMAKE)
fl_debug_var(LIB_jpeg) fl_debug_var(LIB_jpeg)
fl_debug_var(LIB_png) fl_debug_var(LIB_png)
fl_debug_var(LIB_zlib) fl_debug_var(LIB_zlib)
fl_debug_var(FLTK_LIBRARIES)
endif(DEBUG_VARIABLES_CMAKE) endif(DEBUG_VARIABLES_CMAKE)
####################################################################### #######################################################################
@ -41,13 +42,13 @@ endif (DEBUG_VARIABLES_CMAKE)
if(WIN32) if(WIN32)
list(APPEND FLTK_LDLIBS -lole32 -luuid -lcomctl32 -lws2_32) list(APPEND FLTK_LDLIBS -lole32 -luuid -lcomctl32 -lws2_32)
elseif (APPLE AND NOT OPTION_APPLE_X11) elseif(APPLE AND NOT FLTK_BACKEND_X11)
list(APPEND FLTK_LDLIBS "-framework Cocoa") list(APPEND FLTK_LDLIBS "-framework Cocoa")
elseif (OPTION_USE_WAYLAND) elseif(FLTK_BACKEND_WAYLAND)
list(APPEND FLTK_LDLIBS "-lwayland-cursor -lwayland-client -lxkbcommon -ldbus-1") list(APPEND FLTK_LDLIBS "-lwayland-cursor -lwayland-client -lxkbcommon -ldbus-1")
if (OPTION_USE_SYSTEM_LIBDECOR) if(USE_SYSTEM_LIBDECOR)
list(APPEND FLTK_LDLIBS "-ldecor-0") list(APPEND FLTK_LDLIBS "-ldecor-0")
endif (OPTION_USE_SYSTEM_LIBDECOR) endif(USE_SYSTEM_LIBDECOR)
else() else()
list(APPEND FLTK_LDLIBS -lm) list(APPEND FLTK_LDLIBS -lm)
endif(WIN32) endif(WIN32)
@ -82,35 +83,37 @@ endif ()
set(IMAGELIBS) set(IMAGELIBS)
set(STATICIMAGELIBS) set(STATICIMAGELIBS)
if (FLTK_USE_BUILTIN_JPEG) if(FLTK_USE_BUNDLED_JPEG)
list(APPEND IMAGELIBS -lfltk_jpeg) list(APPEND IMAGELIBS -lfltk_jpeg)
list(APPEND STATICIMAGELIBS \$libdir/libfltk_jpeg.a) list(APPEND STATICIMAGELIBS \$libdir/libfltk_jpeg.a)
else() else()
if(LIB_jpeg) if(LIB_jpeg)
list (APPEND IMAGELIBS -ljpeg) # fl_debug_var(LIB_jpeg)
list (APPEND STATICIMAGELIBS -ljpeg) list(APPEND IMAGELIBS ${LIB_jpeg})
list(APPEND STATICIMAGELIBS ${LIB_jpeg})
endif(LIB_jpeg) endif(LIB_jpeg)
endif (FLTK_USE_BUILTIN_JPEG) endif(FLTK_USE_BUNDLED_JPEG)
if (FLTK_USE_BUILTIN_PNG) if(FLTK_USE_BUNDLED_PNG)
list(APPEND IMAGELIBS -lfltk_png) list(APPEND IMAGELIBS -lfltk_png)
list(APPEND STATICIMAGELIBS \$libdir/libfltk_png.a) list(APPEND STATICIMAGELIBS \$libdir/libfltk_png.a)
else() else()
if(LIB_png) if(LIB_png)
list (APPEND IMAGELIBS -lpng) # fl_debug_var(LIB_png)
list (APPEND STATICIMAGELIBS -lpng) list(APPEND IMAGELIBS ${LIB_png})
list(APPEND STATICIMAGELIBS ${LIB_png})
endif(LIB_png) endif(LIB_png)
endif (FLTK_USE_BUILTIN_PNG) endif(FLTK_USE_BUNDLED_PNG)
if (FLTK_USE_BUILTIN_ZLIB) if(FLTK_USE_BUNDLED_ZLIB)
list(APPEND IMAGELIBS -lfltk_z) list(APPEND IMAGELIBS -lfltk_z)
list(APPEND STATICIMAGELIBS \$libdir/libfltk_z.a) list(APPEND STATICIMAGELIBS \$libdir/libfltk_z.a)
else() else()
if(LIB_zlib) if(LIB_zlib)
list (APPEND IMAGELIBS -lz) list(APPEND IMAGELIBS ${LIB_zlib})
list (APPEND STATICIMAGELIBS -lz) list(APPEND STATICIMAGELIBS ${LIB_zlib})
endif(LIB_zlib) endif(LIB_zlib)
endif (FLTK_USE_BUILTIN_ZLIB) endif(FLTK_USE_BUNDLED_ZLIB)
string(REPLACE ";" " " IMAGELIBS "${IMAGELIBS}") string(REPLACE ";" " " IMAGELIBS "${IMAGELIBS}")
string(REPLACE ";" " " STATICIMAGELIBS "${STATICIMAGELIBS}") string(REPLACE ";" " " STATICIMAGELIBS "${STATICIMAGELIBS}")
@ -119,14 +122,14 @@ string (REPLACE ";" " " STATICIMAGELIBS "${STATICIMAGELIBS}")
set(CC ${CMAKE_C_COMPILER}) set(CC ${CMAKE_C_COMPILER})
set(CXX ${CMAKE_CXX_COMPILER}) set(CXX ${CMAKE_CXX_COMPILER})
set (ARCHFLAGS ${OPTION_ARCHFLAGS}) set(ARCHFLAGS ${FLTK_ARCHFLAGS})
string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_UPPER) string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_UPPER)
if(${BUILD_UPPER}) if(${BUILD_UPPER})
set(CFLAGS "${CMAKE_C_FLAGS_${BUILD_UPPER}} ${CFLAGS}") set(CFLAGS "${CMAKE_C_FLAGS_${BUILD_UPPER}} ${CFLAGS}")
endif(${BUILD_UPPER}) endif(${BUILD_UPPER})
set (CFLAGS "${OPTION_OPTIM} ${CMAKE_C_FLAGS} ${CFLAGS}") set(CFLAGS "${FLTK_OPTION_OPTIM} ${CMAKE_C_FLAGS} ${CFLAGS}")
foreach(arg ${FLTK_CFLAGS}) foreach(arg ${FLTK_CFLAGS})
set(CFLAGS "${CFLAGS} ${arg}") set(CFLAGS "${CFLAGS} ${arg}")
endforeach(arg ${FLTK_CFLAGS}) endforeach(arg ${FLTK_CFLAGS})
@ -159,6 +162,7 @@ if (DEBUG_VARIABLES_CMAKE)
fl_debug_var(LIB_jpeg) fl_debug_var(LIB_jpeg)
fl_debug_var(LIB_png) fl_debug_var(LIB_png)
fl_debug_var(LIB_zlib) fl_debug_var(LIB_zlib)
fl_debug_var(FLTK_LIBRARIES)
message(STATUS "[** end of variables.cmake **]") message(STATUS "[** end of variables.cmake **]")
endif(DEBUG_VARIABLES_CMAKE) endif(DEBUG_VARIABLES_CMAKE)
unset(DEBUG_VARIABLES_CMAKE) unset(DEBUG_VARIABLES_CMAKE)

View File

@ -2,7 +2,7 @@
# Main CMakeLists.txt to build the FLTK project using CMake (www.cmake.org) # Main CMakeLists.txt to build the FLTK project using CMake (www.cmake.org)
# Originally written by Michael Surette # Originally written by Michael Surette
# #
# Copyright 1998-2023 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -16,7 +16,7 @@
# #
####################################################################### #######################################################################
# Set CMake minimum version first: must be before `project()` # Set CMake minimum version first: must be set before `project()`
####################################################################### #######################################################################
# Minimum CMake version required by FLTK 1.4 # Minimum CMake version required by FLTK 1.4
@ -29,6 +29,9 @@
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR) cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
# Since CMake 3.4: enable symbol export from all executable targets
# cmake_policy(SET CMP0065 OLD)
####################################################################### #######################################################################
# define the FLTK project and version # define the FLTK project and version
####################################################################### #######################################################################
@ -86,7 +89,7 @@ if (debug_build)
fl_debug_var(APPLE) fl_debug_var(APPLE)
fl_debug_var(CMAKE_BUILD_TYPE) fl_debug_var(CMAKE_BUILD_TYPE)
fl_debug_var(CMAKE_SIZEOF_VOID_P) fl_debug_var(CMAKE_SIZEOF_VOID_P)
fl_debug_var (OPTION_OPTIM) fl_debug_var(FLTK_OPTION_OPTIM)
fl_debug_var(CMAKE_C_FLAGS) fl_debug_var(CMAKE_C_FLAGS)
fl_debug_var(CMAKE_CXX_FLAGS) fl_debug_var(CMAKE_CXX_FLAGS)
fl_debug_var(CMAKE_EXE_LINKER_FLAGS) fl_debug_var(CMAKE_EXE_LINKER_FLAGS)
@ -173,7 +176,7 @@ include (CMake/install.cmake)
# Enable (1) or disable (0) generation of experimental headers (WIP) # Enable (1) or disable (0) generation of experimental headers (WIP)
set(GENERATE_EXPORT_HEADERS 0) set(GENERATE_EXPORT_HEADERS 0)
if (OPTION_BUILD_SHARED_LIBS AND GENERATE_EXPORT_HEADERS) if(FLTK_BUILD_SHARED_LIBS AND GENERATE_EXPORT_HEADERS)
include(GenerateExportHeader) include(GenerateExportHeader)
@ -207,7 +210,7 @@ if (OPTION_BUILD_SHARED_LIBS AND GENERATE_EXPORT_HEADERS)
endif(NOT MSVC) endif(NOT MSVC)
endif (OPTION_BUILD_SHARED_LIBS AND GENERATE_EXPORT_HEADERS) endif(FLTK_BUILD_SHARED_LIBS AND GENERATE_EXPORT_HEADERS)
####################################################################### #######################################################################
# Output Configuration Summary # Output Configuration Summary
@ -221,10 +224,10 @@ 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) if(FLTK_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() 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 FLTK_BUILD_SHARED_LIBS=ON to build)")
endif() endif()
if(FLTK_BUILD_FORMS) if(FLTK_BUILD_FORMS)
@ -233,10 +236,16 @@ else ()
message(STATUS "The forms library will not be built (set FLTK_BUILD_FORMS=ON to build)") message(STATUS "The forms library will not be built (set FLTK_BUILD_FORMS=ON to build)")
endif() endif()
if (FLTK_BUILD_FLUID) if(FLTK_USE_GL)
message (STATUS "FLUID will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fluid") message(STATUS "The OpenGL library will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib")
else() else()
message (STATUS "FLUID will not be built (set FLTK_BUILD_FLUID=ON to build)") message(STATUS "The OpenGL library will not be built (set FLTK_BUILD_GL=ON to build)")
endif()
if(FLTK_BUILD_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)")
endif() endif()
if(FLTK_BUILD_FLTK_OPTIONS) if(FLTK_BUILD_FLTK_OPTIONS)
@ -267,29 +276,29 @@ endif ()
message(STATUS "") message(STATUS "")
if (FLTK_USE_BUILTIN_JPEG) if(FLTK_USE_BUNDLED_JPEG)
message(STATUS "Image Libraries : JPEG = Builtin") message(STATUS "Image Libraries : JPEG = Builtin")
else() else()
message(STATUS "Image Libraries : JPEG = System") message(STATUS "Image Libraries : JPEG = System")
endif() endif()
if (FLTK_USE_BUILTIN_PNG) if(FLTK_USE_BUNDLED_PNG)
message(STATUS " : PNG = Builtin") message(STATUS " : PNG = Builtin")
else() else()
message(STATUS " : PNG = System") message(STATUS " : PNG = System")
endif() endif()
if (FLTK_USE_BUILTIN_ZLIB) if(FLTK_USE_BUNDLED_ZLIB)
message(STATUS " : ZLIB = Builtin") message(STATUS " : ZLIB = Builtin")
else() else()
message(STATUS " : ZLIB = System") message(STATUS " : ZLIB = System")
endif() endif()
if (UNIX AND NOT (APPLE AND NOT OPTION_APPLE_X11)) if(UNIX AND NOT (APPLE AND NOT FLTK_BACKEND_X11))
if (OPTION_USE_WAYLAND) if(FLTK_BACKEND_WAYLAND)
message(STATUS "Use Wayland : Yes (if available at run-time)") message(STATUS "Use Wayland : Yes (if available at run-time)")
if (OPTION_USE_SYSTEM_LIBDECOR) if(USE_SYSTEM_LIBDECOR)
message(STATUS "Use system libdecor : Yes") message(STATUS "Use system libdecor : Yes")
else() else()
message(STATUS "Use system libdecor : No") message(STATUS "Use system libdecor : No")
@ -306,16 +315,16 @@ if (UNIX AND NOT (APPLE AND NOT OPTION_APPLE_X11))
if(USE_PANGO) if(USE_PANGO)
message(STATUS "Use Pango : Yes") message(STATUS "Use Pango : Yes")
else (USE_PANGO) else()
message(STATUS "Use Pango : No") message(STATUS "Use Pango : No")
if(USE_XFT) if(USE_XFT)
message(STATUS "Use Xft : Yes") message(STATUS "Use Xft : Yes")
else() else()
message(STATUS "Use Xft : No") message(STATUS "Use Xft : No")
endif (USE_XFT) endif()
endif (USE_PANGO) endif()
endif (UNIX AND NOT (APPLE AND NOT OPTION_APPLE_X11)) endif()
if(FLTK_HAVE_CAIROEXT) if(FLTK_HAVE_CAIROEXT)
message(STATUS "Fl_Cairo_Window support : Yes (extended)") message(STATUS "Fl_Cairo_Window support : Yes (extended)")
@ -333,3 +342,20 @@ endif ()
message("") message("")
message(STATUS "End of Configuration Summary --\n") message(STATUS "End of Configuration Summary --\n")
# optional info for "modern CMake"
if(0) # debug built library and fluid targets
message(STATUS "------------------------ TARGETS ------------------------")
foreach(tgt fltk fluid fluid-cmd options options-cmd images gl forms cairo jpeg png z)
if(TARGET fltk::${tgt})
message("Target: fltk::${tgt}")
# fl_debug_target(fltk::${tgt})
endif()
if(TARGET fltk::${tgt}-shared)
message("Target: fltk::${tgt}-shared")
# fl_debug_target(fltk::${tgt}-shared)
endif()
endforeach()
message(STATUS "---------------------------------------------------------")
endif()

View File

@ -1473,8 +1473,8 @@ public:
\endcode \endcode
If you configure FLTK with \c '--enable-cairo' or CMake option If you configure FLTK with \c '--enable-cairo' or CMake option
\c 'OPTION_CAIRO' (i.e. without \c '--enable-cairoext' or CMake option \c 'FLTK_OPTION_CAIRO_WINDOW' (i.e. without \c '--enable-cairoext' or CMake option
\c 'OPTION_CAIROEXT') or if you don't enable the \c 'autolink' Cairo \c 'FLTK_OPTION_CAIRO_EXT') or if you don't enable the \c 'autolink' Cairo
context you may do the equivalent to use Cairo drawings in an context you may do the equivalent to use Cairo drawings in an
overridden draw() method of derived classes by using overridden draw() method of derived classes by using
\code \code

View File

@ -51,7 +51,7 @@
For internal use only. For internal use only.
\note Only available when configure has the --enable-cairo or \note Only available when configure has the --enable-cairo or
--enable-cairoext option or one or both of the CMake options --enable-cairoext option or one or both of the CMake options
OPTION_CAIRO or OPTION_CAIROEXT is set (ON) FLTK_OPTION_CAIRO_WINDOW or FLTK_OPTION_CAIRO_EXT is set (ON)
*/ */
class FL_EXPORT Fl_Cairo_State { class FL_EXPORT Fl_Cairo_State {
public: public:

View File

@ -78,7 +78,7 @@
\see test/cairo_test.cxx \see test/cairo_test.cxx
\note Class Fl_Cairo_Window requires the FLTK library to have been built with \note Class Fl_Cairo_Window requires the FLTK library to have been built with
CMake option OPTION_CAIRO or configure --enable-cairo. CMake option FLTK_OPTION_CAIRO_WINDOW or configure --enable-cairo.
\note You can alternatively define your custom Cairo FLTK window, \note You can alternatively define your custom Cairo FLTK window,
and thus at least override the draw() method to provide custom Cairo and thus at least override the draw() method to provide custom Cairo

View File

@ -1,8 +1,8 @@
// //
// FLTK native OS file chooser widget // FLTK native OS file chooser widget
// //
// Copyright 1998-2016 by Bill Spitzak and others.
// Copyright 2004 Greg Ercolano. // Copyright 2004 Greg Ercolano.
// Copyright 2005-2024 by Bill Spitzak and others.
// //
// This library is free software. Distribution and use rights are outlined in // 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 // the file "COPYING" which should have been included with this file. If this
@ -108,7 +108,7 @@ class Fl_Native_File_Chooser_Driver;
not turned off, the \p zenity -based dialog opens. This is expected to be more appropriate not turned off, the \p zenity -based dialog opens. This is expected to be more appropriate
than other dialog forms for sandboxed apps. than other dialog forms for sandboxed apps.
-# Else if the app runs under the KDE desktop and if command \p kdialog is available at run-time -# Else if the app runs under the KDE desktop and if command \p kdialog is available at run-time
and if the library was not built with <tt>cmake -DOPTION_USE_KDIALOG=Off</tt>, the and if the library was not built with <tt>cmake -D FLTK_USE_KDIALOG=OFF</tt>, the
\p kdialog -based dialog opens. \p kdialog -based dialog opens.
-# Else if the GTK library is available at run-time on the computer and if \p Fl::option(OPTION_FNFC_USES_GTK) is -# Else if the GTK library is available at run-time on the computer and if \p Fl::option(OPTION_FNFC_USES_GTK) is
not turned off, the GTK-styled dialog opens. Call fl_register_images() to add a "Preview" button to this dialog. not turned off, the GTK-styled dialog opens. Call fl_register_images() to add a "Preview" button to this dialog.

View File

@ -75,7 +75,7 @@
<li>If the GTK library is available at run-time, class Fl_Printer runs GTK's printer dialog which allows to set <li>If the GTK library is available at run-time, class Fl_Printer runs GTK's printer dialog which allows to set
printer, paper size and orientation. printer, paper size and orientation.
<li>Under the KDE desktop, Fl_Printer runs the <tt>kdialog</tt> command to create KDE-styled file dialogs if <li>Under the KDE desktop, Fl_Printer runs the <tt>kdialog</tt> command to create KDE-styled file dialogs if
that command is available at run-time, unless FLTK was built with CMake and option OPTION_USE_KDIALOG turned off. that command is available at run-time, unless FLTK was built with CMake and option FLTK_USE_KDIALOG turned off.
In that case, Fl_Printer attempts to run the GTK dialog. In that case, Fl_Printer attempts to run the GTK dialog.
<li>If the GTK library is not available, or if Fl::option(Fl::OPTION_PRINTER_USES_GTK) has been turned off, <li>If the GTK library is not available, or if Fl::option(Fl::OPTION_PRINTER_USES_GTK) has been turned off,
class Fl_Printer runs FLTK's print dialog. class Fl_Printer runs FLTK's print dialog.

View File

@ -24,7 +24,7 @@
// EXPERIMENTAL // EXPERIMENTAL
// We use either std::vector or the private class Fl_Int_Vector // We use either std::vector or the private class Fl_Int_Vector
// depending on the build option OPTION_USE_STD or --enable-use_std. // depending on the build option FLTK_OPTION_STD or --enable-use_std.
// This option allows to use std::string and std::vector in FLTK 1.4.x // This option allows to use std::string and std::vector in FLTK 1.4.x
#if (FLTK_USE_STD) #if (FLTK_USE_STD)

View File

@ -38,7 +38,7 @@ extern Window fl_x11_xid(const Fl_Window *win);
extern Fl_Window *fl_x11_find(Window xid); extern Fl_Window *fl_x11_find(Window xid);
/** Returns the X11-specific currently active graphics context. */ /** Returns the X11-specific currently active graphics context. */
extern GC fl_x11_gc(); extern GC fl_x11_gc();
/** Returns the Cairo-specific currently active graphics context (OPTION_USE_CAIRO=On) */ /** Returns the Cairo-specific currently active graphics context (FLTK_GRAPHICS_CAIRO=On) */
extern cairo_t* fl_cairo_gc(); extern cairo_t* fl_cairo_gc();
#else // ! FL_DOXYGEN #else // ! FL_DOXYGEN

View File

@ -6,21 +6,34 @@ README.CMake.txt - Building and using FLTK with CMake
========== ==========
1 Introduction to CMake 1 Introduction to CMake
2 Using CMake to Build FLTK 2 Using CMake to Build FLTK
2.1 Prerequisites 2.1 Prerequisites
2.2 Options 2.2 Options
2.2.1 General CMake Options
2.2.2 FLTK Specific Build Options
2.2.3 Documentation Options
2.2.4 Special Options
2.3 Building under Linux with Unix Makefiles 2.3 Building under Linux with Unix Makefiles
2.4 Building under Windows with Visual Studio [SUGGESTED DOCS -erco] 2.4 Building under Windows with Visual Studio and/or NMake
2.4.1 Building under Windows with Visual Studio
2.4.2 Building under Windows with NMake
2.5 Building under Windows with MinGW using Makefiles 2.5 Building under Windows with MinGW using Makefiles
2.6 Building under MacOS with Xcode 2.6 Building under MacOS with Xcode
2.7 Crosscompiling 2.7 Crosscompiling
3 Using CMake with FLTK
3.1 Library Names
3.2 Building a Simple "Hello World" Program with FLTK
3.3 Building a Program Using Fluid Files
3.4 Building a Program Using CMake's FetchContent Module
4 Document History
3 Using CMake with FLTK
3.1 Library Names
3.2 Library Aliases
3.3 Exported and Imported Targets
3.4 Building a Simple "Hello World" Program with FLTK
3.5 Building a Program Using Fluid Files
3.6 Building a Program Using CMake's FetchContent Module
4 FindFLTK.cmake and find_package(FLTK)
1. Introduction to CMake 1. Introduction to CMake
=========================== ===========================
@ -51,7 +64,7 @@ VC++ and MinGW on Windows, or do some cross-compiling you must use out-of-tree
builds exclusively. In-tree builds will gum up the works by putting a builds exclusively. In-tree builds will gum up the works by putting a
CMakeCache.txt file in the source root. CMakeCache.txt file in the source root.
More information on CMake can be found on its web site http://www.cmake.org. More information on CMake can be found on its web site https://www.cmake.org.
@ -63,8 +76,8 @@ More information on CMake can be found on its web site http://www.cmake.org.
-------------------- --------------------
The prerequisites for building FLTK with CMake are staightforward: The prerequisites for building FLTK with CMake are staightforward:
CMake 3.2.3 or later and a recent FLTK 1.3 release, snapshot, or Git CMake 3.15 or later and a recent FLTK release, snapshot, or Git download
download (working copy). Installation of CMake is covered on its web site. (working copy). Installation of CMake is covered on its web site.
This howto will cover building FLTK with the default options using CMake This howto will cover building FLTK with the default options using CMake
under Linux and MinGW with Unix Makefiles. Chapter 2.5 shows how to use under Linux and MinGW with Unix Makefiles. Chapter 2.5 shows how to use
@ -74,7 +87,8 @@ under Linux. Other platforms are just as easy to use.
2.2 Options 2.2 Options
-------------- --------------
Options can be specified to cmake with the -D flag:
Options can be specified to CMake with the -D flag:
cmake -D <OPTION_NAME>=<OPTION_VALUE> cmake -D <OPTION_NAME>=<OPTION_VALUE>
@ -82,8 +96,20 @@ Example:
cmake -D CMAKE_BUILD_TYPE=Debug cmake -D CMAKE_BUILD_TYPE=Debug
All options have sensible defaults so you won't usually need to touch these. Notes: the space between '-D' and the option name can be omitted.
There are only two CMake options that you may want to specify: Option values must be quoted if they contain spaces.
Other CMake tools are `ccmake` and `cmake-gui` but these are not
described here.
All options have sensible defaults so you won't usually need to specify
them explicitly.
2.2.1 General CMake Options
------------------------------
There are only three CMake options that you may want to specify:
CMAKE_BUILD_TYPE CMAKE_BUILD_TYPE
This specifies what kind of build this is i.e. Release, Debug... This specifies what kind of build this is i.e. Release, Debug...
@ -100,111 +126,21 @@ CMAKE_OSX_ARCHITECTURES (macOS only, ignored on other platforms)
will either build Intel (x86_64) or Apple Silicon aka M1 (arm64) apps. will either build Intel (x86_64) or Apple Silicon aka M1 (arm64) apps.
The default is to build for the host processor architecture. The default is to build for the host processor architecture.
The following are the FLTK specific options. Platform specific options Note: the CMake variable BUILD_SHARED_LIBS is ignored by FLTK. FLTK builds
are ignored on other platforms. static libs by default and can optionally build shared libs as well.
Please see FLTK_BUILD_SHARED_LIBS instead.
OPTION_OPTIM - default EMPTY
Extra optimization flags for the C and C++ compilers, for instance
"-Wall -Wno-deprecated-declarations".
OPTION_ARCHFLAGS - default EMPTY 2.2.2 FLTK Specific Build Options
Extra architecture flags. ------------------------------------
OPTION_APPLE_X11 - default OFF Following are the FLTK specific options. Platform specific options are
In case you want to use X11 on macOS. ignored on other platforms. For convenience the list of options is ordered
Use this only if you know what you do, and if you have installed X11. alphabetically except "Documentation Options" and "Special Options" that
follow in their own sections below.
OPTION_USE_POLL - default OFF
Don't use this one, it is deprecated.
OPTION_BUILD_SHARED_LIBS - default OFF FLTK_ABI_VERSION - default EMPTY
Normally FLTK is built as static libraries which makes more portable
binaries. If you want to use shared libraries, this will build them too.
FLTK_BUILD_FLUID - default ON
Builds the Fast Light User-Interface Designer ("FLUID").
FLTK_BUILD_FLTK_OPTIONS - default ON
Builds the FLTK options editor ("fltk-options").
FLTK_BUILD_TEST - default ON
Builds the test and demo programs in the 'test' directory.
FLTK_BUILD_EXAMPLES - default OFF
Builds the example programs in the 'examples' directory.
FLTK_MSVC_RUNTIME_DLL - default ON (only for Visual Studio and NMake).
Selects whether the build uses the MS runtime DLL or not.
Default is ON: either /MD or /MDd for Release or Debug, respectively.
Select OFF for either /MT or /MTd for Release or Debug, respectively.
OPTION_CAIRO - default OFF
Enables support of class Fl_Cairo_Window (all platforms, requires the
Cairo library) - see README.Cairo.txt.
OPTION_CAIROEXT - default OFF
Enables extended libcairo support - see README.Cairo.txt.
OPTION_USE_GL - default ON
Enables OpenGL support.
OPTION_USE_THREADS - default ON
Enables multithreaded support.
OPTION_LARGE_FILE - default ON
Enables large file (>2G) support.
OPTION_USE_SYSTEM_LIBJPEG - default ON (macOS: OFF)
OPTION_USE_SYSTEM_LIBPNG - default ON (macOS: OFF)
OPTION_USE_SYSTEM_ZLIB - default ON
FLTK has built in jpeg, zlib, and png libraries. These options let you
use system libraries instead, unless CMake can't find them. If you set
any of these options to OFF, then the built in library will be used.
OPTION_USE_SVG - default ON
FLTK has a built-in SVG library and can create (write) SVG image files.
Turning this option off disables SVG (read and write) support.
OPTION_USE_XINERAMA - default ON
OPTION_USE_XFT - default ON
OPTION_USE_XCURSOR - default ON
OPTION_USE_XRENDER - default ON
These are X11 extended libraries. These libs are used if found on the
build system unless the respective option is turned off.
OPTION_USE_CAIRO - default OFF
Makes all drawing operations use the Cairo library (rather than Xlib)
producing antialiased graphics (X11 platform, implies OPTION_USE_PANGO).
OPTION_USE_PANGO - default OFF (see note below)
Enables use of the Pango library for drawing text. Pango supports all
unicode-defined scripts and gives FLTK limited support of right-to-left
scripts. This option makes sense only under X11 or Wayland, and also
requires Xft.
Note: Turned ON if Wayland or OPTION_USE_CAIRO is enabled.
OPTION_USE_KDIALOG - default ON
Under the KDE desktop, allows class Fl_Native_File_Chooser to use the
kdialog utility program to construct its file dialog windows, when that
utility is available at run time on the system. This option makes sense
only under X11 or Wayland.
OPTION_USE_WAYLAND - default ON
Enables the use of Wayland for all window operations, of Cairo for all
graphics and of Pango for text drawing (Linux+FreeBSD only). Resulting FLTK
apps use Wayland when a Wayland compositor is available at run-time,
and use X11 for their window operations otherwise, but keep using
Cairo and Pango - see README.Wayland.txt.
OPTION_WAYLAND_ONLY - default OFF
In conjunction with OPTION_USE_WAYLAND, restricts FLTK to support the
Wayland backend only.
OPTION_ALLOW_GTK_PLUGIN - default ON
Allow to use libdecor's GTK plugin to draw window titlebars (Wayland only).
Otherwise, FLTK will not use GTK and apps will not need linking to GTK.
OPTION_ABI_VERSION - default EMPTY
Use a numeric value corresponding to the FLTK ABI version you want to Use a numeric value corresponding to the FLTK ABI version you want to
build in the form 1xxyy for FLTK 1.x.y (xx and yy with leading zeroes). build in the form 1xxyy for FLTK 1.x.y (xx and yy with leading zeroes).
The default ABI version is 1xx00 (the stable ABI throughout all patch The default ABI version is 1xx00 (the stable ABI throughout all patch
@ -213,55 +149,203 @@ OPTION_ABI_VERSION - default EMPTY
Please see README.abi-version.txt for more information about which Please see README.abi-version.txt for more information about which
ABI version to select. ABI version to select.
OPTION_PRINT_SUPPORT - default ON FLTK_ARCHFLAGS - default EMPTY
Extra "architecture" flags used as C and C++ compiler flags.
These flags are also "exported" to fltk-config.
FLTK_BACKEND_WAYLAND - default ON (only Unix/Linux)
Enable the Wayland backend for all window operations, Cairo for all
graphics and Pango for text drawing (Linux+FreeBSD only). Resulting FLTK
apps use Wayland when a Wayland compositor is available at runtime,
and use X11 for their window operations otherwise (unless FLTK_BACKEND_X11
is OFF), but keep using Cairo and Pango - see README.Wayland.txt.
If FLTK_BACKEND_X11 has been turned OFF and there is no Wayland compositor
at runtime, then FLTK programs fail to start.
FLTK_BACKEND_X11 - default ON on Unix/Linux, OFF elsewhere (Windows, macOS).
Enable or disable the X11 backend on platforms that support it.
- Unix/Linux: enable or disable the X11 backend when building with
Wayland (FLTK_BACKEND_WAYLAND), otherwise this option must be ON.
- macOS: enable the X11 backend instead of standard system graphics.
This requires XQuartz or a similar X11 installation. This option is
tested only with XQuartz by the FLTK team.
Use this only if you know what you do and if you have installed X11.
- Windows/Cygwin: enable X11 backend for Cygwin platforms. This option
is currently (as of FLTK 1.4.0) not supported on Windows.
Note: On platforms that support Wayland you may set FLTK_BACKEND_WAYLAND=ON
(this is the default) and FLTK_BACKEND_X11=OFF to build a Wayland-only
library or vice versa for an X11-only library.
FLTK_BUILD_EXAMPLES - default OFF
Build the example programs in the 'examples' directory.
FLTK_BUILD_FLTK_OPTIONS - default ON
Build the FLTK options editor ("fltk-options").
FLTK_BUILD_FLUID - default ON
Build the Fast Light User-Interface Designer ("fluid").
FLTK_BUILD_FORMS - default ON
Build the (X)Forms compatibility library. This option is ON by default
for backwards compatibility but can safely be turned OFF if you don't
need (X)Forms compatibility.
FLTK_BUILD_GL - default ON
Build the OpenGL support library fltk_gl (fltk::gl) and enable OpenGL
support in user programs using fltk_gl.
FLTK_BUILD_SHARED_LIBS - default OFF
Normally FLTK is built as static libraries which makes more portable
binaries. If you want to use shared libraries, this will build them too.
You can use shared FLTK libs in your own CMake projects by appending
"-shared" to FLTK target names as described in section 3.1 and 3.2.
FLTK_BUILD_TEST - default ON in top-level build, OFF in sub-build
Build the test and demo programs in the 'test' directory. The default
is ON if the FLTK build is in a top-level project so all test and demo
programs are built. If FLTK is built as a subproject only the Library
and the tools (fluid and fltk-config) are built by default.
FLTK_GRAPHICS_CAIRO - default OFF (Unix/Linux: X11 + Wayland only).
Make all drawing operations use the Cairo library (rather than Xlib),
producing antialiased graphics (X11 platform: implies FLTK_USE_PANGO).
When using Wayland this option is ignored (Wayland uses Cairo).
FLTK_GRAPHICS_GDIPLUS - default ON (Windows only).
Make FLTK use GDI+ to draw oblique lines and curves resulting in
antialiased graphics. If this option is OFF standard GDI is used.
FLTK_MSVC_RUNTIME_DLL - default ON (Windows only: Visual Studio and NMake).
Select whether the build uses the MS runtime DLL (ON) or not (OFF).
Default is ON: either /MD or /MDd for Release or Debug, respectively.
Select OFF for either /MT or /MTd for Release or Debug, respectively.
FLTK_OPTION_CAIRO_EXT - default OFF
Enable extended libcairo support - see README.Cairo.txt.
FLTK_OPTION_CAIRO_WINDOW - default OFF
Enable support of class Fl_Cairo_Window (all platforms, requires the
Cairo library) - see README.Cairo.txt.
FLTK_OPTION_FILESYSTEM_SUPPORT - default ON
FLTK_OPTION_LARGE_FILE - default ON
Enables large file (>2G) support.
FLTK_OPTION_OPTIM - default EMPTY
Extra optimization flags for the C and C++ compilers, for instance
"-Wall -Wno-deprecated-declarations".
FLTK_OPTION_PRINT_SUPPORT - default ON
When turned off, the Fl_Printer class does nothing and the When turned off, the Fl_Printer class does nothing and the
Fl_PostScript_File_Device class cannot be used, but the FLTK library Fl_PostScript_File_Device class cannot be used, but the FLTK library
is somewhat smaller. This option makes sense only on the Unix/Linux is somewhat smaller. This option makes sense only on the Unix/Linux
platform or when OPTION_APPLE_X11 is ON. platform or on macOS when FLTK_BACKEND_X11 is ON.
OPTION_USE_GDIPLUS - default ON FLTK_OPTION_STD - default OFF
Makes FLTK use GDI+ to draw oblique lines and curves resulting in
antialiased graphics (Windows platform only).
OPTION_USE_STD - default OFF
This option allows FLTK to use some specific features of modern C++ This option allows FLTK to use some specific features of modern C++
like std::string in the public API of FLTK 1.4.x. Users turning this like std::string in the public API of FLTK 1.4.x. Users turning this
option ON can benefit from some new functions and methods that return option ON can benefit from some new functions and methods that return
std::string or use std::string as input parameters. std::string or use std::string as input parameters.
Note: this option will probably be removed in the next minor (1.5.0) Note: This option will be removed in the next minor (1.5.0) or major
or major (maybe 4.0.0) release which will default to use std::string release which will use std::string and other modern C++ features.
and more modern C++ features.
OPTION_USE_SYSTEM_LIBDECOR - default ON FLTK_OPTION_SVG - default ON
FLTK has a built-in SVG library and can create (write) SVG image files.
Turning this option off disables SVG (read and write) support.
FLTK_USE_KDIALOG - default ON
Under the KDE desktop, allows class Fl_Native_File_Chooser to use the
kdialog utility program to construct its file dialog windows, when that
utility is available at run time on the system. This option makes sense
only under X11 or Wayland.
FLTK_USE_LIBDECOR_GTK - default ON (Wayland only).
Allow to use libdecor's GTK plugin to draw window titlebars. Otherwise
FLTK does not use GTK and apps will not need linking to GTK. This feature
is always 'ON' if FLTK_USE_SYSTEM_LIBDECOR is 'ON'.
FLTK_USE_PANGO - default OFF (see note below)
Enables use of the Pango library for drawing text. Pango supports all
unicode-defined scripts and gives FLTK limited support of right-to-left
scripts. This option makes sense only under X11 or Wayland, and also
requires Xft.
This option is ignored (always enabled) if Wayland or FLTK_GRAPHICS_CAIRO
is ON.
FLTK_USE_POLL - default OFF
Deprecated: don't turn this option ON.
FLTK_USE_PTHREADS - default ON except on Windows.
Enables multithreaded support with pthreads if available.
This option is ignored (switched OFF internally) on Windows except
when using Cygwin.
FLTK_USE_SYSTEM_LIBDECOR - default ON (Wayland only)
This option makes FLTK use package libdecor-0-dev to draw window titlebars This option makes FLTK use package libdecor-0-dev to draw window titlebars
under Wayland. When OFF or when this package has a version < 0.2.0, FLTK under Wayland. When OFF or when this package has a version < 0.2.0, FLTK
uses its bundled copy of libdecor to draw window titlebars. uses its bundled copy of libdecor to draw window titlebars.
As of november 2023, version 0.2.0 of package libdecor-0-dev is available As of november 2023, version 0.2.0 of package libdecor-0-dev is available
only in testing distributions. only in testing distributions.
Documentation options: these options are only available if `doxygen' is FLTK_USE_SYSTEM_LIBJPEG - default ON (macOS and Windows: OFF)
installed and found by CMake. PDF related options require also `latex'. FLTK_USE_SYSTEM_LIBPNG - default ON (macOS and Windows: OFF)
FLTK_USE_SYSTEM_ZLIB - default ON (macOS and Windows: OFF)
FLTK has built in jpeg, zlib, and png libraries. These options let you
use system libraries instead, unless CMake can't find them. If you set
any of these options to OFF, then the built in library will be used.
The default is ON on Linux/Unix platforms but OFF on Windows and macOS
because of potential incompatibilities on Windows and macOS whereas
the system libraries can typically be used on Linux/Unix.
Note: if any one of libpng or zlib is not found on the system, both
libraries are built using the bundled ones and a warning is issued.
OPTION_BUILD_HTML_DOCUMENTATION - default ON FLTK_USE_XCURSOR - default ON
OPTION_BUILD_PDF_DOCUMENTATION - default ON FLTK_USE_XFIXES - default ON
These options can be used to switch HTML documentation generation with FLTK_USE_XFT - default ON
doxygen on. If these are ON the build targets 'html', 'pdf', and 'docs' FLTK_USE_XINERAMA - default ON
FLTK_USE_XRENDER - default ON
These are X11 extended libraries. These libs are used if found on the
build system unless the respective option is turned off.
2.2.3 Documentation Options
------------------------------
These options are only available if `doxygen' is installed and found.
PDF related options require also `latex'.
FLTK_BUILD_HTML_DOCS - default ON
FLTK_BUILD_PDF_DOCS - default ON
These options can be used to enable HTML documentation generation with
doxygen. If these are ON the build targets 'html', 'pdf', and 'docs'
are generated but must be built explicitly. Technically the build targets are generated but must be built explicitly. Technically the build targets
are generated but excluded from 'ALL'. You can safely leave these two are generated but excluded from 'ALL'.
options ON if you want to save build time because the docs are not You can safely leave these two options ON if you want to save build time
built automatically. because the docs are not built automatically.
OPTION_INCLUDE_DRIVER_DOCUMENTATION - default OFF FLTK_INCLUDE_DRIVER_DOCS - default OFF
This option adds driver documentation to HTML and PDF docs (if ON). This This option adds driver documentation to HTML and PDF docs (if ON). This
option is marked as "advanced" since it is only useful for FLTK developers option is marked as "advanced" since it is only useful for FLTK developers
and advanced users. It is only used if at least one of the documentation and advanced users. It is only used if at least one of the documentation
options above is ON as well. options above is ON as well.
OPTION_INSTALL_HTML_DOCUMENTATION - default OFF FLTK_INSTALL_HTML_DOCS - default OFF
OPTION_INSTALL_PDF_DOCUMENTATION - default OFF FLTK_INSTALL_PDF_DOCS - default OFF
If these options are ON then the HTML and/or PDF docs are installed If these options are ON then the HTML and/or PDF docs are installed
when the 'install' target is executed, e.g. with `make install'. You when the 'install' target is executed, e.g. with `make install'. You
need to select above options OPTION_BUILD_*_DOCUMENTATION as well. need to select above options FLTK_BUILD_*_DOCS as well.
2.2.4 Special Options
------------------------
FLTK_INSTALL_LINKS - default OFF
Deprecated: install "compatibility" links to compensate for typos in
include statements (for case sensitive file systems only).
You should not use this option, please fix the sources instead for
better cross-platform compatibility.
2.3 Building under Linux with Unix Makefiles 2.3 Building under Linux with Unix Makefiles
@ -285,7 +369,7 @@ Some flags can be changed during the 'make' command, such as:
make VERBOSE=on make VERBOSE=on
..which builds in verbose mode, so you can see all the compile/link commands. which builds in verbose mode, so you can see all the compile/link commands.
Hint: if you intend to build several different versions of FLTK, e.g. a Debug Hint: if you intend to build several different versions of FLTK, e.g. a Debug
and a Release version, or multiple libraries with different ABI versions or and a Release version, or multiple libraries with different ABI versions or
@ -293,84 +377,102 @@ options, then use subdirectories in the build directory, like this:
mkdir build mkdir build
cd build cd build
mkdir Debug mkdir debug
cd Debug cd debug
cmake -D 'CMAKE_BUILD_TYPE=Debug' ../.. cmake -D 'CMAKE_BUILD_TYPE=Debug' ../..
make make
sudo make install (optional) sudo make install (optional)
2.4 Building under Windows with Visual Studio 2.4 Building under Windows with Visual Studio and/or NMake
------------------------------------------------ -------------------------------------------------------------
Building with CMake under Visual Studio requires the CMake generator with Building with CMake under Visual Studio may require to specify the CMake
the -G command line switch, or the generator can be selected interactively generator with the -G"Visual Studio ..." command line switch, or the
in the GUI (cmake-gui). generator can be selected interactively in the GUI (cmake-gui). If you
are not sure which one to select use `cmake --help` which lists all
generators known to CMake on your system.
2.4.1 Visual Studio 7 / .NET
------------------------------
1) Open a "Visual Studio .NET command prompt" window, e.g. 2.4.1 Building under Windows with Visual Studio
-------------------------------------------------
Start > All Programs > Microsoft Visual Studio .NET > CMake often finds an installed Visual Studio generator and uses it w/o
Visual Studio .NET Tools > Command Prompt using the commandline switch, particularly if you are using a special
"Visual Studio Command Prompt":
2) In the DOS window created above, change the current directory - Hit the "Windows" key
to where you've extracted an fltk distribution tar file (or
snapshot tar file), and run the following commands:
cd C:\fltk-1.4.x <-- change to your FLTK directory - Type "developer command ..."
mkdir build <-- create an empty directory ... until you see something like "Developer Command Prompt for VS xxxx"
(replace 'xxxx' with your installed Visual Studio version)
- Activate the "app" to execute the command prompt (like an old "DOS" shell)
- Inside this command prompt window, run your installed `cmake` (command
line) or `cmake-gui` (GUI) program. You may need to specify the full path
to this program.
If you use `cmake-gui` you can select the source and the build folders in
the GUI, otherwise change directory to where you downloaded and installed
the FLTK sources and execute:
`cmake` -G "Visual Studio xxx..." -B build
cd build cd build
cmake -G "Visual Studio 7" -D CMAKE_BUILD_TYPE=Release ..
IMPORTANT: The trailing ".." on the cmake command must be specified This creates the Visual Studio project files (FLTK.sln and more) in the
(it is NOT an ellipsis). ^^^^^^^^^^^^^^^^^ 'build' directory.
This will create the file FLTK.sln in the current 'build' directory. Open Visual Studio, choose File -> Open -> Project, and pick the "FLTK.sln"
created in the previous step.
3) Open Visual Studio 7, and choose File -> Open -> Project,
and pick the "FLTK.sln" created by step #2 in the 'build' directory.
(Or, if only one version of the Visual Studio compiler is installed, (Or, if only one version of the Visual Studio compiler is installed,
you can just run from DOS: .\FLTK.sln) you can just run from DOS: .\FLTK.sln)
4) Make sure the pulldown menu has either "Release" or "Debug" selected Make sure the pulldown menu has either "Release" or "Debug" selected
in the "Solution Configurations" pulldown menu. in the "Solution Configurations" pulldown menu.
5) In the "Solution Explorer", right click on: In the "Solution Explorer", right click on:
Solution 'FLTK' (## projects) Solution 'FLTK' (## projects)
..and in the popup menu, choose "Build Solution" ... and in the popup menu, choose "Build Solution"
5) That's it, that should build FLTK. or choose 'Build/Build Solution' or 'Build/Rebuild Solution' from the
menu at the top of the window.
The test programs (*.exe) can be found in e.g. That's it, that should build FLTK.
Release: C:\fltk-1.4.x\build\bin\examples\release\*.exe The test programs (*.exe) can be found relative to the 'build' folder in
Debug: C:\fltk-1.4.x\build\bin\examples\debug\*.exe
..and the FLTK include files (*.H & *.h) your own apps can build\bin\test\Release\*.exe
build\bin\test\Debug\*.exe
... and the FLTK include files (*.H & *.h) your own apps can
compile with can be found in: compile with can be found in:
Release & Debug: C:\fltk-1.4.x\build\FL build\FL
*and* [1] in: C:\fltk-1.4.x\FL
..and the FLTK library files (*.lib) which your own apps can *and* [1] in the source folder where you downloade FLTK, e.g. in
C:\fltk-1.4.x\FL
... and the FLTK library files (*.lib) which your own apps can
link with can be found in: link with can be found in:
Release: C:\fltk-1.4.x\build\lib\release\*.lib Release: build\lib\Release\*.lib
Debug: C:\fltk-1.4.x\build\lib\debug\*.lib Debug: build\lib\Debug\*.lib
[1] If you want to build your own FLTK application directly using [1] If you want to build your own FLTK application directly using
the build directories (i.e. without "installation") you need the build directories (i.e. without "installation") you need
to include both the build tree (first) and then the FLTK source to include both the build tree (first) and then the FLTK source
tree in the compiler's header search list. tree in the compiler's header search list.
2.4.2 Visual Studio 2019 / NMake
-------------------------------------- 2.4.2 Building under Windows with NMake
This uses cmake to generate + build FLTK in Release mode using nmake, -----------------------------------------
This example uses cmake to generate + build FLTK in Release mode using nmake,
using purely the command line (never need to open the Visual Studio IDE) using purely the command line (never need to open the Visual Studio IDE)
using Multithreaded (/MT): using Multithreaded (/MT):
@ -379,10 +481,13 @@ in the GUI (cmake-gui).
cmake -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=Release -D FLTK_MSVC_RUNTIME_DLL=off .. cmake -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=Release -D FLTK_MSVC_RUNTIME_DLL=off ..
nmake nmake
..which results in a colorful percentage output crawl similar to what which results in a colorful percentage output crawl similar to what we see
we see with unix 'make'. with unix 'make'.
-erco@seriss.com
Updated: Dec 8 2023 Instead of running `nmake` directly you can also use cmake to build:
cmake --build .
2.5 Building under Windows with MinGW using Makefiles 2.5 Building under Windows with MinGW using Makefiles
-------------------------------------------------------- --------------------------------------------------------
@ -437,13 +542,6 @@ of the cmake related files are updated, Xcode will rerun cmake for you.
5a) To build the Release version of FLTK, use 5a) To build the Release version of FLTK, use
> cmake -G Xcode -D CMAKE_BUILD_TYPE=Release ../.. > cmake -G Xcode -D CMAKE_BUILD_TYPE=Release ../..
5b) To create all included libraries instead of using those that come
with MacOS, use:
> cmake -G Xcode -D OPTION_USE_SYSTEM_LIBJPEG=Off \
-D OPTION_USE_SYSTEM_ZLIB=Off \
-D OPTION_USE_SYSTEM_LIBPNG=Off \
../..
6) Launch Xcode from the Finder or from the Terminal: 6) Launch Xcode from the Finder or from the Terminal:
> open ./FLTK.xcodeproj > open ./FLTK.xcodeproj
When Xcode starts, it asks if it should "Autocreate Schemes". Click on When Xcode starts, it asks if it should "Autocreate Schemes". Click on
@ -549,69 +647,148 @@ Unix/Linux, for instance like this:
-------------------- --------------------
When you use the target_link_libraries() command, CMake uses its own internal When you use the target_link_libraries() command, CMake uses its own internal
"target names" for libraries. The fltk library names are: "target names" for libraries. The original fltk library names in the build
tree are:
fltk fltk_forms fltk_images fltk_gl fltk fltk_forms fltk_images fltk_gl
and for the shared libraries (if built): The bundled image and zlib libraries (if built):
fltk_SHARED fltk_forms_SHARED fltk_images_SHARED fltk_gl_SHARED
The built-in libraries (if built):
fltk_jpeg fltk_png fltk_z fltk_jpeg fltk_png fltk_z
Append suffix "-shared" for shared libraries (Windows: DLL's).
3.2 Building a Simple "Hello World" Program with FLTK These library names are used to construct the filename on disk with system
specific prefixes and postfixes. For instance, on Linux/Unix 'fltk' is libfltk.a
and the shared library (fltk-shared) is libfltk.so.1.4.0 (in FLTK 1.4.0) with
additional system specific links.
Note: since FLTK 1.4.0 the library fltk_cairo is no longer necessary and
should be removed from CMake files of user projects. fltk_cairo is now an
empty library solely for backwards compatibility and will be removed in the
future.
3.2 Library Aliases
----------------------
Since FLTK 1.4.0 "aliases" for all libraries in the FLTK build tree are
created in the namespace "fltk::". These aliases should always be used by
consumer projects (projects that use FLTK) for several reasons which are
beyond the scope of this README file. The following table shows the FLTK
libraries and their aliases in the FLTK build tree.
Library Name Alias Shared Library Alias Notes
--------------------------------------------------------------
fltk fltk::fltk fltk::fltk-shared [1]
fltk_forms fltk::forms fltk::forms-shared [2]
fltk_gl fltk::gl fltk::gl-shared [2]
fltk_images fltk::images fltk::images-shared [2]
fltk_jpeg fltk::jpeg fltk::jpeg-shared [3]
fltk_png fltk::png fltk::png-shared [3]
fltk_z fltk::z fltk::z-shared [3]
[1] The basic FLTK library. Use this if you don't need any of the other
libraries for your application.
[2] Use one or more of these libraries if you have specific needs,
e.g. if you need to read images (fltk::images), OpenGL (fltk::gl),
or (X)Forms compatibility (fltk::forms). If you use one of these
libraries in your CMakeLists.txt then fltk::fltk will be included
automatically.
[3] The bundled libraries are only built if requested and are usually
not needed in user projects. They are linked in with fltk::images
automatically if they were built with FLTK.
The only reason you may need them would be if you used libpng,
libjpeg, or zlib functions directly in your application and need
to use the bundled FLTK libs (e.g. on Windows).
3.3 Exported and Imported Targets
------------------------------------
CMake terminology is to "export" and "import" library "targets". FLTK's
CMake files export targets and its CONFIG module FLTKConfig.cmake imports
targets so user projects can use them. Hence, if you use CMake's CONFIG
mode to find FLTK all library targets will be defined using the namespace
convention listed above in the "Alias" column. This is what user projects
are intended to use.
In addition to the library targets FLTK defines the "imported target"
'fltk::fluid' which can be used to generate source (.cxx) and header (.h)
files from fluid (.fl) files.
Another target fltk::fltk-config can be used to set (e.g.) system or user
specific FLTK options. This would usually be executed in the installation
process of a user project but should rarely be needed and is beyound the
scope of this documentation.
3.4 Building a Simple "Hello World" Program with FLTK
-------------------------------------------------------- --------------------------------------------------------
Here is a basic CMakeLists.txt file using FLTK. Here is a basic CMakeLists.txt file using FLTK. It is important that
this file can only be used as simple as it is if you use find_package()
in `CONFIG` mode as shown below. This requires that the FLTK library
itself has been built with CMake.
--- ---
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.15)
project(hello) project(hello)
# optional (see below):
set(FLTK_DIR "/path/to/fltk" set(FLTK_DIR "/path/to/fltk"
CACHE FILEPATH "FLTK installation or build directory") CACHE FILEPATH "FLTK installation or build directory")
find_package(FLTK REQUIRED CONFIG) find_package(FLTK CONFIG REQUIRED)
add_executable (hello WIN32 MACOSX_BUNDLE hello.cxx) add_executable (hello WIN32 MACOSX_BUNDLE hello.cxx)
if (APPLE) target_link_libraries(hello PRIVATE fltk::fltk)
target_link_libraries (hello PRIVATE "-framework cocoa")
endif (APPLE)
target_include_directories (hello PRIVATE ${FLTK_INCLUDE_DIRS})
target_link_libraries (hello PRIVATE fltk)
--- ---
The set(FLTK_DIR ...) command is a superhint to the find_package command. We recommend to use `cmake_minimum_required(VERSION 3.15)` or higher for
This is very useful if you don't install or have a non-standard install. building projects that use FLTK. Lower CMake versions may work for user
projects but this is not tested by FLTK developers.
The optional `set(FLTK_DIR ...)` command is a superhint to the find_package
command. This is very useful if you don't install or have a non-standard
install location. The path you give to it must be that of a directory that
contains the file FLTKConfig.cmake.
You can omit this statement if CMake finds the required FLTK version
without it. This variable is stored in the CMake Cache so users can change
it with the ususal CMake GUI interfaces (ccmake, cmake-gui) or on the
CMake commandline (-D FLTK_DIR=...).
The find_package command tells CMake to find the package FLTK, REQUIRED The find_package command tells CMake to find the package FLTK, REQUIRED
means that it is an error if it's not found. CONFIG tells it to search means that it is an error if it's not found. CONFIG tells it to search
only for the FLTKConfig file, not using the FindFLTK.cmake supplied with only for the FLTKConfig.cmake file, not using the FindFLTK.cmake "module"
CMake, which doesn't work with this version of FLTK. supplied with CMake, which doesn't work with this version of FLTK.
The "WIN32 MACOSX_BUNDLE" in the add_executable tells this is a GUI app. "WIN32 MACOSX_BUNDLE" in the add_executable() command tells CMake that
It is ignored on other platforms and should always be present with FLTK this is a GUI app. It is ignored on other platforms than Windows or macOS,
GUI programs for better portability - unless you explicitly need to build respectively, and should always be present with FLTK GUI programs for
a "console program", e.g. on Windows. better portability - unless you explicitly need to build a "console program"
on Windows.
Once the package is found the CMake variable FLTK_INCLUDE_DIRS is defined Once the package is found (in CONFIG mode, as described above) all built
which can be used to add the FLTK include directories to the definitions FLTK libraries are "imported" as CMake "targets" or aliases and can be used
used to compile your program using the `target_include_directories()` command. directly. These CMake library targets contain all necessary informations to
be used without having to know about additional include directories or
other library dependencies. This is what is called "Modern CMake".
Older FLTK versions required to use the variables FLTK_INCLUDE_DIRS and
FLTK_LIBRARIES (among others). These variables and related commands are
no longer necessary if your project (CMakeLists.txt) uses CMake's
CONFIG mode as described in this file.
The target_link_libraries() command is used to specify all necessary FLTK The target_link_libraries() command is used to specify all necessary FLTK
libraries. Thus, you may have to add fltk_images, fltk_gl, etc… libraries. Thus you may use fltk::fltk, fltk::images, fltk::gl, fltk::forms,
or any combination. fltk::fltk is linked automatically if any of the other
Note: the variable FLTK_USE_FILE used to include another file in libs is included.
previous FLTK versions was deprecated since FLTK 1.3.4 and has been
removed in FLTK 1.4.0.
3.3 Building a Program Using Fluid Files 3.5 Building a Program Using Fluid Files
------------------------------------------- -------------------------------------------
CMake has a command named fltk_wrap_ui which helps deal with fluid *.fl CMake has a command named fltk_wrap_ui which helps deal with fluid *.fl
@ -619,6 +796,7 @@ files. Unfortunately it is broken in CMake 3.4.x but it seems to work in
3.5 and later CMake versions. We recommend to use add_custom_command() 3.5 and later CMake versions. We recommend to use add_custom_command()
to achieve the same result in a more explicit and well-defined way. to achieve the same result in a more explicit and well-defined way.
This is a more basic approach and should work for all CMake versions. This is a more basic approach and should work for all CMake versions.
It is described below.
Here is a sample CMakeLists.txt which compiles the CubeView example from Here is a sample CMakeLists.txt which compiles the CubeView example from
a directory you've copied the test/Cube* files to. a directory you've copied the test/Cube* files to.
@ -632,28 +810,26 @@ project(CubeView)
set(FLTK_DIR "/path/to/fltk" set(FLTK_DIR "/path/to/fltk"
CACHE FILEPATH "FLTK installation or build directory") CACHE FILEPATH "FLTK installation or build directory")
find_package(FLTK REQUIRED CONFIG) find_package(FLTK CONFIG REQUIRED)
# run fluid -c to generate CubeViewUI.cxx and CubeViewUI.h files # run fluid -c to generate CubeViewUI.cxx and CubeViewUI.h files
add_custom_command( add_custom_command(
OUTPUT "CubeViewUI.cxx" "CubeViewUI.h" OUTPUT "CubeViewUI.cxx" "CubeViewUI.h"
COMMAND fluid -c ${CMAKE_CURRENT_SOURCE_DIR}/CubeViewUI.fl COMMAND fltk::fluid -c ${CMAKE_CURRENT_SOURCE_DIR}/CubeViewUI.fl
) )
add_executable(CubeView WIN32 MACOSX_BUNDLE add_executable(CubeView WIN32 MACOSX_BUNDLE
CubeMain.cxx CubeView.cxx CubeViewUI.cxx) CubeMain.cxx CubeView.cxx CubeViewUI.cxx)
target_include_directories (CubeView PRIVATE ${FLTK_INCLUDE_DIRS})
target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries (CubeView PRIVATE fltk fltk_gl) target_link_libraries (CubeView PRIVATE fltk::gl)
--- ---
You can repeat the add_custom_command for each fluid file or if you You can repeat the add_custom_command for each fluid file or if you
have a large number of them see the CMake/FLTK-Functions.cmake function have a large number of them see the fltk_run_fluid() function in
FLTK_RUN_FLUID for an example of how to run it in a loop. CMake/FLTK-Functions.cmake for an example of how to run it in a loop.
The two lines The two lines
@ -663,10 +839,11 @@ The two lines
add the current build ("binary") and source directories as include directories. add the current build ("binary") and source directories as include directories.
This is necessary for the compiler to find the local header files since the This is necessary for the compiler to find the local header files since the
fluid-generated files (CubeViewUI.cxx and CubeViewUI.h) are created in the fluid-generated files (CubeViewUI.cxx and CubeViewUI.h) are created in the
current build directory. current build directory and other header files may be in the source directory
(depending on your project).
3.4 Building a Program Using CMake's FetchContent Module 3.6 Building a Program Using CMake's FetchContent Module
----------------------------------------------------------- -----------------------------------------------------------
FLTK can be downloaded and built within a user project using CMake's FLTK can be downloaded and built within a user project using CMake's
@ -680,41 +857,38 @@ project(hello)
include(FetchContent) include(FetchContent)
set(FLTK_BUILD_TEST OFF CACHE BOOL "" FORCE)
FetchContent_Declare(FLTK FetchContent_Declare(FLTK
GIT_REPOSITORY https://github.com/fltk/fltk GIT_REPOSITORY https://github.com/fltk/fltk
GIT_TAG master
GIT_SHALLOW TRUE GIT_SHALLOW TRUE
) )
message(STATUS "Download and build FLTK if necessary, please wait...")
FetchContent_MakeAvailable(FLTK) FetchContent_MakeAvailable(FLTK)
message(STATUS "Download and build FLTK - done.")
add_executable (hello WIN32 MACOSX_BUNDLE hello.cxx) add_executable (hello WIN32 MACOSX_BUNDLE hello.cxx)
target_link_libraries(hello PRIVATE fltk::fltk)
target_include_directories(hello PRIVATE ${fltk_BINARY_DIR} ${fltk_SOURCE_DIR})
# link as required: fltk fltk_gl fltk_images fltk_png fltk_jpeg fltk_z
target_link_libraries(hello PRIVATE fltk)
if(APPLE)
target_link_libraries(hello PRIVATE "-framework Cocoa") # needed for Darwin
endif()
if(WIN32)
target_link_libraries(hello PRIVATE gdiplus)
endif()
--- ---
This is as simple as it can be. The CMake FetchContent module is used to
download the FLTK sources from their Git repository and to build them.
Note that this will download and build the FLTK library during the CMake
configure phase which can take some time. Therefore the statement
`FetchContent_MakeAvailable()` is wrapped in `message(STATUS "...")`
commands to let the user know what's going on.
4 Document History
---------------------
Dec 20 2010 - matt: merged and restructured 4 FindFLTK.cmake and find_package(FLTK)
May 15 2013 - erco: small formatting tweaks, added some examples ==========================================
Feb 23 2014 - msurette: updated to reflect changes to the CMake files
Apr 07 2015 - AlbrechtS: update use example and more docs The FindFLTK.cmake module provided by CMake which is also used in the
Jan 31 2016 - msurette: custom command instead of fltk_wrap_ui CMake command find_package(FLTK) does not yet support FLTK's new "Modern
Nov 01 2016 - AlbrechtS: add MinGW build CMake" features.
Jul 05 2017 - matt: added instructions for macOS and Xcode
Dec 29 2018 - AlbrechtS: add documentation option descriptions Unfortunately this module has to be used if the FLTK library wasn't built
Apr 29 2021 - AlbrechtS: document macOS "universal apps" build setup with CMake and thus CONFIG mode can't be used. In this case CMake falls back
Nov 01 2023 - AlbrechtS: improve build instructions for user programs to MODULE mode and find_package() uses this old CMake module.
There are plans to provide a FindFLTK.cmake module with FLTK 1.4.0 but this
module is not yet written. Look here for further info if you need it...

View File

@ -1,4 +1,4 @@
README.Cairo.txt - Cairo rendering support for FLTK README.Cairo.txt - Cairo Window Support for FLTK
---------------------------------------------------- ----------------------------------------------------
@ -8,9 +8,7 @@ README.Cairo.txt - Cairo rendering support for FLTK
1 INTRODUCTION 1 INTRODUCTION
2 CAIRO SUPPORT FOR FLTK 2 CAIRO SUPPORT FOR FLTK
2.1 Configuration 2.1 Supported Features (Fl_Cairo_Window)
2.2 Currently supported features
2.3 Future considerations
3 PLATFORM SPECIFIC NOTES 3 PLATFORM SPECIFIC NOTES
3.1 Linux 3.1 Linux
@ -22,11 +20,9 @@ README.Cairo.txt - Cairo rendering support for FLTK
3.3.2 Install Homebrew for Cairo and other Library Support 3.3.2 Install Homebrew for Cairo and other Library Support
3.3.3 Install CMake and Build with CMake 3.3.3 Install CMake and Build with CMake
4 DOCUMENT HISTORY
1 INTRODUCTION
INTRODUCTION ================
==============
Cairo is a software library used to provide a vector graphics-based, Cairo is a software library used to provide a vector graphics-based,
device-independent API for software developers. It is designed to provide device-independent API for software developers. It is designed to provide
@ -34,25 +30,45 @@ primitives for 2-dimensional drawing across a number of different
backends. Cairo is designed to use hardware acceleration when available. backends. Cairo is designed to use hardware acceleration when available.
CAIRO SUPPORT FOR FLTK 2 CAIRO SUPPORT FOR FLTK
======================== ==========================
It is now possible to integrate Cairo rendering in your FLTK application Since FLTK 1.3 we provide minimum support for Cairo. User programs can
more easily and transparently. use the class Fl_Cairo_Window which sets up a Cairo context so the user
Since FLTK 1.3 we provide minimum support for Cairo; no "total" Cairo progam can call Cairo drawing calls in their own drawing callback.
rendering layer support is achieved.
CMake option name: FLTK_OPTION_CAIRO_WINDOW
Configure option : --enable-cairo
Since FLTK 1.3 the library can also be configured to provide a Cairo context
in all subclasses of Fl_Window. This is called "extended" Cairo support.
CMake option name: FLTK_OPTION_CAIRO_EXT
Configure option : --enable-cairoext
These two options provide users with an interface to use Cairo to draw
into FLTK windows. FLTK does not use Cairo for rendering its own graphics
with these two options. Both options must be enabled explicitly.
Configuration Since FLTK 1.4 the new Wayland platform uses Cairo for all drawings.
--------------- Under X11 drawing with Cairo rather than Xlib is a build option.
The old "Fl_Cairo_Window support" is still available on all platforms.
All the changes are *inactive* as long as the new configuration CMake option name: FLTK_GRAPHICS_CAIRO
option --enable-cairo is not added to the configure command or the CMake Configure option : --enable-usecairo
variable OPTION_CAIRO:BOOL=ON is set.
Full Cairo drawing is provided on Unix/Linux platforms. It is always used if
Wayland (FLTK_BACKEND_WAYLAND) is enabled during the build. It is optional
(default: OFF) if Wayland is disabled (FLTK_BACKEND_WAYLAND=OFF).
Fl_Cairo_Window support is *inactive* as long as it is not explicitly enabled
with one of the first two options mentioned above, even if FLTK uses Cairo
drawing by itself (FLTK_GRAPHICS_CAIRO).
Currently supported features 2.1 Supported Features (Fl_Cairo_Window)
------------------------------ ------------------------------------------
(1) Adding a new Fl_Cairo_Window class permitting transparent and easy (1) Adding a new Fl_Cairo_Window class permitting transparent and easy
integration of a Cairo draw callback without the need to subclass Fl_Window. integration of a Cairo draw callback without the need to subclass Fl_Window.
@ -82,17 +98,16 @@ variable OPTION_CAIRO:BOOL=ON is set.
in any FLTK window. in any FLTK window.
This feature must be enabled with 'configure --enable-cairoext' or the This feature must be enabled with 'configure --enable-cairoext' or the
CMake variable OPTION_CAIROEXT:BOOL=ON (Default: OFF). CMake option FLTK_OPTION_CAIRO_EXT:BOOL=ON (Default: OFF).
(4) A new Cairo demo that is available in the test subdirectory and has (4) A new Cairo demo that is available in the test subdirectory.
been used as a testcase during the multiplatform tests.
For more details, please have a look to the doxygen documentation, For more details, please have a look to the doxygen documentation,
in the Modules section. in the Modules section.
PLATFORM SPECIFIC NOTES 3 PLATFORM SPECIFIC NOTES
========================= ===========================
The following are notes about building FLTK with Cairo support The following are notes about building FLTK with Cairo support
on the various supported operating systems. on the various supported operating systems.
@ -107,7 +122,7 @@ on the various supported operating systems.
sudo apt install libcairo2-dev sudo apt install libcairo2-dev
Then build fltk using the Cairo support option using: Then build fltk using the Cairo support option using:
cmake -G"Unix Makefiles" -DOPTION_CAIRO:BOOL=ON -S <fltk_dir> -B <your_build_dir> cmake -G "Unix Makefiles" -D FLTK_OPTION_CAIRO_WINDOW:BOOL=ON -S <fltk_dir> -B <your_build_dir>
cd <your_build_dir> cd <your_build_dir>
make make
@ -156,9 +171,7 @@ on the various supported operating systems.
Note 1: CMake builds *require* the use of pkg-config. Note 1: CMake builds *require* the use of pkg-config.
Note 2: As of Feb 2021 autoconf/configure/make builds require pkg-config Note 2: As of Feb 2021 autoconf/configure/make builds require pkg-config
as well but there are plans to implement a fallback mechanism so you can as well.
build FLTK w/o having to install and use pkg-config. This will be done if
possible (but not guaranteed).
3.2 Windows 3.2 Windows
@ -241,17 +254,7 @@ on the various supported operating systems.
e.g. 'build' or another folder anywhere else) and click "configure". e.g. 'build' or another folder anywhere else) and click "configure".
Follow the instructions and select either "native compilers" or Xcode or Follow the instructions and select either "native compilers" or Xcode or
whatever you like to build your FLTK library. In the CMake GUI you need whatever you like to build your FLTK library. In the CMake GUI you need
to select OPTION_CAIRO (ON) to build with basic Cairo support. Finally to select FLTK_OPTION_CAIRO_WINDOW (ON) to build with basic Cairo support.
click "generate" to create the build files. Finally click "generate" to create the build files.
For more information on using CMake to build FLTK see README.CMake.txt. For more information on using CMake to build FLTK see README.CMake.txt.
DOCUMENT HISTORY
==================
Dec 20 2010 - matt: restructured document
Dec 09 2011 - greg: Updates for Centos 5.5 builds
Dec 10 2011 - Albrecht: Updates for Ubuntu and Debian, fixed typos.
Jul 05 2017 - Albrecht: Added CMake config info, fixed typos.
Feb 28 2021 - Albrecht: Update for FLTK 1.4, add macOS instructions.

View File

@ -116,10 +116,10 @@ On Linux and FreeBSD systems equipped with the adequate software packages
hybrid library. On systems lacking all or part of Wayland-required packages, hybrid library. On systems lacking all or part of Wayland-required packages,
the default building procedure produces a X11-based library. the default building procedure produces a X11-based library.
Use -DOPTION_USE_WAYLAND=OFF with CMake or "configure --disable-wayland" to build Use "-D FLTK_OPTION_USE_WAYLAND=OFF" with CMake or "configure --disable-wayland"
FLTK for the X11 library when the default would build for Wayland. to build FLTK for the X11 library when the default would build for Wayland.
CMake OPTION_WAYLAND_ONLY or "--disable-x11" configure argument can CMake option FLTK_BACKEND_X11=OFF or configure argument "--disable-x11" can
be used to produce a Wayland-only library which can be useful, e.g., when be used to produce a Wayland-only library which can be useful, e.g., when
cross-compiling for systems that lack X11 headers and libraries. cross-compiling for systems that lack X11 headers and libraries.

View File

@ -72,13 +72,13 @@ the version number.
ABI version, use ccmake, cmake-gui, or run cmake with the following ABI version, use ccmake, cmake-gui, or run cmake with the following
command: command:
cmake -D OPTION_ABI_VERSION:STRING=10401 /path/to/fltk cmake -D FLTK_ABI_VERSION:STRING=10401 /path/to/fltk
Then execute Then execute
make make
You can define OPTION_ABI_VERSION to the required version number using You can define FLTK_ABI_VERSION to the required version number using
one of the graphical CMake tools. one of the graphical CMake tools.
For more information on how to use CMake with FLTK see README.CMake.txt. For more information on how to use CMake with FLTK see README.CMake.txt.
@ -100,8 +100,8 @@ the version number.
... *FIXME* [Add documentation how to use CMake with FLTK]. ... *FIXME* [Add documentation how to use CMake with FLTK].
Use CMake option OPTION_ABI_VERSION:STRING=10401 with the command line Use CMake option FLTK_ABI_VERSION:STRING=10401 with the command line
or set OPTION_ABI_VERSION with one of the CMake GUI programs. or set FLTK_ABI_VERSION with one of the CMake GUI programs.
Then start the build process in the IDE solution of your choice. This Then start the build process in the IDE solution of your choice. This
will run the build with the defined ABI version. will run the build with the defined ABI version.

View File

@ -134,9 +134,9 @@ and
Back in the _CMake_ main window, click _Configure_, select _Xcode_ as the generator and Back in the _CMake_ main window, click _Configure_, select _Xcode_ as the generator and
click _Done_. _CMake_ will now analyse your system and find tools and dependencies. When click _Done_. _CMake_ will now analyse your system and find tools and dependencies. When
done, the upper list field in _CMake_ will show CMAKE, FLTK, and OPTION. Open the OPTION done, the upper list field in _CMake_ will show CMAKE and FLTK. Open the FLTK field and
field and find the entries OPTION_USE_SYSTEM_LIBJPEG and OPTION_USE_SYSTEM_LIBPNG, adjust options if you like. Note that the bundled image libraries are built by default.
and disable both for maximum compatibility with other macOS installation. Further options are available under the CMAKE field.
Finally, click _Generate_ to generate the _Xcode_ IDE file. Finally, click _Generate_ to generate the _Xcode_ IDE file.
@ -246,12 +246,12 @@ Now configure your FLTK installation:
```bash ```bash
cmake -G "Unix Makefiles" \ cmake -G "Unix Makefiles" \
-D OPTION_USE_SYSTEM_LIBJPEG=Off \ -D CMAKE_BUILD_TYPE=Debug \
-D OPTION_USE_SYSTEM_ZLIB=Off \
-D OPTION_USE_SYSTEM_LIBPNG=Off \
../.. ../..
``` ```
Replace 'Debug' with 'Release' if you want to build a release version.
_CMake_ runs a number of tests to find external headers, libraries, and tools. _CMake_ runs a number of tests to find external headers, libraries, and tools.
The configuration summary should not show any errors. You can now continue to build FLTK. The configuration summary should not show any errors. You can now continue to build FLTK.
@ -382,7 +382,8 @@ You will need to clone the repository to check out the source code onto your mac
has the great benefit that the source code can be updated later simply by telling _git_ to has the great benefit that the source code can be updated later simply by telling _git_ to
_pull_ the newest release. _pull_ the newest release.
Weekly snapshots ("tarballs") can be downloaded from https://www.fltk.org/software.php . As an alternative weekly snapshots ("tarballs") can be downloaded from
https://www.fltk.org/software.php .
Start your terminal. If you have not set up a developer directory yet, I recommend to use Start your terminal. If you have not set up a developer directory yet, I recommend to use
`~/dev` and put all your projects there: `~/dev` and put all your projects there:
@ -534,4 +535,3 @@ to the Info.plist file you have prepared.
- Dec 28 2018 - Matt: complete rework for FLTK 1.4 - Dec 28 2018 - Matt: complete rework for FLTK 1.4
- Mar 01 2021 - Albrecht: minor updates, macOS Big Sur and Apple Silicon M1 (ARM) - Mar 01 2021 - Albrecht: minor updates, macOS Big Sur and Apple Silicon M1 (ARM)
- Feb 23 2022 - Manolo: install autoconf without brew - Feb 23 2022 - Manolo: install autoconf without brew

View File

@ -27,13 +27,17 @@
set(cairo_SRCS cairo_dummy.c) set(cairo_SRCS cairo_dummy.c)
FL_ADD_LIBRARY (fltk_cairo STATIC "${cairo_SRCS}") fl_add_library(fltk_cairo STATIC "${cairo_SRCS}")
target_link_libraries(fltk_cairo PUBLIC fltk::fltk)
# Build shared dummy library(optional) # Build shared dummy library(optional)
if (OPTION_BUILD_SHARED_LIBS) if(FLTK_BUILD_SHARED_LIBS)
FL_ADD_LIBRARY (fltk_cairo SHARED "${cairo_SRCS}") fl_add_library(fltk_cairo SHARED "${cairo_SRCS}")
target_link_libraries (fltk_cairo_SHARED fltk_SHARED) target_link_libraries(fltk_cairo-shared PUBLIC fltk::fltk-shared)
endif (OPTION_BUILD_SHARED_LIBS) endif(FLTK_BUILD_SHARED_LIBS)
set(FLTK_LIBRARIES ${FLTK_LIBRARIES} PARENT_SCOPE)
set(FLTK_LIBRARIES_SHARED ${FLTK_LIBRARIES_SHARED} PARENT_SCOPE)

View File

@ -20,11 +20,11 @@ set (GIT_REVISION "")
set(YEAR "") set(YEAR "")
set(CURRENT_DATE "") set(CURRENT_DATE "")
if (OPTION_BUILD_HTML_DOCUMENTATION OR OPTION_BUILD_PDF_DOCUMENTATION) if(FLTK_BUILD_HTML_DOCS OR FLTK_BUILD_PDF_DOCS)
set(GENERATE_DOCS TRUE) set(GENERATE_DOCS TRUE)
endif() endif()
if (OPTION_INCLUDE_DRIVER_DOCUMENTATION) if(FLTK_INCLUDE_DRIVER_DOCS)
set(DRIVER_DOCS "DriverDev") set(DRIVER_DOCS "DriverDev")
else() else()
set(DRIVER_DOCS "") set(DRIVER_DOCS "")
@ -57,9 +57,10 @@ if (GENERATE_DOCS)
# that contains the git revision. # that contains the git revision.
execute_process(COMMAND execute_process(COMMAND
git --git-dir=${FLTK_SOURCE_DIR}/.git rev-parse --short=10 HEAD git rev-parse --short=10 HEAD
OUTPUT_VARIABLE GIT_REVISION OUTPUT_VARIABLE GIT_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${FLTK_SOURCE_DIR}
ERROR_QUIET ERROR_QUIET
) )
@ -110,7 +111,7 @@ endif (GENERATE_DOCS)
# build html documentation # build html documentation
#-------------------------- #--------------------------
if (OPTION_BUILD_HTML_DOCUMENTATION) if(FLTK_BUILD_HTML_DOCS)
list(APPEND DOCS html) list(APPEND DOCS html)
@ -153,13 +154,13 @@ if (OPTION_BUILD_HTML_DOCUMENTATION)
COMMENT "Generating HTML documentation" VERBATIM COMMENT "Generating HTML documentation" VERBATIM
) )
endif (OPTION_BUILD_HTML_DOCUMENTATION) endif(FLTK_BUILD_HTML_DOCS)
#-------------------------- #--------------------------
# build pdf documentation # build pdf documentation
#-------------------------- #--------------------------
if (OPTION_BUILD_PDF_DOCUMENTATION) if(FLTK_BUILD_PDF_DOCS)
list(APPEND DOCS pdf) list(APPEND DOCS pdf)
@ -224,7 +225,7 @@ if (OPTION_BUILD_PDF_DOCUMENTATION)
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fltk.pdf DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fltk.pdf
) )
endif (OPTION_BUILD_PDF_DOCUMENTATION) endif(FLTK_BUILD_PDF_DOCS)
#---------------------------------- #----------------------------------
# add target 'docs' for all docs # add target 'docs' for all docs
@ -242,18 +243,18 @@ endif (DOCS)
# install html + pdf documentation # install html + pdf documentation
#---------------------------------- #----------------------------------
if (OPTION_INSTALL_HTML_DOCUMENTATION AND OPTION_BUILD_HTML_DOCUMENTATION) if(FLTK_INSTALL_HTML_DOCS AND FLTK_BUILD_HTML_DOCS)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
DESTINATION ${FLTK_DATADIR}/doc/fltk DESTINATION ${FLTK_DATADIR}/doc/fltk
) )
endif (OPTION_INSTALL_HTML_DOCUMENTATION AND OPTION_BUILD_HTML_DOCUMENTATION) endif(FLTK_INSTALL_HTML_DOCS AND FLTK_BUILD_HTML_DOCS)
if (OPTION_INSTALL_PDF_DOCUMENTATION AND OPTION_BUILD_PDF_DOCUMENTATION) if(FLTK_INSTALL_PDF_DOCS AND FLTK_BUILD_PDF_DOCS)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/fltk.pdf install(FILES ${CMAKE_CURRENT_BINARY_DIR}/fltk.pdf
DESTINATION ${FLTK_DATADIR}/doc/fltk/ DESTINATION ${FLTK_DATADIR}/doc/fltk/
) )
endif (OPTION_INSTALL_PDF_DOCUMENTATION AND OPTION_BUILD_PDF_DOCUMENTATION) endif(FLTK_INSTALL_PDF_DOCS AND FLTK_BUILD_PDF_DOCS)

View File

@ -140,7 +140,7 @@ uninstall-linux uninstall-osx:
# Note that Doxyfile.in is shared with CMake to configure these files. # Note that Doxyfile.in is shared with CMake to configure these files.
# Note: There's no way to enable the "Driver Documentation" via configure+make, # Note: There's no way to enable the "Driver Documentation" via configure+make,
# please use CMake 'OPTION_INCLUDE_DRIVER_DOCUMENTATION' instead. # please use CMake 'FLTK_INCLUDE_DRIVER_DOCS' instead.
# Alternatively (if you really need it) edit this Makefile and # Alternatively (if you really need it) edit this Makefile and
# replace the two lines below containing "@DRIVER_DOCS@" to read: # replace the two lines below containing "@DRIVER_DOCS@" to read:
# -e's, @DRIVER_DOCS@, DriverDev,' \ # -e's, @DRIVER_DOCS@, DriverDev,' \

View File

@ -106,15 +106,15 @@ required software packages (doxygen, LaTeX) installed. You can
always leave them ON because the documentation is not built always leave them ON because the documentation is not built
automatically (it is excluded from the default target "ALL"). automatically (it is excluded from the default target "ALL").
- OPTION_BUILD_HTML_DOCUMENTATION:BOOL=ON target: html - FLTK_BUILD_HTML_DOCS:BOOL=ON target: html
- OPTION_BUILD_PDF_DOCUMENTATION:BOOL=ON target: pdf - FLTK_BUILD_PDF_DOCS:BOOL=ON target: pdf
The following two options default to OFF and can be switched ON. The following two options default to OFF and can be switched ON.
They are only used when installing the software ('make install') They are only used when installing the software ('make install')
and the corresponding build options are ON. and the corresponding build options are ON.
- OPTION_INSTALL_HTML_DOCUMENTATION:BOOL=OFF - FLTK_INSTALL_HTML_DOCS:BOOL=OFF
- OPTION_INSTALL_PDF_DOCUMENTATION:BOOL=OFF - FLTK_INSTALL_PDF_DOCS:BOOL=OFF
If you switch one or both of the first two options ON, then the build If you switch one or both of the first two options ON, then the build
targets 'html' and/or 'pdf' are generated, respectively. Target 'docs' targets 'html' and/or 'pdf' are generated, respectively. Target 'docs'

View File

@ -863,7 +863,7 @@ requires 4 bytes to store a Unicode character.
FLTK can draw accurately any Unicode-supported script for which the system FLTK can draw accurately any Unicode-supported script for which the system
contains relevant fonts. Under X11 platforms, this requires contains relevant fonts. Under X11 platforms, this requires
to build the library with the OPTION_USE_PANGO CMake option turned On to build the library with the FLTK_USE_PANGO CMake option turned On
(or with configure --enable-pango). (or with configure --enable-pango).
Plain text drawing starting at a user-given coordinate Plain text drawing starting at a user-given coordinate

View File

@ -180,6 +180,129 @@ Code example in header file:
Note the \p 'const' attribute \b and the \p FL_OVERRIDE macro. Note the \p 'const' attribute \b and the \p FL_OVERRIDE macro.
\section migration_1_4_modern_cmake Modern CMake
FLTK 1.4.0 supports "modern" CMake rather than old or "classic" CMake
which was used in FLTK 1.3.x. Modern CMake was introduced in CMake 3.0
(~ 2014) and further developed in later CMake versions. FLTK 1.4.0 requires
at least CMake 3.15 (~ 2019) as of Febrary 2024.
There are a lot of advantages that motivated this transition (mentioning
only some):
- easier to use for projects using FLTK
- better structure
- uses CMake targets rather than variables
- embeddable in user projects via FetchContent() etc.
- embeddable in user projects via add_subdirectory()
- better coexistence with main projects if built as a subproject
Note that CMake targets can provide all required build flags and build
dependencies which is the main advantage for user projects. For instance,
instead of linking both fltk and fltk_images you need only fltk_images
and fltk is linked in automatically.
Unfortunately there is one drawback you may encounter: Several CMake build
option names have been changed, compared to FLTK 1.3.x. This is due to the
fact that CMake cache variables are shared between the main (aka superbuild)
project and all subprojects. Therefore all FLTK options are now prefixed
with FLTK_.
This feature is now CMake standard and very common in newer projects. The
CMake developers recommend strongly to use modern CMake.
We took the opportunity to redesign all CMake related options and target
names for FLTK 1.4.0 to avoid changing these names later. Note that CMake
support in 1.3.x was only experimental and the one in FLTK 1.4 (Git) up to
the official release was beta state by definition. We apologize for all
inconveniencies, hope that this is one of the rare exceptions in FLTK
development, and that the new names are now stable as usual.
Changes in Detail:
Since FLTK 1.4.0 CMake target names are "namespaced", i.e. they are created
with the prefix 'fltk::' and the old prefix 'fltk_' has been stripped off
as far as the CMakeLists.txt file of user projects is concerned. The known
filenames on disk did not change though.
The shared library target names use the common suffix "-shared" rather
than "_SHARED".
The library 'fltk_cairo' is no longer used. Its functionality has been included
in libfltk. FLTK 1.4.0 creates a dummy (empty) libfltk_cairo for backwards
compatibility only. Please remove fltk_cairo from your projects and use only
'fltk::fltk' and/or the other libraries instead.
For more information and documentation of all options please refer to the
file README.CMake.txt in the FLTK root directory.
Old and New Library Targets:
Library | Old Target | New Target | Shared Library Target
----------------|--------------|-----------------|-----------------------
fltk | fltk | fltk::fltk | fltk::fltk-shared
fltk_forms | fltk_forms | fltk::forms | fltk::forms-shared
fltk_gl | fltk_gl | fltk::gl | fltk::gl-shared
fltk_images | fltk_images | fltk::images | fltk::images-shared
fltk_jpeg | fltk_jpeg | fltk::jpeg | fltk::jpeg-shared
fltk_png | fltk_png | fltk::png | fltk::png-shared
fltk_z | fltk_z | fltk::z | fltk::z-shared
fluid | fluid | fltk::fluid | n/a
For project developers used to the old (1.3.x) names the following table can
assist to find the new option names. This table is ordered alphabetically
by the old option name. Note that some option names did not change and
some of the "old" names have been introduced in early 1.4.0 development.
Old Option Name (FLTK 1.3.x) | New Option Name (FLTK 1.4.x)
-------------------------------------|------------------------------------
FLTK_BUILD_EXAMPLES | FLTK_BUILD_EXAMPLES
FLTK_BUILD_FLTK_OPTIONS | FLTK_BUILD_FLTK_OPTIONS
FLTK_BUILD_FLUID | FLTK_BUILD_FLUID
FLTK_BUILD_FORMS | FLTK_BUILD_FORMS
FLTK_BUILD_TEST | FLTK_BUILD_TEST
FLTK_MSVC_RUNTIME_DLL | FLTK_MSVC_RUNTIME_DLL
OPTION_ABI_VERSION | FLTK_ABI_VERSION
OPTION_ALLOW_GTK_PLUGIN | FLTK_USE_LIBDECOR_GTK
OPTION_APPLE_X11 | FLTK_BACKEND_X11
OPTION_ARCHFLAGS | FLTK_ARCHFLAGS
OPTION_BUILD_HTML_DOCUMENTATION | FLTK_BUILD_HTML_DOCS
OPTION_BUILD_PDF_DOCUMENTATION | FLTK_BUILD_PDF_DOCS
OPTION_BUILD_SHARED_LIBS | FLTK_BUILD_SHARED_LIBS
OPTION_CAIRO | FLTK_OPTION_CAIRO_WINDOW
OPTION_CAIROEXT | FLTK_OPTION_CAIRO_EXT
OPTION_CREATE_LINKS | FLTK_INSTALL_LINKS
OPTION_FILESYSTEM_SUPPORT | FLTK_OPTION_FILESYSTEM_SUPPORT
OPTION_INCLUDE_DRIVER_DOCUMENTATION | FLTK_INCLUDE_DRIVER_DOCS
OPTION_INSTALL_HTML_DOCUMENTATION | FLTK_INSTALL_HTML_DOCS
OPTION_INSTALL_PDF_DOCUMENTATION | FLTK_INSTALL_PDF_DOCS
OPTION_LARGE_FILE | FLTK_OPTION_LARGE_FILE
OPTION_OPTIM | FLTK_OPTION_OPTIM
OPTION_PRINT_SUPPORT | FLTK_OPTION_PRINT_SUPPORT
OPTION_USE_CAIRO | FLTK_GRAPHICS_CAIRO
OPTION_USE_GDIPLUS | FLTK_GRAPHICS_GDIPLUS
OPTION_USE_GL | FLTK_BUILD_GL
OPTION_USE_KDIALOG | FLTK_USE_KDIALOG
OPTION_USE_PANGO | FLTK_USE_PANGO
OPTION_USE_POLL | FLTK_USE_POLL
OPTION_USE_STD | FLTK_OPTION_STD
OPTION_USE_SVG | FLTK_OPTION_SVG
OPTION_USE_SYSTEM_LIBDECOR | FLTK_USE_SYSTEM_LIBDECOR
OPTION_USE_SYSTEM_LIBJPEG | FLTK_USE_SYSTEM_LIBJPEG
OPTION_USE_SYSTEM_LIBPNG | FLTK_USE_SYSTEM_LIBPNG
OPTION_USE_SYSTEM_ZLIB | FLTK_USE_SYSTEM_ZLIB
OPTION_USE_THREADS | FLTK_USE_PTHREADS
OPTION_USE_WAYLAND | FLTK_BACKEND_WAYLAND
OPTION_USE_XCURSOR | FLTK_USE_XCURSOR
OPTION_USE_XFIXES | FLTK_USE_XFIXES
OPTION_USE_XFT | FLTK_USE_XFT
OPTION_USE_XINERAMA | FLTK_USE_XINERAMA
OPTION_USE_XRENDER | FLTK_USE_XRENDER
OPTION_WAYLAND_ONLY | FLTK_BACKEND_X11=OFF
\htmlonly \htmlonly
<hr> <hr>
<table summary="navigation bar" width="100%" border="0"> <table summary="navigation bar" width="100%" border="0">

View File

@ -191,7 +191,7 @@ without any other change in the source code nor to the application's environment
In special situations, such as with embedded systems equipped with the Wayland software but lacking In special situations, such as with embedded systems equipped with the Wayland software but lacking
the X11 library, it's possible to build the FLTK library such as it contains only the Wayland backend. the X11 library, it's possible to build the FLTK library such as it contains only the Wayland backend.
This is achieved building FLTK with <tt>cmake -DOPTION_WAYLAND_ONLY=on</tt> or with This is achieved building FLTK with <tt>cmake -DFLTK_BACKEND_X11=OFF</tt> or with
<tt>configure --disable-x11</tt>. In that case, FL/fl_config.h does not define <tt>configure --disable-x11</tt>. In that case, FL/fl_config.h does not define
\c FLTK_USE_X11. \c FLTK_USE_X11.
@ -1120,7 +1120,7 @@ build system, preprocessor variable \c USE_SYSTEM_LIBDECOR is 1,
and both \c libdecor and its plugin are loaded at run-time from shared libraries. and both \c libdecor and its plugin are loaded at run-time from shared libraries.
When these packages are not available or are at an earlier version, FLTK uses the bundled When these packages are not available or are at an earlier version, FLTK uses the bundled
copy of \c libdecor. copy of \c libdecor.
When CMake \c OPTION_USE_SYSTEM_LIBDECOR is OFF, FLTK uses the bundled \c libdecor copy When CMake \c FLTK_USE_SYSTEM_LIBDECOR is OFF, FLTK uses the bundled \c libdecor copy
even if shared libraries \c libdecor.so and \c libdecor-gtk.so are installed. even if shared libraries \c libdecor.so and \c libdecor-gtk.so are installed.
This option is ON by default. This option is ON by default.
@ -1133,7 +1133,7 @@ However, if environment variable \c LIBDECOR_FORCE_CSD is defined to value \c 1
FLTK app runs, \c libdecor instructs an SSD-able compositor to refrain from decorating its FLTK app runs, \c libdecor instructs an SSD-able compositor to refrain from decorating its
windows and decorates windows itself. windows and decorates windows itself.
Whatever the value of \c OPTION_USE_SYSTEM_LIBDECOR, FLTK and \c libdecor use environment variable Whatever the value of \c FLTK_USE_SYSTEM_LIBDECOR, FLTK and \c libdecor use environment variable
\c LIBDECOR_PLUGIN_DIR as follows: if this variable is defined and points to the name of a directory, \c LIBDECOR_PLUGIN_DIR as follows: if this variable is defined and points to the name of a directory,
this directory is searched for a potential \c libdecor plugin in the form of a shared library; this directory is searched for a potential \c libdecor plugin in the form of a shared library;
if one is found, FLTK and \c libdecor load it and use it. if one is found, FLTK and \c libdecor load it and use it.

View File

@ -1,7 +1,7 @@
# #
# CMakeLists.txt used to build example apps by the CMake build system # CMakeLists.txt used to build example apps by the CMake build system
# #
# Copyright 2020-2023 by Bill Spitzak and others. # Copyright 2020-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -113,7 +113,7 @@ set (OPENGL_SOURCES
############################################################ ############################################################
foreach(src ${SIMPLE_SOURCES}) foreach(src ${SIMPLE_SOURCES})
CREATE_EXAMPLE (${src} ${src}.cxx fltk) fl_create_example(${src} ${src}.cxx fltk)
endforeach(src) endforeach(src)
############################################################ ############################################################
@ -121,7 +121,7 @@ endforeach (src)
############################################################ ############################################################
foreach(src ${FLUID_SOURCES}) foreach(src ${FLUID_SOURCES})
CREATE_EXAMPLE (${src} ${src}.fl fltk) fl_create_example(${src} ${src}.fl fltk)
endforeach(src) endforeach(src)
############################################################ ############################################################
@ -129,7 +129,7 @@ endforeach (src)
############################################################ ############################################################
foreach(src ${IMAGE_SOURCES}) foreach(src ${IMAGE_SOURCES})
CREATE_EXAMPLE (${src} ${src}.cxx "fltk_images;fltk") fl_create_example(${src} ${src}.cxx "fltk_images;fltk")
endforeach(src) endforeach(src)
############################################################ ############################################################
@ -146,7 +146,7 @@ else ()
endif() endif()
foreach(src ${CAIRO_SOURCES}) foreach(src ${CAIRO_SOURCES})
CREATE_EXAMPLE (${src} ${src}.cxx "${cairo_libs}") fl_create_example(${src} ${src}.cxx "${cairo_libs}")
endforeach(src) endforeach(src)
############################################################ ############################################################
@ -155,7 +155,7 @@ endforeach (src)
# Note: macOS does not need libGLEW # Note: macOS does not need libGLEW
if (APPLE AND (NOT OPTION_APPLE_X11)) if(APPLE AND NOT FLTK_BACKEND_X11)
if(NOT LIB_GLEW) if(NOT LIB_GLEW)
set(LIB_GLEW TRUE) set(LIB_GLEW TRUE)
endif() endif()
@ -166,7 +166,7 @@ endif ()
if(OPENGL_FOUND AND LIB_GLEW) if(OPENGL_FOUND AND LIB_GLEW)
foreach(src ${OPENGL_SOURCES}) foreach(src ${OPENGL_SOURCES})
CREATE_EXAMPLE (${src} ${src}.cxx "${REQUIRED_LIBS}") fl_create_example(${src} ${src}.cxx "${REQUIRED_LIBS}")
endforeach(src) endforeach(src)
else() else()
message(STATUS message(STATUS

View File

@ -59,7 +59,7 @@ int main(int argc, char **argv) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
fl_message_title("This program needs a Cairo enabled FLTK library"); fl_message_title("This program needs a Cairo enabled FLTK library");
fl_message("Please configure FLTK with Cairo enabled (--enable-cairo or --enable-cairoext)\n" fl_message("Please configure FLTK with Cairo enabled (--enable-cairo or --enable-cairoext)\n"
"or one of the CMake options OPTION_CAIRO or OPTION_CAIROEXT, respectively."); "or one of the CMake options FLTK_OPTION_CAIRO_WINDOW or FLTK_OPTION_CAIRO_EXT, respectively.");
return 0; return 0;
} }
#endif // (FLTK_HAVE_CAIRO) #endif // (FLTK_HAVE_CAIRO)

View File

@ -55,7 +55,7 @@ const char *svg_logo =
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifndef FLTK_USE_SVG #ifndef FLTK_USE_SVG
fl_message("You need to build FLTK with 'configure --enable-svg'\n" fl_message("You need to build FLTK with 'configure --enable-svg'\n"
"or CMake option 'OPTION_USE_SVG'\n" "or CMake option 'FLTK_OPTION_SVG'\n"
"to use this example."); "to use this example.");
return(1); return(1);
#else #else

View File

@ -1,7 +1,7 @@
# #
# CMakeLists.txt to build fltk-options for the FLTK project using CMake (www.cmake.org) # CMakeLists.txt to build fltk-options for the FLTK project using CMake (www.cmake.org)
# #
# Copyright 2023 by Bill Spitzak and others. # Copyright 2023-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -14,23 +14,16 @@
# https://www.fltk.org/bugs.php # https://www.fltk.org/bugs.php
# #
set (CPPFILES # Targets that will be built: fltk-options and fltk-options-cmd (Windows)
fltk-options.cxx set(TARGETS fltk-options)
)
set (HEADERFILES if(APPLE AND NOT FLTK_BACKEND_X11)
)
set (FLTK_OPTIONS_TARGETS fltk-options) # fltk-options and optional fltk-options-cmd target
set (FLTK_OPTIONS_LIBS fltk) # libraries used to link fltk-options executables
if (APPLE AND (NOT OPTION_APPLE_X11))
# macOS # macOS
set(ICON_NAME fltk-options.icns) set(ICON_NAME fltk-options.icns)
set(ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icons/${ICON_NAME}") set(ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icons/${ICON_NAME}")
add_executable (fltk-options MACOSX_BUNDLE ${CPPFILES} ${HEADERFILES} ${ICON_PATH}) add_executable(fltk-options MACOSX_BUNDLE fltk-options.cxx ${ICON_PATH})
# create macOS bundle wrapper script # create macOS bundle wrapper script
@ -46,39 +39,34 @@ if (APPLE AND (NOT OPTION_APPLE_X11))
else() else()
# option WIN32 builds a Windows GUI program, ignored on other platforms # Option WIN32 builds a Windows GUI program, ignored on other platforms
add_executable (fltk-options WIN32 ${CPPFILES} ${HEADERFILES}) add_executable(fltk-options WIN32 fltk-options.cxx)
endif() endif()
# we must link fltk-optons with cairo if option CAIRO is enabled target_link_libraries(fltk-options PRIVATE fltk::fltk)
if (FLTK_HAVE_CAIRO)
target_link_directories (fltk-options PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
endif (FLTK_HAVE_CAIRO)
if (USE_GDIPLUS) # can only be true on Windows # Add the console app (Windows only)
list (APPEND FLTK_OPTIONS_LIBS gdiplus)
endif (USE_GDIPLUS)
target_link_libraries (fltk-options ${FLTK_OPTIONS_LIBS})
# Add fltk-options-cmd console app (Windows only) for editing FLTK options.
# This is done for all Windows targets, even if cross-compiling. # This is done for all Windows targets, even if cross-compiling.
if(WIN32) if(WIN32)
list (APPEND FLTK_OPTIONS_TARGETS fltk-options-cmd) list(APPEND TARGETS fltk-options-cmd)
add_executable (fltk-options-cmd ${CPPFILES} ${HEADERFILES}) add_executable(fltk-options-cmd fltk-options.cxx)
target_link_libraries (fltk-options-cmd ${FLTK_OPTIONS_LIBS}) target_link_libraries(fltk-options-cmd PRIVATE fltk::fltk)
if (FLTK_HAVE_CAIRO)
target_link_directories (fltk-options-cmd PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
endif (FLTK_HAVE_CAIRO)
endif() endif()
# Create aliases for all executables,
# replacing 'fltk-options' with 'fltk::options'
# install fltk-options GUI and commandline tool foreach(tgt ${TARGETS})
string(REPLACE "fltk-options" "fltk::options" alias ${tgt})
add_executable(${alias} ALIAS ${tgt})
unset(alias)
endforeach()
if (APPLE AND (NOT OPTION_APPLE_X11)) # Install fltk-options GUI and commandline tool
if(APPLE AND NOT FLTK_BACKEND_X11)
# On macOS, fltk-options must be installed twice. The bundled version of # On macOS, fltk-options must be installed twice. The bundled version of
# fltk-options needs to go into the /Applications folder to make it visible # fltk-options needs to go into the /Applications folder to make it visible
@ -108,16 +96,16 @@ else()
# install fltk-options GUI and optional commandline tool 'fltk-options-cmd' # install fltk-options GUI and optional commandline tool 'fltk-options-cmd'
# (only on Windows) # (only on Windows)
install (TARGETS ${FLTK_OPTIONS_TARGETS} install(TARGETS ${TARGETS}
EXPORT FLTK-Targets EXPORT FLTK-Targets
RUNTIME DESTINATION ${FLTK_BINDIR} RUNTIME DESTINATION ${FLTK_BINDIR}
LIBRARY DESTINATION ${FLTK_LIBDIR} LIBRARY DESTINATION ${FLTK_LIBDIR}
ARCHIVE DESTINATION ${FLTK_LIBDIR} ARCHIVE DESTINATION ${FLTK_LIBDIR}
) )
endif (APPLE AND (NOT OPTION_APPLE_X11)) endif(APPLE AND NOT FLTK_BACKEND_X11)
# install desktop files # Install desktop files
if(UNIX) if(UNIX)
install(FILES fltk-options.desktop install(FILES fltk-options.desktop

View File

@ -1,7 +1,7 @@
# #
# CMakeLists.txt to build fluid for the FLTK project using CMake (www.cmake.org) # CMakeLists.txt to build fluid for the FLTK project using CMake (www.cmake.org)
# #
# Copyright 1998-2023 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -14,7 +14,12 @@
# https://www.fltk.org/bugs.php # https://www.fltk.org/bugs.php
# #
# Source files for 'fluid-lib' = all source files except fluid.cxx # Targets that will be built: fluid and fluid-cmd (Windows)
set(TARGETS fluid)
# Source files for 'fluid-lib' = all source files except the main file (fluid.cxx)
# Note: macOS (Xcode) needs at least one source file (fluid.cxx) to link the main
# program fluid properly
set(CPPFILES set(CPPFILES
CodeEditor.cxx CodeEditor.cxx
@ -71,6 +76,7 @@ set (HEADERFILES
custom_widgets.h custom_widgets.h
factory.h factory.h
file.h file.h
fluid.h
function_panel.h function_panel.h
mergeback.h mergeback.h
print_panel.h print_panel.h
@ -127,23 +133,21 @@ set ( DEV_DOC_FILES
source_group("Documentation: Developer" FILES ${DEV_DOC_FILES}) source_group("Documentation: Developer" FILES ${DEV_DOC_FILES})
# Build a local object library to avoid compiling all source files # Build a local object library to avoid compiling all source files
# for all fluid targets (fluid, fluid-cmd, fluid-shared). This # multiple times for all fluid targets on Windows (fluid + fluid-cmd).
# library includes everything except the main program (fluid.cxx).
add_library (fluid-lib OBJECT EXCLUDE_FROM_ALL ${CPPFILES} ${HEADERFILES} ${USER_DOC_FILES} ${DEV_DOC_FILES}) add_library(fluid-lib OBJECT EXCLUDE_FROM_ALL)
target_sources(fluid-lib PRIVATE ${CPPFILES} ${HEADERFILES})
target_link_libraries(fluid-lib PUBLIC fltk::images)
# Build fluid with all its variants (fluid-cmd, fluid-shared) ... # Build targets
set (FLUID_TARGETS fluid) # fluid and optional fluid-cmd target if(APPLE AND NOT FLTK_BACKEND_X11)
set (FLUID_LIBS fluid-lib fltk fltk_images) # libraries used to link fluid executables
if (APPLE AND (NOT OPTION_APPLE_X11))
# macOS # macOS
set(ICON_NAME fluid.icns) set(ICON_NAME fluid.icns)
set(ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icons/${ICON_NAME}") set(ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icons/${ICON_NAME}")
add_executable (fluid MACOSX_BUNDLE fluid.cxx fluid.h ${ICON_PATH}) add_executable(fluid MACOSX_BUNDLE fluid.cxx ${ICON_PATH})
# create macOS bundle wrapper script # create macOS bundle wrapper script
@ -160,60 +164,30 @@ if (APPLE AND (NOT OPTION_APPLE_X11))
else() else()
# Option 'WIN32' builds a Windows GUI program, ignored on other platforms # Option 'WIN32' builds a Windows GUI program, ignored on other platforms
add_executable (fluid WIN32 fluid.cxx fluid.h) add_executable(fluid WIN32 fluid.cxx)
endif() endif()
# Link fluid with Cairo if OPTION_CAIRO is enabled target_link_libraries(fluid PRIVATE fluid-lib)
if (FLTK_HAVE_CAIRO)
target_include_directories (fluid PRIVATE ${PKG_CAIRO_INCLUDE_DIRS})
if (PKG_CAIRO_LIBRARY_DIRS)
target_link_directories (fluid PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
endif ()
endif (FLTK_HAVE_CAIRO)
if (USE_GDIPLUS) # can only be true on Windows # Build the console app on Windows
list (APPEND FLUID_LIBS gdiplus)
endif (USE_GDIPLUS)
target_link_libraries (fluid ${FLUID_LIBS})
# Add fluid-cmd console app (Windows only) for converting .fl to .cxx/.h files.
# This is done for all Windows targets, even if cross-compiling. # This is done for all Windows targets, even if cross-compiling.
if(WIN32) if(WIN32)
list (APPEND FLUID_TARGETS fluid-cmd) list(APPEND TARGETS fluid-cmd)
add_executable (fluid-cmd fluid.cxx fluid.h) add_executable(fluid-cmd fluid.cxx)
target_link_libraries (fluid-cmd ${FLUID_LIBS}) target_link_libraries(fluid-cmd PRIVATE fluid-lib)
# Link fluid-cmd with Cairo if OPTION_CAIRO is enabled (same as above)
if (FLTK_HAVE_CAIRO)
target_include_directories (fluid-cmd PRIVATE ${PKG_CAIRO_INCLUDE_DIRS})
if (PKG_CAIRO_LIBRARY_DIRS)
target_link_directories (fluid-cmd PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
endif() endif()
endif (FLTK_HAVE_CAIRO)
endif (WIN32)
# Build fluid-shared (experimental) # Create aliases for all targets
if (OPTION_BUILD_SHARED_LIBS) foreach(tgt ${TARGETS})
list (APPEND FLUID_TARGETS fluid-shared) add_executable(fltk::${tgt} ALIAS ${tgt})
add_executable (fluid-shared fluid.cxx fluid.h) endforeach()
if (MSVC)
# Todo: this should link against fltk_SHARED rather than fltk_images but for an unknown
# reason this would issue link errors (about 25 undefined symbols). Needs investigation.
# AlbrechtS: Sep. 12, 2023
target_link_libraries (fluid-shared PRIVATE fluid-lib fltk_images) # should be: fltk_SHARED)
else ()
target_link_libraries (fluid-shared PRIVATE fluid-lib fltk_images_SHARED)
endif (MSVC)
endif ()
# Install fluid GUI and commandline tool # Install fluid GUI and commandline tool
if (APPLE AND (NOT OPTION_APPLE_X11)) if(APPLE AND NOT FLTK_BACKEND_X11)
# On macOS, Fluid must be installed twice. The bundled version of Fluid needs # On macOS, Fluid must be installed twice. The bundled version of Fluid needs
# to go into the /Applications folder to make it visible as a user App with # to go into the /Applications folder to make it visible as a user App with
@ -241,14 +215,14 @@ else()
# install Fluid GUI and optional commandline tool 'fluid-cmd' (only on Windows) # install Fluid GUI and optional commandline tool 'fluid-cmd' (only on Windows)
install (TARGETS ${FLUID_TARGETS} install(TARGETS ${TARGETS}
EXPORT FLTK-Targets EXPORT FLTK-Targets
RUNTIME DESTINATION ${FLTK_BINDIR} RUNTIME DESTINATION ${FLTK_BINDIR}
LIBRARY DESTINATION ${FLTK_LIBDIR} LIBRARY DESTINATION ${FLTK_LIBDIR}
ARCHIVE DESTINATION ${FLTK_LIBDIR} ARCHIVE DESTINATION ${FLTK_LIBDIR}
) )
endif (APPLE AND (NOT OPTION_APPLE_X11)) endif(APPLE AND NOT FLTK_BACKEND_X11)
# Install desktop files # Install desktop files

View File

@ -1,7 +1,7 @@
# #
# JPEG library CMake configuration for the Fast Light Toolkit (FLTK). # JPEG library CMake configuration for the Fast Light Toolkit (FLTK).
# #
# Copyright 1998-2023 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -47,9 +47,16 @@ set (decompression_SRCS
list(APPEND BUILD_SRCS "${systemdependent_SRCS};${common_SRCS}") list(APPEND BUILD_SRCS "${systemdependent_SRCS};${common_SRCS}")
list(APPEND BUILD_SRCS "${compression_SRCS};${decompression_SRCS}") list(APPEND BUILD_SRCS "${compression_SRCS};${decompression_SRCS}")
#######################################################################
# Set common variables for static and shared builds
####################################################################### #######################################################################
# Suppress some Visual Studio compiler warnings set(_include_dirs
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
# Suppress Visual Studio compiler warnings
set(msvc_warnings /wd4267) set(msvc_warnings /wd4267)
@ -57,31 +64,53 @@ set (msvc_warnings /wd4267)
# Build the static library # Build the static library
####################################################################### #######################################################################
FL_ADD_LIBRARY (fltk_jpeg STATIC "${BUILD_SRCS}") fl_add_library(fltk_jpeg STATIC "${BUILD_SRCS}")
set(target fltk_jpeg)
target_include_directories(${target} PUBLIC ${_include_dirs})
if(MSVC) if(MSVC)
target_compile_options (fltk_jpeg PRIVATE ${msvc_warnings}) target_compile_options(${target} PRIVATE ${msvc_warnings})
endif(MSVC) endif(MSVC)
list(APPEND FLTK_IMAGE_LIBRARIES fltk::jpeg)
# Propagate to parent scope (modified by fl_add_library and here)
set(FLTK_LIBRARIES ${FLTK_LIBRARIES} PARENT_SCOPE)
set(FLTK_IMAGE_LIBRARIES ${FLTK_IMAGE_LIBRARIES} PARENT_SCOPE)
####################################################################### #######################################################################
# Build the shared library (optional) # Build the shared library (optional)
####################################################################### #######################################################################
if (OPTION_BUILD_SHARED_LIBS) if(FLTK_BUILD_SHARED_LIBS)
FL_ADD_LIBRARY (fltk_jpeg SHARED "${BUILD_SRCS}") # ensure to export all symbols for Windows DLL's
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
fl_add_library(fltk_jpeg SHARED "${BUILD_SRCS}")
set(target fltk_jpeg-shared)
target_include_directories(${target} PUBLIC ${_include_dirs})
if(MSVC) if(MSVC)
target_compile_options (fltk_jpeg_SHARED PRIVATE ${msvc_warnings}) target_compile_options(${target} PRIVATE ${msvc_warnings})
endif(MSVC) endif(MSVC)
endif (OPTION_BUILD_SHARED_LIBS) list(APPEND FLTK_IMAGE_LIBRARIES_SHARED fltk::jpeg-shared)
# Propagate to parent scope (modified by fl_add_library and here)
set(FLTK_LIBRARIES_SHARED ${FLTK_LIBRARIES_SHARED} PARENT_SCOPE)
set(FLTK_IMAGE_LIBRARIES_SHARED ${FLTK_IMAGE_LIBRARIES_SHARED} PARENT_SCOPE)
endif(FLTK_BUILD_SHARED_LIBS)
####################################################################### #######################################################################
# Install the library headers # Install the library headers
####################################################################### #######################################################################
install (FILES jconfig.h jerror.h jmorecfg.h jpeglib.h install(FILES
fltk_jpeg_prefix.h jconfig.h jerror.h jmorecfg.h jpeglib.h fltk_jpeg_prefix.h
DESTINATION ${FLTK_INCLUDEDIR}/FL/images DESTINATION
${FLTK_INCLUDEDIR}/FL/images
) )

View File

@ -96,12 +96,12 @@ LIBDECOR_EXPORT void libdecor_frame_set_minimized(struct libdecor_frame *frame)
* if FLTK was built with package libgtk-3-dev, the GTK plugin is used * if FLTK was built with package libgtk-3-dev, the GTK plugin is used
* if FLTK was built without package libgtk-3-dev, the Cairo plugin is used * if FLTK was built without package libgtk-3-dev, the Cairo plugin is used
If FLTK was built with OPTION_USE_SYSTEM_LIBDECOR turned ON, the present modification If FLTK was built with FLTK_USE_SYSTEM_LIBDECOR turned ON, the present modification
isn't compiled, so the plugin-searching algorithm of libdecor_new() in libdecor-0.so is used. isn't compiled, so the plugin-searching algorithm of libdecor_new() in libdecor-0.so is used.
This corresponds to step 1) above and to use no titlebar is no plugin is found. This corresponds to step 1) above and to use no titlebar is no plugin is found.
N.B.: only the system package is built with a meaningful value of -DLIBDECOR_PLUGIN_DIR= N.B.: only the system package is built with a meaningful value of -DLIBDECOR_PLUGIN_DIR=
so a plugin may be loaded that way only if FLTK was built with OPTION_USE_SYSTEM_LIBDECOR turned ON. so a plugin may be loaded that way only if FLTK was built with FLTK_USE_SYSTEM_LIBDECOR turned ON.
*/ */
LIBDECOR_EXPORT struct libdecor *libdecor_new(struct wl_display *wl_display, struct libdecor_interface *iface) LIBDECOR_EXPORT struct libdecor *libdecor_new(struct wl_display *wl_display, struct libdecor_interface *iface)

View File

@ -1,7 +1,7 @@
# #
# PNG library CMake configuration for the Fast Light Toolkit (FLTK). # PNG library CMake configuration for the Fast Light Toolkit (FLTK).
# #
# Copyright 1998-2023 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -36,8 +36,8 @@ set (PNG_SRCS
####################################################################### #######################################################################
# Note: This file is used only if we build the bundled PNG library, # Note: This file is used only if we build the bundled PNG library,
# and if we do this we MUST also build and use the *bundled* ZLIB, # and if we do this we MUST also build and use the *bundled* ZLIB,
# hence we MUST also link against the bundled ZLIB (see below). # hence we also link against the bundled ZLIB. Therefore there's
# There's no need to check which ZLIB version to use in this context. # no need to check which ZLIB version to use in this context.
####################################################################### #######################################################################
####################################################################### #######################################################################
@ -56,7 +56,7 @@ else ()
endif() endif()
if(is_arm) if(is_arm)
LIST (APPEND PNG_SRCS list(APPEND PNG_SRCS
arm/arm_init.c arm/arm_init.c
arm/filter_neon_intrinsics.c arm/filter_neon_intrinsics.c
arm/palette_neon_intrinsics.c arm/palette_neon_intrinsics.c
@ -66,31 +66,69 @@ endif ()
unset(is_arm) unset(is_arm)
####################################################################### #######################################################################
# Build some files on ppc64 # Build some files on ppc64.
# We compile these files whatever the architecture resulting in void code # We compile these files whatever the architecture resulting in
# on non-ppc64 architectures. # void code on non-ppc64 architectures.
####################################################################### #######################################################################
LIST (APPEND PNG_SRCS list(APPEND PNG_SRCS
powerpc/powerpc_init.c powerpc/powerpc_init.c
powerpc/filter_vsx_intrinsics.c powerpc/filter_vsx_intrinsics.c
) )
#######################################################################
# Set common variables for static and shared builds
#######################################################################
set(compile_defs
HAVE_PNG_H=1
HAVE_PNG_GET_VALID=1
HAVE_PNG_SET_TRNS_TO_ALPHA=1
)
set(include_dirs
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
####################################################################### #######################################################################
# Build the static library # Build the static library
####################################################################### #######################################################################
FL_ADD_LIBRARY (fltk_png STATIC "${PNG_SRCS}") fl_add_library(fltk_png STATIC "${PNG_SRCS}")
target_link_libraries (fltk_png PUBLIC fltk_z) set(target fltk_png)
target_link_libraries (${target} PUBLIC fltk::z)
target_compile_definitions(${target} PUBLIC ${compile_defs})
target_include_directories(${target} PUBLIC ${include_dirs})
list(APPEND FLTK_IMAGE_LIBRARIES fltk::png)
# Propagate to parent scope (modified by fl_add_library and here)
set(FLTK_LIBRARIES ${FLTK_LIBRARIES} PARENT_SCOPE)
set(FLTK_IMAGE_LIBRARIES ${FLTK_IMAGE_LIBRARIES} PARENT_SCOPE)
####################################################################### #######################################################################
# Build the shared library (optional) # Build the shared library (optional)
####################################################################### #######################################################################
if (OPTION_BUILD_SHARED_LIBS) if(FLTK_BUILD_SHARED_LIBS)
FL_ADD_LIBRARY (fltk_png SHARED "${PNG_SRCS}") # ensure to export all symbols for Windows DLL's
target_link_libraries (fltk_png_SHARED PUBLIC fltk_z_SHARED) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
fl_add_library(fltk_png SHARED "${PNG_SRCS}")
set(target fltk_png-shared)
target_link_libraries (${target} PUBLIC fltk::z-shared)
target_compile_definitions(${target} PUBLIC ${compile_defs})
target_include_directories(${target} PUBLIC ${include_dirs})
list(APPEND FLTK_IMAGE_LIBRARIES_SHARED fltk::png-shared)
# Propagate to parent scope (modified by fl_add_library and here)
set(FLTK_LIBRARIES_SHARED ${FLTK_LIBRARIES_SHARED} PARENT_SCOPE)
set(FLTK_IMAGE_LIBRARIES_SHARED ${FLTK_IMAGE_LIBRARIES_SHARED} PARENT_SCOPE)
endif() endif()

View File

@ -14,6 +14,20 @@
# https://www.fltk.org/bugs.php # https://www.fltk.org/bugs.php
# #
# Local macro to check existence of a required file with warning message
#
# In: FILENAME (string): File to search
# Out: WARN (string): *Name* of a variable that is set to true if NOT found
#
# Set variable ${WARN} to FALSE before calling this macro
macro(fl_check_required_file WARN FILENAME)
if(NOT EXISTS ${FILENAME})
message("*** Required file not found: ${FILENAME} ***")
set(${WARN} TRUE)
endif()
endmacro(fl_check_required_file WARN FILENAME)
set(CPPFILES set(CPPFILES
Fl.cxx Fl.cxx
Fl_Adjuster.cxx Fl_Adjuster.cxx
@ -173,7 +187,7 @@ set (CPPFILES
screen_xywh.cxx screen_xywh.cxx
) )
if (FLTK_HAVE_CAIRO) # OPTION_CAIRO or OPTION_CAIROEXT if(FLTK_HAVE_CAIRO) # FLTK_OPTION_CAIRO_WINDOW or FLTK_OPTION_CAIRO_EXT
list(APPEND CPPFILES Fl_Cairo.cxx) list(APPEND CPPFILES Fl_Cairo.cxx)
endif() endif()
@ -191,19 +205,18 @@ list (APPEND HEADER_FILES
set(GL_HEADER_FILES) # FIXME: not (yet?) defined set(GL_HEADER_FILES) # FIXME: not (yet?) defined
if (FLTK_USE_X11 AND NOT OPTION_PRINT_SUPPORT) if(FLTK_USE_X11 AND NOT FLTK_OPTION_PRINT_SUPPORT)
set (PSFILES set(PSFILES)
)
else() else()
set(PSFILES set(PSFILES
drivers/PostScript/Fl_PostScript.cxx drivers/PostScript/Fl_PostScript.cxx
drivers/PostScript/Fl_PostScript_image.cxx drivers/PostScript/Fl_PostScript_image.cxx
) )
endif (FLTK_USE_X11 AND NOT OPTION_PRINT_SUPPORT) endif(FLTK_USE_X11 AND NOT FLTK_OPTION_PRINT_SUPPORT)
set(DRIVER_FILES) set(DRIVER_FILES)
if (FLTK_USE_X11 AND NOT OPTION_USE_WAYLAND) if(FLTK_USE_X11 AND NOT FLTK_BACKEND_WAYLAND)
# X11 (including APPLE with X11) # X11 (including APPLE with X11)
@ -224,30 +237,31 @@ if (FLTK_USE_X11 AND NOT OPTION_USE_WAYLAND)
Fl_get_key.cxx Fl_get_key.cxx
) )
if (OPTION_USE_KDIALOG) if(FLTK_USE_KDIALOG)
set (DRIVER_FILES ${DRIVER_FILES} Fl_Native_File_Chooser_Kdialog.cxx list(APPEND DRIVER_FILES
Fl_Native_File_Chooser_Kdialog.cxx
Fl_Native_File_Chooser_Zenity.cxx) Fl_Native_File_Chooser_Zenity.cxx)
endif (OPTION_USE_KDIALOG) endif(FLTK_USE_KDIALOG)
if(FLTK_USE_CAIRO) if(FLTK_USE_CAIRO)
set (DRIVER_FILES ${DRIVER_FILES} list(APPEND DRIVER_FILES
drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.cxx drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.cxx
) )
else() else()
if(USE_XFT) if(USE_XFT)
set (DRIVER_FILES ${DRIVER_FILES} list(APPEND DRIVER_FILES
drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx
) )
if(USE_PANGO) if(USE_PANGO)
set (DRIVER_FILES ${DRIVER_FILES} drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx) list(APPEND DRIVER_FILES drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx)
endif(USE_PANGO) endif(USE_PANGO)
else() else()
set (DRIVER_FILES ${DRIVER_FILES} list(APPEND DRIVER_FILES
drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
) )
endif(USE_XFT) endif(USE_XFT)
set (DRIVER_FILES ${DRIVER_FILES} list(APPEND DRIVER_FILES
drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx
drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx
@ -279,7 +293,7 @@ if (FLTK_USE_X11 AND NOT OPTION_USE_WAYLAND)
) )
endif(FLTK_USE_CAIRO) endif(FLTK_USE_CAIRO)
elseif (OPTION_USE_WAYLAND) elseif(FLTK_BACKEND_WAYLAND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${CMAKE_CURRENT_BINARY_DIR}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${CMAKE_CURRENT_BINARY_DIR}")
set(DRIVER_FILES set(DRIVER_FILES
drivers/Posix/Fl_Posix_System_Driver.cxx drivers/Posix/Fl_Posix_System_Driver.cxx
@ -297,10 +311,13 @@ elseif (OPTION_USE_WAYLAND)
Fl_Native_File_Chooser_FLTK.cxx Fl_Native_File_Chooser_FLTK.cxx
Fl_Native_File_Chooser_GTK.cxx Fl_Native_File_Chooser_GTK.cxx
) )
if (OPTION_USE_KDIALOG)
set (DRIVER_FILES ${DRIVER_FILES} Fl_Native_File_Chooser_Kdialog.cxx if(FLTK_USE_KDIALOG)
list(APPEND DRIVER_FILES
Fl_Native_File_Chooser_Kdialog.cxx
Fl_Native_File_Chooser_Zenity.cxx) Fl_Native_File_Chooser_Zenity.cxx)
endif (OPTION_USE_KDIALOG) endif(FLTK_USE_KDIALOG)
if(FLTK_USE_X11) if(FLTK_USE_X11)
list(APPEND DRIVER_FILES list(APPEND DRIVER_FILES
drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.cxx drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.cxx
@ -313,6 +330,7 @@ elseif (OPTION_USE_WAYLAND)
Fl_get_key.cxx Fl_get_key.cxx
) )
endif(FLTK_USE_X11) endif(FLTK_USE_X11)
set(DRIVER_HEADER_FILES set(DRIVER_HEADER_FILES
drivers/Posix/Fl_Posix_System_Driver.H drivers/Posix/Fl_Posix_System_Driver.H
drivers/Wayland/Fl_Wayland_Screen_Driver.H drivers/Wayland/Fl_Wayland_Screen_Driver.H
@ -394,7 +412,7 @@ else ()
drivers/GDI/Fl_GDI_Image_Surface_Driver.H drivers/GDI/Fl_GDI_Image_Surface_Driver.H
) )
endif (FLTK_USE_X11 AND NOT OPTION_USE_WAYLAND) endif(FLTK_USE_X11 AND NOT FLTK_BACKEND_WAYLAND)
source_group("Header Files" FILES ${HEADER_FILES}) source_group("Header Files" FILES ${HEADER_FILES})
source_group("Driver Source Files" FILES ${DRIVER_FILES}) source_group("Driver Source Files" FILES ${DRIVER_FILES})
@ -444,7 +462,7 @@ set (GL_DRIVER_FILES
drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx
drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx
) )
if (OPTION_USE_WAYLAND) if(FLTK_BACKEND_WAYLAND)
set(GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx) set(GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx)
set(GL_DRIVER_HEADER_FILES drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H) set(GL_DRIVER_HEADER_FILES drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H)
if(FLTK_USE_X11) if(FLTK_USE_X11)
@ -460,7 +478,7 @@ elseif (APPLE)
elseif(WIN32) elseif(WIN32)
set(GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx) set(GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx)
set(GL_DRIVER_HEADER_FILES drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H) set(GL_DRIVER_HEADER_FILES drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H)
endif (OPTION_USE_WAYLAND) endif(FLTK_BACKEND_WAYLAND)
set(GL_DRIVER_HEADER_FILES ${GL_DRIVER_FILES} set(GL_DRIVER_HEADER_FILES ${GL_DRIVER_FILES}
drivers/OpenGL/Fl_OpenGL_Display_Device.H drivers/OpenGL/Fl_OpenGL_Display_Device.H
@ -515,7 +533,7 @@ if (FLTK_USE_X11)
endif(NOT USE_XFT) endif(NOT USE_XFT)
endif(FLTK_USE_X11) endif(FLTK_USE_X11)
if (OPTION_USE_WAYLAND) if(FLTK_BACKEND_WAYLAND)
pkg_check_modules(DBUS dbus-1) pkg_check_modules(DBUS dbus-1)
set(IDIRS "${CMAKE_CURRENT_BINARY_DIR}") set(IDIRS "${CMAKE_CURRENT_BINARY_DIR}")
set(CDEFS "_GNU_SOURCE;HAVE_MEMFD_CREATE;HAVE_MKOSTEMP;HAVE_POSIX_FALLOCATE") set(CDEFS "_GNU_SOURCE;HAVE_MEMFD_CREATE;HAVE_MKOSTEMP;HAVE_POSIX_FALLOCATE")
@ -524,38 +542,38 @@ if (OPTION_USE_WAYLAND)
set(CDEFS "${CDEFS};HAS_DBUS") set(CDEFS "${CDEFS};HAS_DBUS")
set(IDIRS "${IDIRS};${DBUS_INCLUDE_DIRS}") set(IDIRS "${IDIRS};${DBUS_INCLUDE_DIRS}")
endif(DBUS_FOUND) endif(DBUS_FOUND)
if (OPTION_USE_SYSTEM_LIBDECOR) if(USE_SYSTEM_LIBDECOR)
set(CDEFS "${CDEFS};USE_SYSTEM_LIBDECOR;LIBDECOR_PLUGIN_DIR=${LIBDECOR_PLUGIN_DIR}") set(CDEFS "${CDEFS};USE_SYSTEM_LIBDECOR;LIBDECOR_PLUGIN_DIR=${LIBDECOR_PLUGIN_DIR}")
if(GTK_FOUND) if(GTK_FOUND)
set(CDEFS "${CDEFS};HAVE_GTK") set(CDEFS "${CDEFS};HAVE_GTK")
endif(GTK_FOUND) endif(GTK_FOUND)
set_source_files_properties( set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/fl_libdecor-plugins.c ${FLTK_SOURCE_DIR}/libdecor/build/fl_libdecor-plugins.c
${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src/os-compatibility.c ${FLTK_SOURCE_DIR}/libdecor/src/os-compatibility.c
${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src/cursor-settings.c ${FLTK_SOURCE_DIR}/libdecor/src/cursor-settings.c
PROPERTIES COMPILE_DEFINITIONS "${CDEFS}" PROPERTIES COMPILE_DEFINITIONS "${CDEFS}"
INCLUDE_DIRECTORIES "${IDIRS}" INCLUDE_DIRECTORIES "${IDIRS}"
COMPILE_OPTIONS "${COPTS}" COMPILE_OPTIONS "${COPTS}"
) )
else() else()
set (IDIRS "${IDIRS};${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src" set(IDIRS "${IDIRS};${FLTK_SOURCE_DIR}/libdecor/src"
"${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src/plugins") "${FLTK_SOURCE_DIR}/libdecor/src/plugins")
set(CDEFS "${CDEFS};USE_SYSTEM_LIBDECOR=0;LIBDECOR_PLUGIN_API_VERSION=1" set(CDEFS "${CDEFS};USE_SYSTEM_LIBDECOR=0;LIBDECOR_PLUGIN_API_VERSION=1"
"LIBDECOR_PLUGIN_DIR=\"\"") "LIBDECOR_PLUGIN_DIR=\"\"")
if (GTK_FOUND AND OPTION_ALLOW_GTK_PLUGIN) if(GTK_FOUND AND FLTK_USE_LIBDECOR_GTK)
set(CDEFS "${CDEFS};HAVE_GTK") set(CDEFS "${CDEFS};HAVE_GTK")
endif (GTK_FOUND AND OPTION_ALLOW_GTK_PLUGIN) endif(GTK_FOUND AND FLTK_USE_LIBDECOR_GTK)
set_source_files_properties( set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/fl_libdecor.c ${FLTK_SOURCE_DIR}/libdecor/build/fl_libdecor.c
${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/fl_libdecor-plugins.c ${FLTK_SOURCE_DIR}/libdecor/build/fl_libdecor-plugins.c
${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src/os-compatibility.c ${FLTK_SOURCE_DIR}/libdecor/src/os-compatibility.c
${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src/cursor-settings.c ${FLTK_SOURCE_DIR}/libdecor/src/cursor-settings.c
PROPERTIES PROPERTIES
COMPILE_DEFINITIONS "${CDEFS}" COMPILE_DEFINITIONS "${CDEFS}"
INCLUDE_DIRECTORIES "${IDIRS}" INCLUDE_DIRECTORIES "${IDIRS}"
COMPILE_OPTIONS "${COPTS}" COMPILE_OPTIONS "${COPTS}"
) )
endif (OPTION_USE_SYSTEM_LIBDECOR) endif(USE_SYSTEM_LIBDECOR)
list(APPEND CFILES list(APPEND CFILES
scandir_posix.c scandir_posix.c
@ -566,13 +584,13 @@ if (OPTION_USE_WAYLAND)
if(FLTK_USE_X11) if(FLTK_USE_X11)
list(APPEND CFILES xutf8/keysym2Ucs.c) list(APPEND CFILES xutf8/keysym2Ucs.c)
endif(FLTK_USE_X11) endif(FLTK_USE_X11)
if (NOT OPTION_USE_SYSTEM_LIBDECOR) if(NOT USE_SYSTEM_LIBDECOR)
list(APPEND CFILES list(APPEND CFILES
../libdecor/build/fl_libdecor.c ../libdecor/build/fl_libdecor.c
../libdecor/src/plugins/common/libdecor-cairo-blur.c ../libdecor/src/plugins/common/libdecor-cairo-blur.c
) )
endif (NOT OPTION_USE_SYSTEM_LIBDECOR) endif(NOT USE_SYSTEM_LIBDECOR)
endif (OPTION_USE_WAYLAND) endif(FLTK_BACKEND_WAYLAND)
if(WIN32) if(WIN32)
list(APPEND CFILES list(APPEND CFILES
@ -580,7 +598,7 @@ if (WIN32)
) )
endif(WIN32) endif(WIN32)
if (APPLE AND (NOT OPTION_APPLE_X11)) if(APPLE AND NOT FLTK_BACKEND_X11)
set(MMFILES set(MMFILES
Fl_cocoa.mm Fl_cocoa.mm
drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm
@ -588,9 +606,8 @@ if (APPLE AND (NOT OPTION_APPLE_X11))
Fl_MacOS_Sys_Menu_Bar.mm Fl_MacOS_Sys_Menu_Bar.mm
) )
else() else()
set (MMFILES set(MMFILES)
) endif()
endif (APPLE AND (NOT OPTION_APPLE_X11))
####################################################################### #######################################################################
@ -652,9 +669,9 @@ if (HAVE_XRENDER)
list(APPEND OPTIONAL_LIBS ${X11_Xrender_LIB}) list(APPEND OPTIONAL_LIBS ${X11_Xrender_LIB})
endif(HAVE_XRENDER) endif(HAVE_XRENDER)
if (FLTK_HAVE_CAIRO) # OPTION_CAIRO or OPTION_CAIROEXT ### if(FLTK_HAVE_CAIRO) # FLTK_OPTION_CAIRO_WINDOW or FLTK_OPTION_CAIRO_EXT or Wayland
list (APPEND OPTIONAL_LIBS ${PKG_CAIRO_LIBRARIES}) ### list(APPEND OPTIONAL_LIBS ${PKG_CAIRO_LIBRARIES})
endif() ### endif()
if(USE_PANGO) if(USE_PANGO)
### FIXME ### This needs to use the PKG_* variables directly ### FIXME ### This needs to use the PKG_* variables directly
@ -672,130 +689,136 @@ if (USE_XFT)
endif(LIB_fontconfig) endif(LIB_fontconfig)
endif(USE_XFT) endif(USE_XFT)
if (UNIX AND OPTION_USE_WAYLAND) if(UNIX AND FLTK_BACKEND_WAYLAND)
pkg_get_variable(PROTOCOLS wayland-protocols pkgdatadir) pkg_get_variable(PROTOCOLS wayland-protocols pkgdatadir)
# replace "//" with "/" # replace "//" with "/"
string(REPLACE "//" "/" PROTOCOLS ${PROTOCOLS}) string(REPLACE "//" "/" PROTOCOLS ${PROTOCOLS})
if (NOT(EXISTS ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml))
message(WARNING "Install necessary file ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml") # The following variable is used for finding required files and to terminate
endif () # the build if one or more files are not found. For user convenience
if (NOT(EXISTS ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml)) # the build is terminated after *all* files have been checked.
message(WARNING set(STOP_REQUIRED FALSE)
"Install necessary file ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml")
endif () set(INFILE ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml)
if (NOT(EXISTS ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml)) fl_check_required_file(STOP_REQUIRED ${INFILE})
message(WARNING
"Install necessary file ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml")
endif ()
if (NOT((EXISTS ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml) AND
(EXISTS ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml) AND
(EXISTS ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml)))
message(FATAL_ERROR "*** Terminating: one or more required file(s) missing.")
endif ()
add_custom_command( add_custom_command(
OUTPUT xdg-shell-protocol.c xdg-shell-client-protocol.h OUTPUT xdg-shell-protocol.c xdg-shell-client-protocol.h
COMMAND wayland-scanner private-code ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml xdg-shell-protocol.c COMMAND wayland-scanner private-code ${INFILE} xdg-shell-protocol.c
COMMAND wayland-scanner client-header ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml xdg-shell-client-protocol.h COMMAND wayland-scanner client-header ${INFILE} xdg-shell-client-protocol.h
DEPENDS ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml DEPENDS ${INFILE}
VERBATIM VERBATIM
) )
list(APPEND STATIC_FILES "xdg-shell-protocol.c") list(APPEND STATIC_FILES "xdg-shell-protocol.c")
list(APPEND SHARED_FILES "xdg-shell-protocol.c") list(APPEND SHARED_FILES "xdg-shell-protocol.c")
if (NOT OPTION_USE_SYSTEM_LIBDECOR)
if(NOT USE_SYSTEM_LIBDECOR)
set(INFILE ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml)
fl_check_required_file(STOP_REQUIRED ${INFILE})
add_custom_command( add_custom_command(
OUTPUT xdg-decoration-protocol.c xdg-decoration-client-protocol.h OUTPUT xdg-decoration-protocol.c xdg-decoration-client-protocol.h
COMMAND wayland-scanner private-code ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml xdg-decoration-protocol.c COMMAND wayland-scanner private-code ${INFILE} xdg-decoration-protocol.c
COMMAND wayland-scanner client-header ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml xdg-decoration-client-protocol.h COMMAND wayland-scanner client-header ${INFILE} xdg-decoration-client-protocol.h
DEPENDS ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml DEPENDS ${INFILE}
VERBATIM VERBATIM
) )
list(APPEND STATIC_FILES "xdg-decoration-protocol.c") list(APPEND STATIC_FILES "xdg-decoration-protocol.c")
list(APPEND SHARED_FILES "xdg-decoration-protocol.c") list(APPEND SHARED_FILES "xdg-decoration-protocol.c")
endif (NOT OPTION_USE_SYSTEM_LIBDECOR) endif(NOT USE_SYSTEM_LIBDECOR)
set(INFILE ${FLTK_SOURCE_DIR}/libdecor/build/gtk-shell.xml)
add_custom_command( add_custom_command(
OUTPUT gtk-shell-protocol.c gtk-shell-client-protocol.h OUTPUT gtk-shell-protocol.c gtk-shell-client-protocol.h
COMMAND wayland-scanner private-code ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/gtk-shell.xml gtk-shell-protocol.c COMMAND wayland-scanner private-code ${INFILE} gtk-shell-protocol.c
COMMAND wayland-scanner client-header ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/gtk-shell.xml gtk-shell-client-protocol.h COMMAND wayland-scanner client-header ${INFILE} gtk-shell-client-protocol.h
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/gtk-shell.xml DEPENDS ${INFILE}
VERBATIM VERBATIM
) )
list(APPEND STATIC_FILES "gtk-shell-protocol.c") list(APPEND STATIC_FILES "gtk-shell-protocol.c")
list(APPEND SHARED_FILES "gtk-shell-protocol.c") list(APPEND SHARED_FILES "gtk-shell-protocol.c")
set(INFILE ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml)
fl_check_required_file(STOP_REQUIRED ${INFILE})
add_custom_command( add_custom_command(
OUTPUT text-input-protocol.c text-input-client-protocol.h OUTPUT text-input-protocol.c text-input-client-protocol.h
COMMAND wayland-scanner private-code ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml text-input-protocol.c COMMAND wayland-scanner private-code ${INFILE} text-input-protocol.c
COMMAND wayland-scanner client-header ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml text-input-client-protocol.h COMMAND wayland-scanner client-header ${INFILE} text-input-client-protocol.h
DEPENDS ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml DEPENDS ${INFILE}
VERBATIM VERBATIM
) )
list(APPEND STATIC_FILES "text-input-protocol.c") list(APPEND STATIC_FILES "text-input-protocol.c")
list(APPEND SHARED_FILES "text-input-protocol.c") list(APPEND SHARED_FILES "text-input-protocol.c")
if (OPTION_USE_GL) if(STOP_REQUIRED)
message(FATAL_ERROR "*** Terminating: one or more required file(s) were not found. ***")
endif()
if(FLTK_USE_GL)
list(APPEND OPTIONAL_LIBS "-lwayland-egl -lEGL") list(APPEND OPTIONAL_LIBS "-lwayland-egl -lEGL")
endif (OPTION_USE_GL) endif(FLTK_USE_GL)
if (OPTION_USE_SYSTEM_LIBDECOR) if(USE_SYSTEM_LIBDECOR)
list(APPEND OPTIONAL_LIBS "-ldecor-0") list(APPEND OPTIONAL_LIBS "-ldecor-0")
elseif (GTK_FOUND AND OPTION_ALLOW_GTK_PLUGIN) elseif(GTK_FOUND AND FLTK_USE_LIBDECOR_GTK)
list(APPEND OPTIONAL_LIBS ${GTK_LDFLAGS} ) list(APPEND OPTIONAL_LIBS ${GTK_LDFLAGS} )
endif (OPTION_USE_SYSTEM_LIBDECOR) endif(USE_SYSTEM_LIBDECOR)
list(APPEND OPTIONAL_LIBS "-lwayland-cursor -lwayland-client -lxkbcommon -ldl") list(APPEND OPTIONAL_LIBS "-lwayland-cursor -lwayland-client -lxkbcommon -ldl")
if(DBUS_FOUND) if(DBUS_FOUND)
list(APPEND OPTIONAL_LIBS "${DBUS_LDFLAGS}") list(APPEND OPTIONAL_LIBS "${DBUS_LDFLAGS}")
endif(DBUS_FOUND) endif(DBUS_FOUND)
if (NOT OPTION_WAYLAND_ONLY) if(NOT FLTK_BACKEND_WAYLAND_ONLY)
list(APPEND OPTIONAL_LIBS "-lXcursor -lXrender -lXinerama -lXfixes -lXft -lXext -lX11") list(APPEND OPTIONAL_LIBS "-lXcursor -lXrender -lXinerama -lXfixes -lXft -lXext -lX11")
endif (NOT OPTION_WAYLAND_ONLY) endif(NOT FLTK_BACKEND_WAYLAND_ONLY)
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux" AND NOT OPTION_BUILD_SHARED_LIBS) if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND NOT FLTK_BUILD_SHARED_LIBS)
list(APPEND OPTIONAL_LIBS "-no-pie") list(APPEND OPTIONAL_LIBS "-no-pie")
endif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux" AND NOT OPTION_BUILD_SHARED_LIBS) endif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND NOT FLTK_BUILD_SHARED_LIBS)
endif (UNIX AND OPTION_USE_WAYLAND) endif(UNIX AND FLTK_BACKEND_WAYLAND)
####################################################################### #######################################################################
FL_ADD_LIBRARY (fltk STATIC "${STATIC_FILES}") fl_add_library(fltk STATIC "${STATIC_FILES}")
target_link_libraries (fltk ${OPTIONAL_LIBS}) target_link_libraries(fltk PUBLIC ${OPTIONAL_LIBS})
if (FLTK_HAVE_CAIRO) ### if(FLTK_HAVE_CAIRO OR FLTK_USE_CAIRO)
target_link_directories (fltk PUBLIC ${PKG_CAIRO_LIBRARY_DIRS}) ### target_link_directories(fltk PUBLIC ${PKG_CAIRO_LIBRARY_DIRS})
endif() ### endif()
####################################################################### #######################################################################
if(FLTK_BUILD_FORMS) if(FLTK_BUILD_FORMS)
FL_ADD_LIBRARY (fltk_forms STATIC "${FORMS_FILES}") fl_add_library(fltk_forms STATIC "${FORMS_FILES}")
target_link_libraries (fltk_forms fltk) target_link_libraries(fltk_forms PUBLIC fltk::fltk)
endif() endif()
####################################################################### #######################################################################
FL_ADD_LIBRARY (fltk_images STATIC "${IMGCPPFILES}") if(0)
target_link_libraries (fltk_images fltk) message(STATUS "---------------------- fltk_images -----------------------")
fl_debug_var(FLTK_JPEG_LIBRARIES)
if (FLTK_USE_BUILTIN_JPEG) fl_debug_var(FLTK_PNG_LIBRARIES)
target_link_libraries (fltk_images fltk_jpeg) fl_debug_var(FLTK_ZLIB_LIBRARIES)
else() fl_debug_var(FLTK_IMAGE_LIBRARIES)
target_link_libraries (fltk_images ${FLTK_JPEG_LIBRARIES}) message(STATUS "---------------------- fltk_images -----------------------")
endif() endif()
if (FLTK_USE_BUILTIN_ZLIB) fl_add_library(fltk_images STATIC "${IMGCPPFILES}")
target_link_libraries (fltk_images fltk_z) target_link_libraries(fltk_images PUBLIC fltk::fltk)
else() target_link_libraries(fltk_images PRIVATE ${FLTK_IMAGE_LIBRARIES})
target_link_libraries (fltk_images ${FLTK_ZLIB_LIBRARIES})
endif ()
if (FLTK_USE_BUILTIN_PNG) ### target_link_libraries(fltk_images PUBLIC ${FLTK_JPEG_LIBRARIES})
target_link_libraries (fltk_images fltk_png) ### target_link_libraries(fltk_images PUBLIC ${FLTK_PNG_LIBRARIES})
else() ### target_link_libraries(fltk_images PUBLIC ${FLTK_IMAGE_LIBRARIES})
target_link_libraries (fltk_images ${FLTK_PNG_LIBRARIES})
if(FLTK_USE_BUNDLED_JPEG)
target_include_directories(fltk_images PUBLIC
$<BUILD_INTERFACE:${FLTK_SOURCE_DIR}/jpeg>
$<INSTALL_INTERFACE:include>)
endif() endif()
####################################################################### #######################################################################
if (OPENGL_FOUND) if(FLTK_USE_GL)
FL_ADD_LIBRARY (fltk_gl STATIC "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}") fl_add_library(fltk_gl STATIC "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}")
target_link_libraries (fltk_gl fltk ${OPENGL_LIBRARIES}) target_link_libraries(fltk_gl PUBLIC ${OPENGL_LIBRARIES} fltk::fltk)
endif (OPENGL_FOUND) endif(FLTK_USE_GL)
####################################################################### #######################################################################
# Build shared libraries (optional) # Build shared libraries (optional)
@ -803,92 +826,108 @@ endif (OPENGL_FOUND)
# Shared libraries, part 1: everything except Visual Studio (MSVC) # Shared libraries, part 1: everything except Visual Studio (MSVC)
####################################################################### #######################################################################
if (OPTION_BUILD_SHARED_LIBS AND NOT MSVC) ### fl_debug_var(OPTIONAL_LIBS)
FL_ADD_LIBRARY (fltk SHARED "${SHARED_FILES}") if(FLTK_BUILD_SHARED_LIBS AND NOT MSVC)
target_link_libraries (fltk_SHARED ${OPTIONAL_LIBS} ${PKG_CAIRO_LIBRARIES})
target_link_directories (fltk_SHARED PUBLIC ${PKG_CAIRO_LIBRARY_DIRS}) fl_add_library(fltk SHARED "${SHARED_FILES}")
target_link_libraries(fltk-shared PUBLIC ${OPTIONAL_LIBS})
### if(FLTK_HAVE_CAIRO OR FLTK_USE_CAIRO)
### target_link_directories(fltk-shared PUBLIC ${PKG_CAIRO_LIBRARY_DIRS})
### endif()
################################################################### ###################################################################
if(FLTK_BUILD_FORMS) if(FLTK_BUILD_FORMS)
FL_ADD_LIBRARY (fltk_forms SHARED "${FORMS_FILES}") fl_add_library(fltk_forms SHARED "${FORMS_FILES}")
target_link_libraries (fltk_forms_SHARED fltk_SHARED) target_link_libraries(fltk_forms-shared PUBLIC fltk::fltk-shared)
endif() endif()
################################################################### ###################################################################
FL_ADD_LIBRARY (fltk_images SHARED "${IMGCPPFILES}") ### fl_debug_var(fltk_images)
target_link_libraries (fltk_images_SHARED fltk_SHARED) ### fl_debug_var(FLTK_JPEG_LIBRARIES)
### fl_debug_var(FLTK_PNG_LIBRARIES)
### fl_debug_var(FLTK_ZLIB_LIBRARIES)
### fl_debug_var(FLTK_IMAGE_LIBRARIES)
if (FLTK_USE_BUILTIN_JPEG) fl_add_library(fltk_images SHARED "${IMGCPPFILES}")
target_link_libraries (fltk_images_SHARED fltk_jpeg_SHARED) target_link_libraries(fltk_images-shared PUBLIC fltk::fltk-shared)
else()
target_link_libraries (fltk_images_SHARED ${FLTK_JPEG_LIBRARIES}) target_link_libraries(fltk_images PUBLIC ${FLTK_JPEG_LIBRARIES})
target_link_libraries(fltk_images PUBLIC ${FLTK_PNG_LIBRARIES})
target_link_libraries(fltk_images PUBLIC ${FLTK_IMAGE_LIBRARIES})
if(FLTK_USE_BUNDLED_JPEG)
## include_directories(${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(fltk_images-shared PUBLIC
$<BUILD_INTERFACE:${FLTK_SOURCE_DIR}/jpeg>
# $<INSTALL_INTERFACE:include>
)
endif() endif()
if (FLTK_USE_BUILTIN_PNG) if(FLTK_USE_BUNDLED_JPEG)
target_link_libraries (fltk_images_SHARED fltk_png_SHARED) target_link_libraries(fltk_images-shared PUBLIC fltk::jpeg-shared)
else() else()
target_link_libraries (fltk_images_SHARED ${FLTK_PNG_LIBRARIES}) target_link_libraries(fltk_images-shared PUBLIC ${JPEG_LIBRARIES})
endif() endif()
if (FLTK_USE_BUILTIN_ZLIB) if(FLTK_USE_BUNDLED_PNG)
target_link_libraries (fltk_images_SHARED fltk_z_SHARED) target_link_libraries(fltk_images-shared PUBLIC fltk::png-shared)
else() else()
target_link_libraries (fltk_images_SHARED ${FLTK_ZLIB_LIBRARIES}) target_link_libraries(fltk_images-shared PUBLIC ${PNG_LIBRARIES})
endif() endif()
################################################################### ###################################################################
if (OPENGL_FOUND) if(FLTK_USE_GL)
FL_ADD_LIBRARY (fltk_gl SHARED "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}") fl_add_library(fltk_gl SHARED "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}")
target_link_libraries (fltk_gl_SHARED fltk_SHARED ${OPENGL_LIBRARIES}) target_link_libraries(fltk_gl-shared PUBLIC ${OPENGL_LIBRARIES} fltk::fltk-shared)
endif (OPENGL_FOUND) endif(FLTK_USE_GL)
endif (OPTION_BUILD_SHARED_LIBS AND NOT MSVC) endif(FLTK_BUILD_SHARED_LIBS AND NOT MSVC)
####################################################################### #######################################################################
# Shared libraries, part 2: Visual Studio (MSVC) # Shared libraries, part 2: Visual Studio (MSVC)
####################################################################### #######################################################################
# Note to devs: As of June 2020 we can't build separate shared libs (DLL's) # Note to devs: As of June 2020 we can't build separate shared libs
# under Windows with Visual Studio (MSVC) but we can build one big DLL # (DLL's) under Windows with Visual Studio (MSVC) but we can build one
# that comprises all FLTK and optional PNG, JPEG, and ZLIB libs. # big DLL that comprises all FLTK and optional PNG, JPEG, and ZLIB libs.
# The reason is the common DLL linkage (FL_EXPORT) for all libs. This
# might be changed in the future but it would require a lot of work.
# AlbrechtS # AlbrechtS
if (OPTION_BUILD_SHARED_LIBS AND MSVC) if(FLTK_BUILD_SHARED_LIBS AND MSVC)
set(SOURCES ${SHARED_FILES} ${FORMS_FILES} ${IMGCPPFILES}) set(SOURCES ${SHARED_FILES} ${FORMS_FILES} ${IMGCPPFILES})
if(OPENGL_FOUND) if(OPENGL_FOUND)
list(APPEND SOURCES ${GLCPPFILES} ${GL_HEADER_FILES} ${GL_DRIVER_HEADER_FILES}) list(APPEND SOURCES ${GLCPPFILES} ${GL_HEADER_FILES} ${GL_DRIVER_HEADER_FILES})
endif(OPENGL_FOUND) endif(OPENGL_FOUND)
FL_ADD_LIBRARY (fltk SHARED "${SOURCES}") fl_add_library(fltk SHARED "${SOURCES}")
target_link_libraries (fltk_SHARED ${OPTIONAL_LIBS}) target_link_libraries(fltk-shared PUBLIC ${OPTIONAL_LIBS})
if (FLTK_USE_BUILTIN_JPEG) if(FLTK_USE_BUNDLED_JPEG)
target_link_libraries (fltk_SHARED fltk_jpeg) target_link_libraries(fltk-shared PUBLIC fltk::jpeg-shared)
else() else()
target_link_libraries (fltk_SHARED ${FLTK_JPEG_LIBRARIES}) target_link_libraries(fltk-shared PUBLIC ${FLTK_JPEG_LIBRARIES})
endif() endif()
if (FLTK_USE_BUILTIN_PNG) if(FLTK_USE_BUNDLED_PNG)
target_link_libraries (fltk_SHARED fltk_png) target_link_libraries(fltk-shared PUBLIC fltk::png-shared)
else() else()
target_link_libraries (fltk_SHARED ${FLTK_PNG_LIBRARIES}) target_link_libraries(fltk-shared PUBLIC ${FLTK_PNG_LIBRARIES})
endif ()
if (FLTK_USE_BUILTIN_ZLIB)
target_link_libraries (fltk_SHARED fltk_z)
else()
target_link_libraries (fltk_SHARED ${FLTK_ZLIB_LIBRARIES})
endif() endif()
if(OPENGL_FOUND) if(OPENGL_FOUND)
target_link_libraries (fltk_SHARED ${OPENGL_LIBRARIES}) target_link_libraries(fltk-shared PUBLIC ${OPENGL_LIBRARIES})
endif(OPENGL_FOUND) endif(OPENGL_FOUND)
endif (OPTION_BUILD_SHARED_LIBS AND MSVC) endif(FLTK_BUILD_SHARED_LIBS AND MSVC)
####################################################################### #######################################################################
set(FLTK_LIBRARIES ${FLTK_LIBRARIES} PARENT_SCOPE)
set(FLTK_LIBRARIES_SHARED ${FLTK_LIBRARIES_SHARED} PARENT_SCOPE)

View File

@ -1,7 +1,7 @@
// //
// Special Cairo support for the Fast Light Tool Kit (FLTK). // Special Cairo support for the Fast Light Tool Kit (FLTK).
// //
// Copyright 1998-2023 by Bill Spitzak and others. // Copyright 1998-2024 by Bill Spitzak and others.
// //
// This library is free software. Distribution and use rights are outlined in // 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 // the file "COPYING" which should have been included with this file. If this
@ -14,13 +14,14 @@
// https://www.fltk.org/bugs.php // https://www.fltk.org/bugs.php
// //
// This file implements the FLTK Cairo support (since 1.3.x): // This file implements the FLTK Cairo Window support (since 1.3.x):
// //
// - ./configure --enable-cairo and/or --enable-cairoext // - ./configure --enable-cairo and/or --enable-cairoext
// - cmake -DOPTION_CAIRO and/or -DOPTION_CAIROEXT // - cmake -D FLTK_OPTION_CAIRO_WINDOW and/or -D FLTK_OPTION_CAIRO_EXT
// //
// Preprocessor macro FLTK_HAVE_CAIRO is defined for both options. // Preprocessor macro FLTK_HAVE_CAIRO is defined for both options.
// Preprocessor macro FLTK_HAVE_CAIRO_EXT is defined only for "cairoext" // Preprocessor macro FLTK_HAVE_CAIRO_EXT is defined only for "cairoext".
// Both macros are defined in 'FL/fl_config.h'.
#include <FL/Fl.H> // includes <FL/fl_config.h> #include <FL/Fl.H> // includes <FL/fl_config.h>
@ -69,7 +70,7 @@ void Fl_Cairo_State::autolink(bool b) {
autolink_ = b; autolink_ = b;
#else #else
Fl::fatal("In Fl::autolink(bool): Cairo autolink() feature is only " Fl::fatal("In Fl::autolink(bool): Cairo autolink() feature is only "
"available with CMake OPTION_CAIROEXT " "available with CMake FLTK_OPTION_CAIRO_EXT "
"or the enable-cairoext configure option.\n" "or the enable-cairoext configure option.\n"
"Quitting now."); "Quitting now.");
#endif #endif
@ -167,7 +168,7 @@ static cairo_surface_t *cairo_create_surface(void *gc, int W, int H) {
Creates a Cairo context from a \a gc only, gets its window size or Creates a Cairo context from a \a gc only, gets its window size or
offscreen size if fl_window is null. offscreen size if fl_window is null.
\note Only available if CMake OPTION_CAIRO is enabled \note Only available if CMake FLTK_OPTION_CAIRO_WINDOW is enabled
or configure has the --enable-cairo option. or configure has the --enable-cairo option.
*/ */
cairo_t *Fl::cairo_make_current(void *gc) { cairo_t *Fl::cairo_make_current(void *gc) {
@ -210,7 +211,7 @@ cairo_t *Fl::cairo_make_current(void *gc) {
/** /**
Creates a Cairo context from a \p gc and the given size. Creates a Cairo context from a \p gc and the given size.
\note Only available if CMake OPTION_CAIRO is enabled \note Only available if CMake FLTK_OPTION_CAIRO_WINDOW is enabled
or configure has the --enable-cairo option. or configure has the --enable-cairo option.
*/ */
cairo_t *Fl::cairo_make_current(void *gc, int W, int H) { cairo_t *Fl::cairo_make_current(void *gc, int W, int H) {

View File

@ -40,7 +40,7 @@
backwards compatibility with FLTK 1.3.x and earlier. backwards compatibility with FLTK 1.3.x and earlier.
\note The documentation is only visible if the CMake option \note The documentation is only visible if the CMake option
\c 'OPTION_INCLUDE_DRIVER_DOCUMENTATION' is enabled. \c 'FLTK_INCLUDE_DRIVER_DOCS' is enabled.
*/ */
#include <FL/Fl.H> #include <FL/Fl.H>

View File

@ -22,7 +22,7 @@
// EXPERIMENTAL // EXPERIMENTAL
// We use either std::vector or the private class Fl_Int_Vector // We use either std::vector or the private class Fl_Int_Vector
// depending on the build option OPTION_USE_STD or equivalent. // depending on the build option FLTK_OPTION_STD or equivalent.
// This option allows to use std::string and maybe std::vector // This option allows to use std::string and maybe std::vector
// already in FLTK 1.4.x // already in FLTK 1.4.x

View File

@ -1,7 +1,7 @@
# #
# CMakeLists.txt used to build test and demo apps by the CMake build system # CMakeLists.txt used to build test and demo apps by the CMake build system
# #
# Copyright 2004-2021 by Bill Spitzak and others. # Copyright 2004-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -26,6 +26,15 @@ set (TESTFILE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../data)
file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
file(MAKE_DIRECTORY ${TESTFILE_PATH}) file(MAKE_DIRECTORY ${TESTFILE_PATH})
#######################################################################
# Define additional example programs for testing, for instance:
# set(extra_tests issue-276 str-1895)
# Use the source file test/'name'.cxx for each additional program.
# These test programs will be built with image and GL libraries.
# Leave the variable 'extra_tests' empty to disable extra test programs.
set(extra_tests)
####################################################################### #######################################################################
# audio libs for test apps # audio libs for test apps
if(WIN32) if(WIN32)
@ -40,21 +49,6 @@ elseif (HAVE_ALSA_ASOUNDLIB_H)
mark_as_advanced (LIB_asound) mark_as_advanced (LIB_asound)
endif(WIN32) endif(WIN32)
#######################################################################
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
#######################################################################
# Define additional example programs for testing, for instance:
# set (extra_tests issue-276 str-1895)
# Use the source file test/'name'.cxx for each additional program.
# These test programs will be built with image and GL libraries.
# Leave the variable 'extra_tests' empty to disable extra test programs.
set (extra_tests)
####################################################################### #######################################################################
# Define standard libraries for those OpenGL demos that can be built # Define standard libraries for those OpenGL demos that can be built
# w/o OpenGL as well. These demos show an alternate GUI or a warning # w/o OpenGL as well. These demos show an alternate GUI or a warning
@ -64,118 +58,118 @@ set (extra_tests)
# or "${GLDEMO_SHARED}" to build with shared FLTK libraries # or "${GLDEMO_SHARED}" to build with shared FLTK libraries
if(OPENGL_FOUND) if(OPENGL_FOUND)
set (GLDEMO_LIBS fltk_gl fltk ${OPENGL_LIBRARIES}) set(GLDEMO_LIBS fltk::gl)
if(MSVC) if(MSVC)
set (GLDEMO_SHARED fltk_SHARED ${OPENGL_LIBRARIES}) set(GLDEMO_SHARED fltk::fltk-shared)
else() else()
set (GLDEMO_SHARED fltk_gl_SHARED fltk_SHARED ${OPENGL_LIBRARIES}) set(GLDEMO_SHARED fltk::gl-shared)
endif() endif()
else() else()
set (GLDEMO_LIBS fltk) set(GLDEMO_LIBS fltk::fltk)
set (GLDEMO_SHARED fltk_SHARED) set(GLDEMO_SHARED fltk::fltk-shared)
endif() endif()
# Similar approach for the 'forms' demo (shared lib not supported) # Similar approach for the 'forms' demo (shared lib not supported)
if(FLTK_BUILD_FORMS) if(FLTK_BUILD_FORMS)
set (FORMS_LIBS fltk_forms) # implies 'fltk' as well set(FORMS_LIBS fltk::forms)
else() else()
set (FORMS_LIBS fltk) set(FORMS_LIBS fltk::fltk)
endif() endif()
####################################################################### #######################################################################
CREATE_EXAMPLE (adjuster adjuster.cxx fltk) fl_create_example(adjuster adjuster.cxx fltk::fltk)
CREATE_EXAMPLE (arc arc.cxx fltk) fl_create_example(arc arc.cxx fltk::fltk)
CREATE_EXAMPLE (animated animated.cxx fltk) fl_create_example(animated animated.cxx fltk::fltk)
CREATE_EXAMPLE (ask ask.cxx fltk) fl_create_example(ask ask.cxx fltk::fltk)
CREATE_EXAMPLE (bitmap bitmap.cxx fltk) fl_create_example(bitmap bitmap.cxx fltk::fltk)
CREATE_EXAMPLE (blocks "blocks.cxx;blocks.plist;blocks.icns" "fltk;${AUDIOLIBS}") fl_create_example(blocks "blocks.cxx;blocks.plist;blocks.icns" "fltk::fltk;${AUDIOLIBS}")
CREATE_EXAMPLE (boxtype boxtype.cxx fltk) fl_create_example(boxtype boxtype.cxx fltk::fltk)
CREATE_EXAMPLE (browser browser.cxx fltk) fl_create_example(browser browser.cxx fltk::fltk)
CREATE_EXAMPLE (button button.cxx fltk) fl_create_example(button button.cxx fltk::fltk)
CREATE_EXAMPLE (buttons buttons.cxx fltk) fl_create_example(buttons buttons.cxx fltk::fltk)
CREATE_EXAMPLE (checkers "checkers.cxx;checkers_pieces.fl;checkers.icns" "fltk_images;fltk") fl_create_example(checkers "checkers.cxx;checkers_pieces.fl;checkers.icns" fltk::images)
CREATE_EXAMPLE (clipboard clipboard.cxx "fltk_images;fltk") fl_create_example(clipboard clipboard.cxx fltk::images)
CREATE_EXAMPLE (clock clock.cxx fltk) fl_create_example(clock clock.cxx fltk::fltk)
CREATE_EXAMPLE (colbrowser colbrowser.cxx fltk) fl_create_example(colbrowser colbrowser.cxx fltk::fltk)
CREATE_EXAMPLE (color_chooser color_chooser.cxx fltk) fl_create_example(color_chooser color_chooser.cxx fltk::fltk)
CREATE_EXAMPLE (contrast contrast.cxx fltk) fl_create_example(contrast contrast.cxx fltk::fltk)
CREATE_EXAMPLE (coordinates coordinates.cxx fltk) fl_create_example(coordinates coordinates.cxx fltk::fltk)
CREATE_EXAMPLE (cursor cursor.cxx fltk) fl_create_example(cursor cursor.cxx fltk::fltk)
CREATE_EXAMPLE (curve curve.cxx fltk) fl_create_example(curve curve.cxx fltk::fltk)
CREATE_EXAMPLE (demo demo.cxx fltk) fl_create_example(demo demo.cxx fltk::fltk)
CREATE_EXAMPLE (device device.cxx "fltk_images;fltk") fl_create_example(device device.cxx fltk::images)
CREATE_EXAMPLE (doublebuffer doublebuffer.cxx fltk) fl_create_example(doublebuffer doublebuffer.cxx fltk::fltk)
CREATE_EXAMPLE (editor "editor.cxx;editor.plist" fltk) fl_create_example(editor "editor.cxx;editor.plist" fltk::fltk)
CREATE_EXAMPLE (fast_slow fast_slow.fl fltk) fl_create_example(fast_slow fast_slow.fl fltk::fltk)
CREATE_EXAMPLE (file_chooser file_chooser.cxx "fltk_images;fltk") fl_create_example(file_chooser file_chooser.cxx fltk::images)
CREATE_EXAMPLE (flex_demo flex_demo.cxx fltk) fl_create_example(flex_demo flex_demo.cxx fltk::fltk)
CREATE_EXAMPLE (flex_login flex_login.cxx fltk) fl_create_example(flex_login flex_login.cxx fltk::fltk)
CREATE_EXAMPLE (fltk-versions fltk-versions.cxx fltk) fl_create_example(fltk-versions fltk-versions.cxx fltk::fltk)
CREATE_EXAMPLE (fonts fonts.cxx fltk) fl_create_example(fonts fonts.cxx fltk::fltk)
CREATE_EXAMPLE (forms forms.cxx "${FORMS_LIBS}") fl_create_example(forms forms.cxx "${FORMS_LIBS}")
CREATE_EXAMPLE (fullscreen fullscreen.cxx "${GLDEMO_LIBS}") fl_create_example(fullscreen fullscreen.cxx "${GLDEMO_LIBS}")
CREATE_EXAMPLE (grid_alignment grid_alignment.cxx fltk) fl_create_example(grid_alignment grid_alignment.cxx fltk::fltk)
CREATE_EXAMPLE (grid_buttons grid_buttons.cxx fltk) fl_create_example(grid_buttons grid_buttons.cxx fltk::fltk)
CREATE_EXAMPLE (grid_dialog grid_dialog.cxx fltk) fl_create_example(grid_dialog grid_dialog.cxx fltk::fltk)
CREATE_EXAMPLE (grid_login grid_login.cxx fltk) fl_create_example(grid_login grid_login.cxx fltk::fltk)
CREATE_EXAMPLE (handle_events handle_events.cxx "${GLDEMO_LIBS}") fl_create_example(handle_events handle_events.cxx "${GLDEMO_LIBS}")
CREATE_EXAMPLE (hello hello.cxx fltk) fl_create_example(hello hello.cxx fltk::fltk)
CREATE_EXAMPLE (help_dialog help_dialog.cxx "fltk_images;fltk") fl_create_example(help_dialog help_dialog.cxx fltk::images)
CREATE_EXAMPLE (icon icon.cxx fltk) fl_create_example(icon icon.cxx fltk::fltk)
CREATE_EXAMPLE (iconize iconize.cxx fltk) fl_create_example(iconize iconize.cxx fltk::fltk)
CREATE_EXAMPLE (image image.cxx fltk) fl_create_example(image image.cxx fltk::fltk)
CREATE_EXAMPLE (inactive inactive.fl fltk) fl_create_example(inactive inactive.fl fltk::fltk)
CREATE_EXAMPLE (input input.cxx fltk) fl_create_example(input input.cxx fltk::fltk)
CREATE_EXAMPLE (input_choice input_choice.cxx fltk) fl_create_example(input_choice input_choice.cxx fltk::fltk)
CREATE_EXAMPLE (keyboard "keyboard.cxx;keyboard_ui.fl" fltk) fl_create_example(keyboard "keyboard.cxx;keyboard_ui.fl" fltk::fltk)
CREATE_EXAMPLE (label label.cxx fltk) fl_create_example(label label.cxx fltk::fltk)
CREATE_EXAMPLE (line_style line_style.cxx fltk) fl_create_example(line_style line_style.cxx fltk::fltk)
CREATE_EXAMPLE (list_visuals list_visuals.cxx fltk) fl_create_example(list_visuals list_visuals.cxx fltk::fltk)
CREATE_EXAMPLE (mandelbrot "mandelbrot_ui.fl;mandelbrot.cxx" fltk) fl_create_example(mandelbrot "mandelbrot_ui.fl;mandelbrot.cxx" fltk::fltk)
CREATE_EXAMPLE (menubar menubar.cxx fltk) fl_create_example(menubar menubar.cxx fltk::fltk)
CREATE_EXAMPLE (message message.cxx fltk) fl_create_example(message message.cxx fltk::fltk)
CREATE_EXAMPLE (minimum minimum.cxx fltk) fl_create_example(minimum minimum.cxx fltk::fltk)
CREATE_EXAMPLE (native-filechooser native-filechooser.cxx "fltk_images;fltk") fl_create_example(native-filechooser native-filechooser.cxx fltk::images)
CREATE_EXAMPLE (navigation navigation.cxx fltk) fl_create_example(navigation navigation.cxx fltk::fltk)
CREATE_EXAMPLE (output output.cxx fltk) fl_create_example(output output.cxx fltk::fltk)
CREATE_EXAMPLE (overlay overlay.cxx fltk) fl_create_example(overlay overlay.cxx fltk::fltk)
CREATE_EXAMPLE (pack pack.cxx fltk) fl_create_example(pack pack.cxx fltk::fltk)
CREATE_EXAMPLE (pixmap pixmap.cxx "fltk_images;fltk") fl_create_example(pixmap pixmap.cxx fltk::images)
CREATE_EXAMPLE (pixmap_browser pixmap_browser.cxx "fltk_images;fltk") fl_create_example(pixmap_browser pixmap_browser.cxx fltk::images)
CREATE_EXAMPLE (preferences preferences.fl fltk) fl_create_example(preferences preferences.fl fltk::fltk)
CREATE_EXAMPLE (offscreen offscreen.cxx fltk) fl_create_example(offscreen offscreen.cxx fltk::fltk)
CREATE_EXAMPLE (radio radio.fl fltk) fl_create_example(radio radio.fl fltk::fltk)
CREATE_EXAMPLE (resize resize.fl fltk) fl_create_example(resize resize.fl fltk::fltk)
CREATE_EXAMPLE (resizebox resizebox.cxx fltk) fl_create_example(resizebox resizebox.cxx fltk::fltk)
CREATE_EXAMPLE (resize-example1 "resize-example1.cxx;resize-arrows.cxx" fltk) fl_create_example(resize-example1 "resize-example1.cxx;resize-arrows.cxx" fltk::fltk)
CREATE_EXAMPLE (resize-example2 "resize-example2.cxx;resize-arrows.cxx" fltk) fl_create_example(resize-example2 "resize-example2.cxx;resize-arrows.cxx" fltk::fltk)
CREATE_EXAMPLE (resize-example3a "resize-example3a.cxx;resize-arrows.cxx" fltk) fl_create_example(resize-example3a "resize-example3a.cxx;resize-arrows.cxx" fltk::fltk)
CREATE_EXAMPLE (resize-example3b "resize-example3b.cxx;resize-arrows.cxx" fltk) fl_create_example(resize-example3b "resize-example3b.cxx;resize-arrows.cxx" fltk::fltk)
CREATE_EXAMPLE (resize-example3c "resize-example3c.cxx;resize-arrows.cxx" fltk) fl_create_example(resize-example3c "resize-example3c.cxx;resize-arrows.cxx" fltk::fltk)
CREATE_EXAMPLE (resize-example4a "resize-example4a.cxx;resize-arrows.cxx" fltk) fl_create_example(resize-example4a "resize-example4a.cxx;resize-arrows.cxx" fltk::fltk)
CREATE_EXAMPLE (resize-example4b "resize-example4b.cxx;resize-arrows.cxx" fltk) fl_create_example(resize-example4b "resize-example4b.cxx;resize-arrows.cxx" fltk::fltk)
CREATE_EXAMPLE (resize-example5a "resize-example5a.cxx;resize-arrows.cxx" fltk) fl_create_example(resize-example5a "resize-example5a.cxx;resize-arrows.cxx" fltk::fltk)
CREATE_EXAMPLE (resize-example5b "resize-example5b.cxx;resize-arrows.cxx" fltk) fl_create_example(resize-example5b "resize-example5b.cxx;resize-arrows.cxx" fltk::fltk)
CREATE_EXAMPLE (resize-example5c "resize-example5c.cxx;resize-arrows.cxx" fltk) fl_create_example(resize-example5c "resize-example5c.cxx;resize-arrows.cxx" fltk::fltk)
CREATE_EXAMPLE (rotated_text rotated_text.cxx fltk) fl_create_example(rotated_text rotated_text.cxx fltk::fltk)
CREATE_EXAMPLE (scroll scroll.cxx fltk) fl_create_example(scroll scroll.cxx fltk::fltk)
CREATE_EXAMPLE (subwindow subwindow.cxx fltk) fl_create_example(subwindow subwindow.cxx fltk::fltk)
CREATE_EXAMPLE (sudoku "sudoku.cxx;sudoku.plist;sudoku.icns;sudoku.rc" "fltk_images;fltk;${AUDIOLIBS}") fl_create_example(sudoku "sudoku.cxx;sudoku.plist;sudoku.icns;sudoku.rc" "fltk::images;${AUDIOLIBS}")
CREATE_EXAMPLE (symbols symbols.cxx fltk) fl_create_example(symbols symbols.cxx fltk::fltk)
CREATE_EXAMPLE (tabs tabs.fl fltk) fl_create_example(tabs tabs.fl fltk::fltk)
CREATE_EXAMPLE (table table.cxx fltk) fl_create_example(table table.cxx fltk::fltk)
CREATE_EXAMPLE (terminal terminal.fl fltk) fl_create_example(terminal terminal.fl fltk::fltk)
CREATE_EXAMPLE (threads threads.cxx fltk) fl_create_example(threads threads.cxx fltk::fltk)
CREATE_EXAMPLE (tile tile.cxx fltk) fl_create_example(tile tile.cxx fltk::fltk)
CREATE_EXAMPLE (tiled_image tiled_image.cxx fltk) fl_create_example(tiled_image tiled_image.cxx fltk::fltk)
CREATE_EXAMPLE (tree tree.fl fltk) fl_create_example(tree tree.fl fltk::fltk)
CREATE_EXAMPLE (twowin twowin.cxx fltk) fl_create_example(twowin twowin.cxx fltk::fltk)
CREATE_EXAMPLE (utf8 utf8.cxx fltk) fl_create_example(utf8 utf8.cxx fltk::fltk)
CREATE_EXAMPLE (valuators valuators.fl fltk) fl_create_example(valuators valuators.fl fltk::fltk)
CREATE_EXAMPLE (windowfocus windowfocus.cxx fltk) fl_create_example(windowfocus windowfocus.cxx fltk::fltk)
CREATE_EXAMPLE (wizard wizard.cxx fltk) fl_create_example(wizard wizard.cxx fltk::fltk)
# unittests uses multiple source files and can be built with or w/o OpenGL and "shared" # unittests uses multiple source files and can be built with or w/o OpenGL and "shared"
@ -197,41 +191,41 @@ SET (UNITTEST_SRCS
unittest_schemes.cxx unittest_schemes.cxx
unittest_terminal.cxx unittest_terminal.cxx
) )
CREATE_EXAMPLE (unittests "${UNITTEST_SRCS}" "${GLDEMO_LIBS}") fl_create_example(unittests "${UNITTEST_SRCS}" "${GLDEMO_LIBS}")
# Create additional test programs (used by developers for testing) # Create additional test programs (used by developers for testing)
if(extra_tests) if(extra_tests)
foreach(name ${extra_tests}) foreach(name ${extra_tests})
create_example (${name} ${name}.cxx "fltk_images;${GLDEMO_LIBS}") fl_create_example(${name} ${name}.cxx "fltk::images;${GLDEMO_LIBS}")
endforeach() endforeach()
endif() endif()
# OpenGL demos. These programs can't be built w/o OpenGL # OpenGL demos. These programs can't be built w/o OpenGL
if(OPENGL_FOUND) if(OPENGL_FOUND)
CREATE_EXAMPLE (CubeView "CubeMain.cxx;CubeView.cxx;CubeViewUI.fl" "${GLDEMO_LIBS}") fl_create_example(CubeView "CubeMain.cxx;CubeView.cxx;CubeViewUI.fl" "${GLDEMO_LIBS}")
CREATE_EXAMPLE (cube cube.cxx "${GLDEMO_LIBS}") fl_create_example(cube cube.cxx "${GLDEMO_LIBS}")
CREATE_EXAMPLE (fractals "fractals.cxx;fracviewer.cxx" "${GLDEMO_LIBS}") fl_create_example(fractals "fractals.cxx;fracviewer.cxx" "${GLDEMO_LIBS}")
CREATE_EXAMPLE (glut_test glut_test.cxx "${GLDEMO_LIBS}") fl_create_example(glut_test glut_test.cxx "${GLDEMO_LIBS}")
CREATE_EXAMPLE (glpuzzle glpuzzle.cxx "${GLDEMO_LIBS}") fl_create_example(glpuzzle glpuzzle.cxx "${GLDEMO_LIBS}")
CREATE_EXAMPLE (gl_overlay gl_overlay.cxx "${GLDEMO_LIBS}") fl_create_example(gl_overlay gl_overlay.cxx "${GLDEMO_LIBS}")
CREATE_EXAMPLE (shape shape.cxx "${GLDEMO_LIBS}") fl_create_example(shape shape.cxx "${GLDEMO_LIBS}")
endif(OPENGL_FOUND) endif(OPENGL_FOUND)
# Cairo demo - must also be built w/o Cairo (displays a message box) # Cairo demo - must also be built w/o Cairo (displays a message box)
if (FLTK_HAVE_CAIRO) # ### if(FLTK_HAVE_CAIRO)
CREATE_EXAMPLE (cairo_test cairo_test.cxx "fltk;cairo") # ### fl_create_example(cairo_test cairo_test.cxx "fltk;cairo")
else () # ### else()
CREATE_EXAMPLE (cairo_test cairo_test.cxx fltk) fl_create_example(cairo_test cairo_test.cxx fltk::fltk)
endif (FLTK_HAVE_CAIRO) # ### endif(FLTK_HAVE_CAIRO)
# *** EXPERIMENTAL *** # *** EXPERIMENTAL ***
# Build some of the demo programs linked against the shared FLTK lib(s). # Build some of the demo programs linked against the shared FLTK lib(s).
# This is currently pretty complicated and should be improved. # This is currently pretty complicated and should be improved.
# It will be simplified significantly when we use more "modern CMake". # It will be simplified significantly when we use more "modern CMake".
if (OPTION_BUILD_SHARED_LIBS) if(FLTK_BUILD_SHARED_LIBS)
if(MSVC) # MS Visual C++ aka. Visual Studio if(MSVC) # MS Visual C++ aka. Visual Studio
@ -253,14 +247,15 @@ if (OPTION_BUILD_SHARED_LIBS)
# define a list of shared targets so we can set COMPILE_DEFINITIONS in a loop # define a list of shared targets so we can set COMPILE_DEFINITIONS in a loop
set(SHARED_TARGETS "") set(SHARED_TARGETS "")
CREATE_EXAMPLE (hello-shared hello.cxx "fltk_SHARED;CALL_MAIN") fl_create_example(hello-shared hello.cxx "CALL_MAIN;fltk::fltk-shared")
CREATE_EXAMPLE (pixmap_browser-shared pixmap_browser.cxx "fltk_SHARED;CALL_MAIN") fl_create_example(pixmap_browser-shared pixmap_browser.cxx "CALL_MAIN;fltk::fltk-shared")
CREATE_EXAMPLE (unittests-shared "${UNITTEST_SRCS}" "${GLDEMO_SHARED};CALL_MAIN") fl_create_example(unittests-shared "${UNITTEST_SRCS}" "CALL_MAIN;${GLDEMO_SHARED}")
list(APPEND SHARED_TARGETS hello pixmap_browser unittests) list(APPEND SHARED_TARGETS hello pixmap_browser unittests)
if(OPENGL_FOUND) if(OPENGL_FOUND)
CREATE_EXAMPLE (glpuzzle-shared glpuzzle.cxx "fltk_SHARED;CALL_MAIN;${OPENGL_LIBRARIES}") fl_create_example(glpuzzle-shared glpuzzle.cxx "CALL_MAIN;${GLDEMO_SHARED}")
CREATE_EXAMPLE (shape-shared shape.cxx "fltk_SHARED;CALL_MAIN;${OPENGL_LIBRARIES}") fl_create_example(shape-shared shape.cxx "CALL_MAIN;${GLDEMO_SHARED}")
list(APPEND SHARED_TARGETS glpuzzle shape) list(APPEND SHARED_TARGETS glpuzzle shape)
endif(OPENGL_FOUND) endif(OPENGL_FOUND)
@ -271,24 +266,20 @@ if (OPTION_BUILD_SHARED_LIBS)
else() # not MSVC else() # not MSVC
CREATE_EXAMPLE (hello-shared hello.cxx fltk_SHARED) fl_create_example(hello-shared hello.cxx fltk::fltk-shared)
CREATE_EXAMPLE (pixmap_browser-shared pixmap_browser.cxx "fltk_images_SHARED") fl_create_example(pixmap_browser-shared pixmap_browser.cxx "fltk::images-shared")
CREATE_EXAMPLE (unittests-shared "${UNITTEST_SRCS}" "${GLDEMO_SHARED}") fl_create_example(unittests-shared "${UNITTEST_SRCS}" "${GLDEMO_SHARED}")
if(OPENGL_FOUND) if(OPENGL_FOUND)
CREATE_EXAMPLE (glpuzzle-shared glpuzzle.cxx "${GLDEMO_SHARED}") fl_create_example(glpuzzle-shared glpuzzle.cxx "${GLDEMO_SHARED}")
CREATE_EXAMPLE (shape-shared shape.cxx "${GLDEMO_SHARED}") fl_create_example(shape-shared shape.cxx "${GLDEMO_SHARED}")
endif(OPENGL_FOUND) endif(OPENGL_FOUND)
if (FLTK_HAVE_CAIRO) fl_create_example(cairo_test-shared cairo_test.cxx "fltk::fltk-shared")
CREATE_EXAMPLE (cairo_test-shared cairo_test.cxx "fltk_SHARED;cairo")
else ()
CREATE_EXAMPLE (cairo_test-shared cairo_test.cxx "fltk_SHARED")
endif ()
endif(MSVC) # (not MSVC) endif(MSVC) # (not MSVC)
endif (OPTION_BUILD_SHARED_LIBS) endif(FLTK_BUILD_SHARED_LIBS)
##################################################### #####################################################
# We need some support files for the demo programs # We need some support files for the demo programs

View File

@ -27,7 +27,7 @@
#define DEF_WIDTH 0.03 #define DEF_WIDTH 0.03
// This demo program can be used in 3 modes. All 3 modes require configure // This demo program can be used in 3 modes. All 3 modes require configure
// option --enable-cairo or CMake OPTION_CAIRO. // option --enable-cairo or CMake FLTK_OPTION_CAIRO_WINDOW.
// //
// 1) using class Fl_Cairo_Window useful when all the content of a window // 1) using class Fl_Cairo_Window useful when all the content of a window
// is drawn with Cairo. // is drawn with Cairo.
@ -39,7 +39,7 @@
// or // or
// 3) showing how to use "cairo extended use". // 3) showing how to use "cairo extended use".
// This is achieved when FLTK was built with one more option // This is achieved when FLTK was built with one more option
// (configure --enable-cairoext or CMake OPTION_CAIROEXT) // (configure --enable-cairoext or CMake FLTK_OPTION_CAIRO_EXT)
// which defines the preprocessor variable FLTK_HAVE_CAIROEXT. // which defines the preprocessor variable FLTK_HAVE_CAIROEXT.
// If Fl::cairo_autolink_context(true); is called at the beginning // If Fl::cairo_autolink_context(true); is called at the beginning
// of main(), any overridden draw() function gets access to an adequate // of main(), any overridden draw() function gets access to an adequate
@ -212,7 +212,7 @@ int main(int argc, char **argv) {
fl_message_title("This program needs a Cairo enabled FLTK library"); fl_message_title("This program needs a Cairo enabled FLTK library");
fl_message( fl_message(
"Please configure FLTK with Cairo enabled (--enable-cairo or --enable-cairoext)\n" "Please configure FLTK with Cairo enabled (--enable-cairo or --enable-cairoext)\n"
"or one of the CMake options OPTION_CAIRO or OPTION_CAIROEXT, respectively."); "or one of the CMake options FLTK_OPTION_CAIRO_WINDOW or FLTK_OPTION_CAIRO_EXT, respectively.");
return 0; return 0;
} }
#endif // (FLTK_HAVE_CAIRO) #endif // (FLTK_HAVE_CAIRO)

View File

@ -1,7 +1,7 @@
# #
# ZLIB library CMake configuration for the Fast Light Toolkit (FLTK). # ZLIB library CMake configuration for the Fast Light Toolkit (FLTK).
# #
# Copyright 1998-2023 by Bill Spitzak and others. # Copyright 1998-2024 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -44,7 +44,7 @@ set (msvc_warnings /wd4267 /wd4996)
# Build the static library # Build the static library
####################################################################### #######################################################################
FL_ADD_LIBRARY (fltk_z STATIC "${ZLIB_SRCS}") fl_add_library(fltk_z STATIC "${ZLIB_SRCS}")
if(MSVC) if(MSVC)
target_compile_options(fltk_z PRIVATE ${msvc_warnings}) target_compile_options(fltk_z PRIVATE ${msvc_warnings})
@ -54,15 +54,21 @@ endif (MSVC)
# Build the shared library (optional) # Build the shared library (optional)
####################################################################### #######################################################################
if (OPTION_BUILD_SHARED_LIBS) if(FLTK_BUILD_SHARED_LIBS)
FL_ADD_LIBRARY (fltk_z SHARED "${ZLIB_SRCS}") # ensure to export all symbols for Windows DLL's
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
fl_add_library(fltk_z SHARED "${ZLIB_SRCS}")
if(MSVC) if(MSVC)
target_compile_options (fltk_z_SHARED PRIVATE ${msvc_warnings}) target_compile_options(fltk_z-shared PRIVATE ${msvc_warnings})
endif(MSVC) endif(MSVC)
endif (OPTION_BUILD_SHARED_LIBS) endif(FLTK_BUILD_SHARED_LIBS)
set(FLTK_LIBRARIES ${FLTK_LIBRARIES} PARENT_SCOPE)
set(FLTK_LIBRARIES_SHARED ${FLTK_LIBRARIES_SHARED} PARENT_SCOPE)
####################################################################### #######################################################################
# Install the library headers # Install the library headers