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
@ -72,7 +72,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 -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_EXTENSIONS=OFF -DCMAKE_C_FLAGS_INIT="-Wall -Wunused" -DCMAKE_CXX_FLAGS_INIT="-Wall -Wunused -Wsuggest-override" run: cmake $GITHUB_WORKSPACE -D CMAKE_BUILD_TYPE=$BUILD_TYPE -D CMAKE_CXX_STANDARD=11 -D CMAKE_CXX_EXTENSIONS=OFF -D CMAKE_C_FLAGS_INIT="-Wall -Wunused" -D CMAKE_CXX_FLAGS_INIT="-Wall -Wunused -Wsuggest-override"
- name: Build - name: Build
working-directory: ${{github.workspace}}/build working-directory: ${{github.workspace}}/build
@ -103,7 +103,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 -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_EXTENSIONS=OFF -DCMAKE_C_FLAGS_INIT="-Wall -Wunused" -DCMAKE_CXX_FLAGS_INIT="-Wall -Wunused -Wsuggest-override" run: cmake $GITHUB_WORKSPACE -D CMAKE_BUILD_TYPE=$BUILD_TYPE -D CMAKE_CXX_STANDARD=20 -D CMAKE_CXX_EXTENSIONS=OFF -D CMAKE_C_FLAGS_INIT="-Wall -Wunused" -D CMAKE_CXX_FLAGS_INIT="-Wall -Wunused -Wsuggest-override"
- 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,22 +15,37 @@
# 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(
OUTPUT "${basename}.cxx" "${basename}.h" OUTPUT "${basename}.cxx" "${basename}.h"
@ -38,21 +53,33 @@ function (FLTK_RUN_FLUID TARGET SOURCES)
DEPENDS ${src} DEPENDS ${src}
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}
MACOSX_BUNDLE_ICON_FILE "${ICON_NAME}" PROPERTIES
RESOURCE "${ICON_PATH}" MACOSX_BUNDLE_ICON_FILE "${ICON_NAME}"
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.
#
set (FLTK_VERSION @FLTK_VERSION@) # 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).
include (${CMAKE_CURRENT_LIST_DIR}/FLTK-Targets.cmake) set(FLTK_CREATE_COMPATIBILITY_ALIASES TRUE)
set (FLTK_INCLUDE_DIRS "@INCLUDE_DIRS@") set(FLTK_VERSION @FLTK_VERSION@)
# for compatibility with CMake's FindFLTK.cmake include(${CMAKE_CURRENT_LIST_DIR}/FLTK-Targets.cmake)
set (FLTK_INCLUDE_DIR "${FLTK_INCLUDE_DIRS}") set(FLTK_INCLUDE_DIRS "@INCLUDE_DIRS@")
set(FLTK_LIBRARIES "@FLTK_LIBRARIES@")
if (CMAKE_CROSSCOMPILING) # For compatibility with CMake's FindFLTK.cmake:
find_file(FLUID_PATH
set(FLTK_INCLUDE_DIR "${FLTK_INCLUDE_DIRS}")
if(CMAKE_CROSSCOMPILING)
# 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
set (FLTK_FLUID_EXECUTABLE ${FLUID_PATH}) # Import a special 'fluid' target called 'fluid-host' (fltk::fluid-host)
else () # Note: this is "the same as" the CMake variable FLTK_FLUID_EXECUTABLE
set (FLTK_FLUID_EXECUTABLE fluid) add_executable(fluid-host IMPORTED)
endif (CMAKE_CROSSCOMPILING) set_target_properties(fluid-host
PROPERTIES IMPORTED_LOCATION ${FLTK_FLUID_HOST}
)
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()
set(FLTK_FLUID_EXECUTABLE fluid)
endif()
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
@ -15,13 +16,13 @@
# https://www.fltk.org/bugs.php # https://www.fltk.org/bugs.php
# #
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR message(FATAL_ERROR
"Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
endif () endif()
file (READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string (REGEX REPLACE "\n" ";" files "${files}") string(REGEX REPLACE "\n" ";" files "${files}")
# Note 1: 'cmake -E remove [-f]' is deprecated since CMake 3.17 and the docs # Note 1: 'cmake -E remove [-f]' is deprecated since CMake 3.17 and the docs
# state: "The implementation was buggy and always returned 0. It cannot be # state: "The implementation was buggy and always returned 0. It cannot be
@ -30,13 +31,13 @@ string (REGEX REPLACE "\n" ";" files "${files}")
# Note 3: # Note 3:
# Remove this distinction if: cmake_minimum_required(VERSION 3.17) or higher. # Remove this distinction if: cmake_minimum_required(VERSION 3.17) or higher.
if (CMAKE_VERSION VERSION_LESS 3.17) if(CMAKE_VERSION VERSION_LESS 3.17)
set (rm_cmd remove) set(rm_cmd remove)
else () else()
set (rm_cmd rm) set(rm_cmd rm)
endif () endif()
foreach (file ${files}) foreach(file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
execute_process( execute_process(
COMMAND "${CMAKE_COMMAND}" -E ${rm_cmd} -f "$ENV{DESTDIR}${file}" COMMAND "${CMAKE_COMMAND}" -E ${rm_cmd} -f "$ENV{DESTDIR}${file}"
@ -45,12 +46,12 @@ foreach (file ${files})
RESULT_VARIABLE rm_retval RESULT_VARIABLE rm_retval
) )
if (NOT "${rm_retval}" STREQUAL 0) if(NOT "${rm_retval}" STREQUAL 0)
message (STATUS "Error removing \"$ENV{DESTDIR}${file}\"") message(STATUS "Error removing \"$ENV{DESTDIR}${file}\"")
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

@ -62,7 +62,7 @@
# #
# Example: # Example:
# #
# fl_target_link_directories (fluid PRIVATE "${PKG_CAIRO_LIBRARY_DIRS}") # fl_target_link_directories(fluid PRIVATE "${PKG_CAIRO_LIBRARY_DIRS}")
# #
# In this example 'PKG_CAIRO_LIBRARY_DIRS' is platform dependent and # In this example 'PKG_CAIRO_LIBRARY_DIRS' is platform dependent and
# can be an empty list. # can be an empty list.

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
@ -21,42 +22,65 @@
# 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)
set (FLUID_EXPORT "") # don't export fluid message(STATUS "Warning: fluid not found on the build system!")
endif (FLTK_BUILD_FLUID AND NOT CMAKE_CROSSCOMPILING) endif()
# Note: this *may* assign "FLTK_FLUID_HOST-NOTFOUND"
set(FLTK_FLUID_EXECUTABLE "${FLTK_FLUID_HOST}")
set(FLUID_EXPORT "") # don't export fluid
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(
${CMAKE_CURRENT_SOURCE_DIR}/CMake/FLTK-Functions.cmake ${CMAKE_CURRENT_SOURCE_DIR}/CMake/FLTK-Functions.cmake
${CMAKE_CURRENT_BINARY_DIR}/FLTK-Functions.cmake ${CMAKE_CURRENT_BINARY_DIR}/FLTK-Functions.cmake
COPYONLY COPYONLY
) )
# 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()
set (CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR}) list(REMOVE_DUPLICATES INCLUDE_DIRS)
set(CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR})
configure_file( configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/CMake/FLTKConfig.cmake.in ${CMAKE_CURRENT_SOURCE_DIR}/CMake/FLTKConfig.cmake.in
@ -65,14 +89,14 @@ configure_file(
) )
# generate fltk-config for build directory use # generate fltk-config for build directory use
set (prefix ${CMAKE_CURRENT_BINARY_DIR}) set(prefix ${CMAKE_CURRENT_BINARY_DIR})
set (exec_prefix "\${prefix}") set(exec_prefix "\${prefix}")
set (includedir "${CMAKE_CURRENT_SOURCE_DIR}") set(includedir "${CMAKE_CURRENT_SOURCE_DIR}")
set (BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") set(BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set (libdir "\${exec_prefix}/lib") set(libdir "\${exec_prefix}/lib")
set (srcdir ".") set(srcdir ".")
set (LIBNAME "${libdir}/libfltk.a") set(LIBNAME "${libdir}/libfltk.a")
configure_file( configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/fltk-config.in" "${CMAKE_CURRENT_SOURCE_DIR}/fltk-config.in"
@ -80,38 +104,38 @@ 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)
if (UNIX OR MSYS OR MINGW) if(UNIX OR MSYS OR MINGW)
execute_process(COMMAND chmod 755 fltk-config execute_process(COMMAND chmod 755 fltk-config
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endif () endif()
else (CMAKE_VERSION VERSION_LESS 3.19) else(CMAKE_VERSION VERSION_LESS 3.19)
file (CHMOD "${CMAKE_CURRENT_BINARY_DIR}/fltk-config" file(CHMOD "${CMAKE_CURRENT_BINARY_DIR}/fltk-config"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE) WORLD_READ WORLD_EXECUTE)
endif (CMAKE_VERSION VERSION_LESS 3.19) endif(CMAKE_VERSION VERSION_LESS 3.19)
# prepare some variables for config.h # prepare some variables for config.h
if (IS_ABSOLUTE "${FLTK_DATADIR}") if(IS_ABSOLUTE "${FLTK_DATADIR}")
set (PREFIX_DATA "${FLTK_DATADIR}/fltk") set(PREFIX_DATA "${FLTK_DATADIR}/fltk")
else (IS_ABSOLUTE "${FLTK_DATADIR}") else(IS_ABSOLUTE "${FLTK_DATADIR}")
set (PREFIX_DATA "${CMAKE_INSTALL_PREFIX}/${FLTK_DATADIR}/fltk") set(PREFIX_DATA "${CMAKE_INSTALL_PREFIX}/${FLTK_DATADIR}/fltk")
endif (IS_ABSOLUTE "${FLTK_DATADIR}") endif(IS_ABSOLUTE "${FLTK_DATADIR}")
if (IS_ABSOLUTE "${FLTK_DOCDIR}") if(IS_ABSOLUTE "${FLTK_DOCDIR}")
set (PREFIX_DOC "${FLTK_DOCDIR}/fltk") set(PREFIX_DOC "${FLTK_DOCDIR}/fltk")
else (IS_ABSOLUTE "${FLTK_DOCDIR}") else(IS_ABSOLUTE "${FLTK_DOCDIR}")
set (PREFIX_DOC "${CMAKE_INSTALL_PREFIX}/${FLTK_DOCDIR}/fltk") set(PREFIX_DOC "${CMAKE_INSTALL_PREFIX}/${FLTK_DOCDIR}/fltk")
endif (IS_ABSOLUTE "${FLTK_DOCDIR}") endif(IS_ABSOLUTE "${FLTK_DOCDIR}")
set (CONFIG_H_IN configh.cmake.in) set(CONFIG_H_IN configh.cmake.in)
set (CONFIG_H config.h) set(CONFIG_H config.h)
# generate config.h # generate config.h
@ -121,15 +145,15 @@ 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})
else () else()
set (PREFIX_INCLUDE "${CMAKE_INSTALL_PREFIX}/${FLTK_INCLUDEDIR}") set(PREFIX_INCLUDE "${CMAKE_INSTALL_PREFIX}/${FLTK_INCLUDEDIR}")
endif (IS_ABSOLUTE ${FLTK_INCLUDEDIR}) endif(IS_ABSOLUTE ${FLTK_INCLUDEDIR})
configure_file( configure_file(
"${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,108 +16,239 @@
# #
####################################################################### #######################################################################
# 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 (TARGET_NAME ${LIBNAME})
endif (${LIBTYPE} STREQUAL "SHARED")
if (MSVC) set(suffix "")
set (OUTPUT_NAME_DEBUG "${LIBNAME}d") if(LIBTYPE STREQUAL "SHARED")
set (OUTPUT_NAME_RELEASE "${LIBNAME}") set(suffix "-shared")
else () endif()
set (OUTPUT_NAME_DEBUG "${LIBNAME}")
set (OUTPUT_NAME_RELEASE "${LIBNAME}")
endif (MSVC)
add_library(${TARGET_NAME} ${LIBTYPE} ${LIBFILES}) 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)
set(OUTPUT_NAME_DEBUG "${LIBNAME}d")
else()
set(OUTPUT_NAME_DEBUG "${LIBNAME}")
endif(MSVC)
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*
) )
endif (MSVC) target_compile_definitions (${TARGET_NAME} PRIVATE FL_DLL)
endif (${LIBTYPE} STREQUAL "SHARED") endif(MSVC)
endif(LIBTYPE STREQUAL "SHARED")
# Debug library output names (optional) # Debug library output names (optional)
set (DEBUG_ONAME 0) set(DEBUG_ONAME 0)
if (DEBUG_ONAME) if(DEBUG_ONAME)
get_target_property (XX_NAME ${TARGET_NAME} NAME) get_target_property (XX_NAME ${TARGET_NAME} NAME)
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)
fl_debug_var (TARGET_NAME) message(STATUS "--- DEBUG_ONAME ---")
fl_debug_var (XX_NAME) fl_debug_var(TARGET_NAME)
fl_debug_var (XX_ONAME) fl_debug_var(XX_NAME)
fl_debug_var (XX_ONAME_DEBUG) fl_debug_var(XX_ONAME)
fl_debug_var (XX_ONAME_RELEASE) fl_debug_var(XX_ONAME_DEBUG)
message (STATUS "---") fl_debug_var(XX_ONAME_RELEASE)
endif (DEBUG_ONAME) fl_debug_var(XX_EXPORT_NAME)
message(STATUS "--- /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)
endif(MSVC)
if (${LIBTYPE} STREQUAL "SHARED") install(TARGETS ${TARGET_NAME} EXPORT FLTK-Targets
target_compile_definitions(${TARGET_NAME}
PRIVATE "FL_DLL")
endif ()
endif (MSVC)
install (TARGETS ${TARGET_NAME}
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}
) )
list (APPEND FLTK_LIBRARIES "${TARGET_NAME}") if(LIBTYPE STREQUAL "SHARED")
set (FLTK_LIBRARIES ${FLTK_LIBRARIES} PARENT_SCOPE) list(APPEND FLTK_LIBRARIES_SHARED "${TARGET_NAME}")
set(FLTK_LIBRARIES_SHARED "${FLTK_LIBRARIES_SHARED}" PARENT_SCOPE)
else()
list(APPEND FLTK_LIBRARIES "${TARGET_NAME}")
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:
# #
@ -27,9 +27,9 @@
# Sources can be: # Sources can be:
# - .c/.cxx files, e.g. 'hello.cxx' # - .c/.cxx files, e.g. 'hello.cxx'
# - .fl (fluid) files, e.g. 'radio.fl' # - .fl (fluid) files, e.g. 'radio.fl'
# - .plist file (macOS), e.g. 'editor.plist' # - .plist file(macOS), e.g. 'editor.plist'
# - .icns file (macOS Icon), e.g. 'checkers.icns' # - .icns file(macOS Icon), e.g. 'checkers.icns'
# - .rc file (Windows resource file, e.g. icon definition) # - .rc file(Windows resource file, e.g. icon definition)
# #
# Order of sources doesn't matter, multiple .cxx and .fl files are # Order of sources doesn't matter, multiple .cxx and .fl files are
# supported, but only one .plist and one .icns file. # supported, but only one .plist and one .icns file.
@ -42,127 +42,127 @@
# 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
set (TARGET_NAME ${NAME}) # CMake target name set(TARGET_NAME ${NAME}) # CMake target name
set (ICON_NAME) # macOS icon (max. one) set(ICON_NAME) # macOS icon (max. one)
set (PLIST) # macOS .plist file (max. one) set(PLIST) # macOS .plist file(max. one)
set (ICON_PATH) # macOS icon resource path set(ICON_PATH) # macOS icon resource path
# 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)
foreach (src ${SOURCES}) foreach(src ${SOURCES})
if ("${src}" MATCHES "\\.fl$") if("${src}" MATCHES "\\.fl$")
list (APPEND flsrcs ${src}) list(APPEND flsrcs ${src})
elseif ("${src}" MATCHES "\\.icns$") elseif("${src}" MATCHES "\\.icns$")
set (ICON_NAME "${src}") set(ICON_NAME "${src}")
elseif ("${src}" MATCHES "\\.plist$") elseif("${src}" MATCHES "\\.plist$")
set (PLIST "${src}") set(PLIST "${src}")
else () else()
list (APPEND srcs ${src}) list(APPEND srcs ${src})
endif ("${src}" MATCHES "\\.fl$") endif("${src}" MATCHES "\\.fl$")
endforeach (src) endforeach(src)
# generate source files from .fl files, add output to sources # generate source files from .fl files, add output to sources
if (flsrcs) if(flsrcs)
if (NOT FLTK_FLUID_EXECUTABLE) if(NOT FLTK_FLUID_EXECUTABLE)
message(STATUS "Example app \"${NAME}\" will not be built. FLUID executable not found.") message(STATUS "Example app \"${NAME}\" will not be built. FLUID executable not found.")
return () return ()
endif () endif()
FLTK_RUN_FLUID (FLUID_SOURCES "${flsrcs}") FLTK_RUN_FLUID (FLUID_SOURCES "${flsrcs}")
list (APPEND srcs ${FLUID_SOURCES}) list(APPEND srcs ${FLUID_SOURCES})
unset (FLUID_SOURCES) unset(FLUID_SOURCES)
endif (flsrcs) endif(flsrcs)
# set macOS (icon) resource path if applicable # set macOS (icon) resource path if applicable
if (MAC_BUNDLE AND ICON_NAME) if(MAC_BUNDLE AND ICON_NAME)
set (ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/mac-resources/${ICON_NAME}") set(ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/mac-resources/${ICON_NAME}")
endif (MAC_BUNDLE AND ICON_NAME) endif(MAC_BUNDLE AND ICON_NAME)
############################################################################## ##############################################################################
# add executable target and set properties (all platforms) # add executable target and set properties (all platforms)
############################################################################## ##############################################################################
if (MAC_BUNDLE) if(MAC_BUNDLE)
add_executable (${TARGET_NAME} MACOSX_BUNDLE ${srcs} ${ICON_PATH}) add_executable (${TARGET_NAME} MACOSX_BUNDLE ${srcs} ${ICON_PATH})
else () else()
add_executable (${TARGET_NAME} WIN32 ${srcs}) add_executable (${TARGET_NAME} WIN32 ${srcs})
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 (FLTK_HAVE_CAIROEXT)
target_link_libraries (${TARGET_NAME} ${PKG_CAIRO_LIBRARIES})
endif ()
if (FLTK_HAVE_CAIRO AND PKG_CAIRO_LIBRARY_DIRS) if(0) # This should no longer be necessary (implied by linking the libs)
target_link_directories (${TARGET_NAME} PUBLIC ${PKG_CAIRO_LIBRARY_DIRS})
endif ()
if (USE_GDIPLUS) # can only be true on Windows # we must link all programs with Cairo if option CAIROEXT is enabled
target_link_libraries (${TARGET_NAME} gdiplus) if(FLTK_HAVE_CAIROEXT)
endif () target_link_libraries(${TARGET_NAME} PRIVATE ${PKG_CAIRO_LIBRARIES})
endif()
if (MAC_BUNDLE) if(FLTK_HAVE_CAIRO AND PKG_CAIRO_LIBRARY_DIRS)
if (PLIST) target_link_directories(${TARGET_NAME} PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST endif()
endif() # This should no longer be necessary (implied by linking the libs)
# 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(PLIST)
set_target_properties(${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST
"${CMAKE_CURRENT_SOURCE_DIR}/mac-resources/${PLIST}") "${CMAKE_CURRENT_SOURCE_DIR}/mac-resources/${PLIST}")
endif() endif()
string(REPLACE "_" "-" FLTK_BUNDLE_ID "org.fltk.${TARGET_NAME}") string(REPLACE "_" "-" FLTK_BUNDLE_ID "org.fltk.${TARGET_NAME}")
set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "${TARGET_NAME}") set_target_properties(${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "${TARGET_NAME}")
set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "${FLTK_BUNDLE_ID}") set_target_properties(${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "${FLTK_BUNDLE_ID}")
set_target_properties (${TARGET_NAME} PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${FLTK_BUNDLE_ID}") set_target_properties(${TARGET_NAME} PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${FLTK_BUNDLE_ID}")
if (ICON_NAME) if(ICON_NAME)
set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME}) set_target_properties(${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
set_target_properties (${TARGET_NAME} PROPERTIES RESOURCE ${ICON_PATH}) set_target_properties(${TARGET_NAME} PROPERTIES RESOURCE ${ICON_PATH})
endif () endif()
endif () endif()
############################################################################## ##############################################################################
# Copy macOS "bundle wrapper" (shell script) to target directory. # Copy macOS "bundle wrapper" (shell script) to target directory.
# The "custom command" will be executed "POST_BUILD". # The "custom command" will be executed "POST_BUILD".
############################################################################## ##############################################################################
if (MAC_BUNDLE) if(MAC_BUNDLE)
set (WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${TARGET_NAME}") set(WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${TARGET_NAME}")
add_custom_command ( add_custom_command(
TARGET ${TARGET_NAME} POST_BUILD TARGET ${TARGET_NAME} POST_BUILD
COMMAND cp ${FLTK_SOURCE_DIR}/CMake/macOS-bundle-wrapper.in ${WRAPPER} COMMAND cp ${FLTK_SOURCE_DIR}/CMake/macOS-bundle-wrapper.in ${WRAPPER}
COMMAND chmod u+x,g+x,o+x ${WRAPPER} COMMAND chmod u+x,g+x,o+x ${WRAPPER}
@ -170,29 +170,18 @@ function (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
# COMMENT "Creating macOS bundle wrapper script ${WRAPPER}" # COMMENT "Creating macOS bundle wrapper script ${WRAPPER}"
VERBATIM VERBATIM
) )
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

@ -41,29 +41,29 @@
macro (fl_debug_pkg PREFIX NAME) macro (fl_debug_pkg PREFIX NAME)
message("") message("")
message(STATUS "Results of pkg_check_modules(${PREFIX}, ${NAME}):") message(STATUS "Results of pkg_check_modules(${PREFIX}, ${NAME}):")
fl_debug_var (${PREFIX}_FOUND) fl_debug_var(${PREFIX}_FOUND)
if (${PREFIX}_FOUND) if(${PREFIX}_FOUND)
fl_debug_var (${PREFIX}_INCLUDE_DIRS) fl_debug_var(${PREFIX}_INCLUDE_DIRS)
fl_debug_var (${PREFIX}_CFLAGS) fl_debug_var(${PREFIX}_CFLAGS)
fl_debug_var (${PREFIX}_LIBRARIES) fl_debug_var(${PREFIX}_LIBRARIES)
fl_debug_var (${PREFIX}_LINK_LIBRARIES) fl_debug_var(${PREFIX}_LINK_LIBRARIES)
fl_debug_var (${PREFIX}_LIBRARY_DIRS) fl_debug_var(${PREFIX}_LIBRARY_DIRS)
fl_debug_var (${PREFIX}_LDFLAGS) fl_debug_var(${PREFIX}_LDFLAGS)
fl_debug_var (${PREFIX}_LDFLAGS_OTHER) fl_debug_var(${PREFIX}_LDFLAGS_OTHER)
fl_debug_var (${PREFIX}_CFLAGS_OTHER) fl_debug_var(${PREFIX}_CFLAGS_OTHER)
fl_debug_var (${PREFIX}_STATIC_INCLUDE_DIRS) fl_debug_var(${PREFIX}_STATIC_INCLUDE_DIRS)
fl_debug_var (${PREFIX}_STATIC_CFLAGS) fl_debug_var(${PREFIX}_STATIC_CFLAGS)
fl_debug_var (${PREFIX}_STATIC_LIBRARIES) fl_debug_var(${PREFIX}_STATIC_LIBRARIES)
fl_debug_var (${PREFIX}_STATIC_LINK_LIBRARIES) fl_debug_var(${PREFIX}_STATIC_LINK_LIBRARIES)
fl_debug_var (${PREFIX}_STATIC_LIBRARY_DIRS) fl_debug_var(${PREFIX}_STATIC_LIBRARY_DIRS)
fl_debug_var (${PREFIX}_VERSION) fl_debug_var(${PREFIX}_VERSION)
fl_debug_var (${PREFIX}_PREFIX) fl_debug_var(${PREFIX}_PREFIX)
fl_debug_var (${PREFIX}_INCLUDEDIR) fl_debug_var(${PREFIX}_INCLUDEDIR)
fl_debug_var (${PREFIX}_LIBDIR) fl_debug_var(${PREFIX}_LIBDIR)
endif () endif()
message("") message("")
endmacro (fl_debug_pkg) endmacro (fl_debug_pkg)

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}") fl_expand_name(var "${name}" 40)
string(LENGTH "${var}" len) message(STATUS "${var} = '${${name}}'")
while (len LESS min_len) endfunction (fl_debug_var)
# 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) # fl_debug_target - a function to output info about a target
endwhile (len LESS min_len) #######################################################################
message (STATUS "${var} = '${${name}}'") #
endmacro (fl_debug_var) # 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

@ -22,7 +22,7 @@ if (NOT EXISTS $ENV{DESTDIR}@PREFIX_INCLUDE@/Fl)
endif (NOT EXISTS $ENV{DESTDIR}@PREFIX_INCLUDE@/Fl) endif (NOT EXISTS $ENV{DESTDIR}@PREFIX_INCLUDE@/Fl)
file (GLOB FLTK_HEADER_FILES $ENV{DESTDIR}@PREFIX_INCLUDE@/FL/*.H) file (GLOB FLTK_HEADER_FILES $ENV{DESTDIR}@PREFIX_INCLUDE@/FL/*.H)
foreach (file ${FLTK_HEADER_FILES}) foreach(file ${FLTK_HEADER_FILES})
GET_FILENAME_COMPONENT(nameWE ${file} NAME_WE) GET_FILENAME_COMPONENT(nameWE ${file} NAME_WE)
if (NOT EXISTS $ENV{DESTDIR}@PREFIX_INCLUDE@/FL/${nameWE}.h) if (NOT EXISTS $ENV{DESTDIR}@PREFIX_INCLUDE@/FL/${nameWE}.h)
EXECUTE_PROCESS( EXECUTE_PROCESS(
@ -30,4 +30,4 @@ foreach (file ${FLTK_HEADER_FILES})
WORKING_DIRECTORY $ENV{DESTDIR}@PREFIX_INCLUDE@/FL WORKING_DIRECTORY $ENV{DESTDIR}@PREFIX_INCLUDE@/FL
) )
endif (NOT EXISTS $ENV{DESTDIR}@PREFIX_INCLUDE@/FL/${nameWE}.h) endif (NOT EXISTS $ENV{DESTDIR}@PREFIX_INCLUDE@/FL/${nameWE}.h)
endforeach (file) endforeach(file)

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
@ -25,11 +25,11 @@ configure_file(
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
@ONLY @ONLY
) )
add_custom_target (uninstall add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
) )
install (DIRECTORY install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/FL ${CMAKE_CURRENT_SOURCE_DIR}/FL
DESTINATION ${FLTK_INCLUDEDIR} USE_SOURCE_PERMISSIONS DESTINATION ${FLTK_INCLUDEDIR} USE_SOURCE_PERMISSIONS
FILES_MATCHING FILES_MATCHING
@ -37,28 +37,29 @@ install (DIRECTORY
PATTERN "fl_config.h" EXCLUDE PATTERN "fl_config.h" EXCLUDE
) )
install (DIRECTORY install(DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/FL ${CMAKE_CURRENT_BINARY_DIR}/FL
DESTINATION ${FLTK_INCLUDEDIR} USE_SOURCE_PERMISSIONS DESTINATION ${FLTK_INCLUDEDIR} USE_SOURCE_PERMISSIONS
FILES_MATCHING FILES_MATCHING
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)
if (FLTK_HAVE_CAIRO) if(FLTK_HAVE_CAIRO)
list (APPEND INCLUDE_DIRS ${PKG_CAIRO_INCLUDE_DIRS}) list(APPEND INCLUDE_DIRS ${PKG_CAIRO_INCLUDE_DIRS})
endif () endif()
set (CONFIG_PATH ${CMAKE_INSTALL_PREFIX}/${FLTK_CONFIG_PATH}) 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(
@ -67,26 +68,26 @@ configure_file(
@ONLY @ONLY
) )
install (FILES install(FILES
${CMAKE_CURRENT_BINARY_DIR}/etc/FLTKConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/etc/FLTKConfig.cmake
DESTINATION ${FLTK_CONFIG_PATH} DESTINATION ${FLTK_CONFIG_PATH}
) )
install (FILES install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/CMake/FLTK-Functions.cmake ${CMAKE_CURRENT_SOURCE_DIR}/CMake/FLTK-Functions.cmake
DESTINATION ${FLTK_CONFIG_PATH} DESTINATION ${FLTK_CONFIG_PATH}
) )
# Generate fltk-config # Generate fltk-config
set (prefix ${CMAKE_INSTALL_PREFIX}) set(prefix ${CMAKE_INSTALL_PREFIX})
set (exec_prefix "\${prefix}") set(exec_prefix "\${prefix}")
set (includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
set (BINARY_DIR) set(BINARY_DIR)
set (libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
set (srcdir ".") set(srcdir ".")
set (LIBNAME "${libdir}/libfltk.a") set(LIBNAME "${libdir}/libfltk.a")
configure_file( configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/fltk-config.in" "${CMAKE_CURRENT_SOURCE_DIR}/fltk-config.in"
@ -95,14 +96,14 @@ configure_file(
) )
# Install fltk-config # Install fltk-config
# Note: no need to set execute perms, install (PROGRAMS) does this # Note: no need to set execute perms, install(PROGRAMS) does this
install (PROGRAMS install(PROGRAMS
${CMAKE_CURRENT_BINARY_DIR}/bin/fltk-config ${CMAKE_CURRENT_BINARY_DIR}/bin/fltk-config
DESTINATION ${FLTK_BINDIR} DESTINATION ${FLTK_BINDIR}
) )
if (UNIX OR MSYS OR MINGW) if(UNIX OR MSYS OR MINGW)
macro(INSTALL_MAN FILE LEVEL) macro(INSTALL_MAN FILE LEVEL)
install(FILES install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/documentation/src/${FILE}.man ${CMAKE_CURRENT_SOURCE_DIR}/documentation/src/${FILE}.man
@ -111,20 +112,20 @@ if (UNIX OR MSYS OR MINGW)
) )
endmacro (INSTALL_MAN FILE LEVEL) endmacro (INSTALL_MAN FILE LEVEL)
if (FLTK_BUILD_FLUID) if(FLTK_BUILD_FLUID)
INSTALL_MAN (fluid 1) INSTALL_MAN (fluid 1)
endif (FLTK_BUILD_FLUID) endif(FLTK_BUILD_FLUID)
if (FLTK_BUILD_FLTK_OPTIONS) if(FLTK_BUILD_FLTK_OPTIONS)
INSTALL_MAN (fltk-options 1) INSTALL_MAN (fltk-options 1)
endif (FLTK_BUILD_FLTK_OPTIONS) endif(FLTK_BUILD_FLTK_OPTIONS)
INSTALL_MAN (fltk-config 1) INSTALL_MAN (fltk-config 1)
INSTALL_MAN (fltk 3) INSTALL_MAN (fltk 3)
if (FLTK_BUILD_TEST AND FLTK_BUILD_FLUID) if(FLTK_BUILD_TEST AND FLTK_BUILD_FLUID)
# Don't (!) install man pages of games (GitHub issue #23) # Don't (!) install man pages of games (GitHub issue #23)
# INSTALL_MAN (blocks 6) # INSTALL_MAN (blocks 6)
# INSTALL_MAN (checkers 6) # INSTALL_MAN (checkers 6)
# INSTALL_MAN (sudoku 6) # INSTALL_MAN (sudoku 6)
endif () endif()
endif (UNIX OR MSYS OR MINGW) endif(UNIX OR MSYS OR MINGW)

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
@ -24,34 +24,37 @@
# and the result of the search is logged with fl_debug_var(). # and the result of the search is logged with fl_debug_var().
# This is useful for debugging. # This is useful for debugging.
set (CMAKE_REQUIRED_QUIET 1) set(CMAKE_REQUIRED_QUIET 1)
include (CheckIncludeFiles) include(CheckIncludeFiles)
macro (fl_find_header VAR HEADER) macro (fl_find_header VAR HEADER)
check_include_files ("${HEADER}" ${VAR}) check_include_files("${HEADER}" ${VAR})
if (NOT CMAKE_REQUIRED_QUIET) if(NOT CMAKE_REQUIRED_QUIET)
fl_debug_var (${VAR}) fl_debug_var(${VAR})
endif (NOT CMAKE_REQUIRED_QUIET) endif(NOT CMAKE_REQUIRED_QUIET)
endmacro (fl_find_header) endmacro (fl_find_header)
####################################################################### #######################################################################
# Include FindPkgConfig for later use of pkg-config # Include FindPkgConfig for later use of pkg-config
####################################################################### #######################################################################
include (FindPkgConfig) include(FindPkgConfig)
# fl_debug_var (PKG_CONFIG_FOUND) # fl_debug_var(PKG_CONFIG_FOUND)
# fl_debug_var (PKG_CONFIG_EXECUTABLE) # fl_debug_var(PKG_CONFIG_EXECUTABLE)
# fl_debug_var (PKG_CONFIG_VERSION_STRING) # fl_debug_var(PKG_CONFIG_VERSION_STRING)
####################################################################### #######################################################################
# Find header files... # Find header files...
####################################################################### #######################################################################
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD") 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)
@ -65,23 +68,23 @@ fl_find_header (HAVE_SYS_STDTYPES_H sys/stdtypes.h)
fl_find_header (HAVE_X11_XREGION_H "X11/Xlib.h;X11/Xregion.h") fl_find_header (HAVE_X11_XREGION_H "X11/Xlib.h;X11/Xregion.h")
if (WIN32 AND NOT CYGWIN) if(WIN32 AND NOT CYGWIN)
# we don't use pthreads on Windows (except for Cygwin, see options.cmake) # we don't use pthreads on Windows (except for Cygwin, see options.cmake)
set (HAVE_PTHREAD_H 0) set(HAVE_PTHREAD_H 0)
else () else()
fl_find_header (HAVE_PTHREAD_H pthread.h) fl_find_header (HAVE_PTHREAD_H pthread.h)
endif (WIN32 AND NOT CYGWIN) endif(WIN32 AND NOT CYGWIN)
# Do we have PTHREAD_MUTEX_RECURSIVE ? # Do we have PTHREAD_MUTEX_RECURSIVE ?
if (HAVE_PTHREAD_H) if(HAVE_PTHREAD_H)
try_compile(HAVE_PTHREAD_MUTEX_RECURSIVE try_compile(HAVE_PTHREAD_MUTEX_RECURSIVE
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/CMake/pthread_mutex_recursive.c ${CMAKE_CURRENT_SOURCE_DIR}/CMake/pthread_mutex_recursive.c
) )
else () else()
set (HAVE_PTHREAD_MUTEX_RECURSIVE 0) set(HAVE_PTHREAD_MUTEX_RECURSIVE 0)
endif () endif()
# Special case for Microsoft Visual Studio generator (MSVC): # Special case for Microsoft Visual Studio generator (MSVC):
# #
@ -94,19 +97,19 @@ endif ()
# #
# Note: these cache variables can only be seen in "advanced" mode. # Note: these cache variables can only be seen in "advanced" mode.
if (MSVC) if(MSVC)
if (NOT HAVE_GL_GLU_H) if(NOT HAVE_GL_GLU_H)
message (STATUS "Info: Header file GL/glu.h was not found. Continuing...") message(STATUS "Info: Header file GL/glu.h was not found. Continuing...")
set (HAVE_GL_GLU_H 1) set(HAVE_GL_GLU_H 1)
endif (NOT HAVE_GL_GLU_H) endif(NOT HAVE_GL_GLU_H)
if (NOT HAVE_LOCALE_H) if(NOT HAVE_LOCALE_H)
message (STATUS "Info: Header file locale.h was not found. Continuing...") message(STATUS "Info: Header file locale.h was not found. Continuing...")
set (HAVE_LOCALE_H 1) set(HAVE_LOCALE_H 1)
endif (NOT HAVE_LOCALE_H) endif(NOT HAVE_LOCALE_H)
endif (MSVC) endif(MSVC)
# Simulate the behavior of autoconf macro AC_HEADER_DIRENT, see: # Simulate the behavior of autoconf macro AC_HEADER_DIRENT, see:
# https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Headers.html # https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Headers.html
@ -118,15 +121,15 @@ endif (MSVC)
fl_find_header (HAVE_DIRENT_H dirent.h) fl_find_header (HAVE_DIRENT_H dirent.h)
if (NOT HAVE_DIRENT_H) if(NOT HAVE_DIRENT_H)
fl_find_header (HAVE_SYS_NDIR_H sys/ndir.h) fl_find_header (HAVE_SYS_NDIR_H sys/ndir.h)
if (NOT HAVE_SYS_NDIR_H) if(NOT HAVE_SYS_NDIR_H)
fl_find_header (HAVE_SYS_DIR_H sys/dir.h) fl_find_header (HAVE_SYS_DIR_H sys/dir.h)
if (NOT HAVE_SYS_DIR_H) if(NOT HAVE_SYS_DIR_H)
fl_find_header (HAVE_NDIR_H ndir.h) fl_find_header (HAVE_NDIR_H ndir.h)
endif (NOT HAVE_SYS_DIR_H) endif(NOT HAVE_SYS_DIR_H)
endif (NOT HAVE_SYS_NDIR_H) endif(NOT HAVE_SYS_NDIR_H)
endif (NOT HAVE_DIRENT_H) endif(NOT HAVE_DIRENT_H)
mark_as_advanced (HAVE_ALSA_ASOUNDLIB_H HAVE_DIRENT_H HAVE_DLFCN_H) mark_as_advanced (HAVE_ALSA_ASOUNDLIB_H HAVE_DIRENT_H HAVE_DLFCN_H)
mark_as_advanced (HAVE_GL_GLU_H) mark_as_advanced (HAVE_GL_GLU_H)
@ -147,18 +150,18 @@ mark_as_advanced (HAVE_X11_XREGION_H)
find_path (FREETYPE_PATH freetype.h PATH_SUFFIXES freetype2) 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)
####################################################################### #######################################################################
# 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)
@ -173,40 +176,40 @@ mark_as_advanced (LIB_jpeg LIB_png LIB_zlib)
####################################################################### #######################################################################
# functions # functions
include (CheckFunctionExists) include(CheckFunctionExists)
# save CMAKE_REQUIRED_LIBRARIES (is this really necessary ?) # save CMAKE_REQUIRED_LIBRARIES (is this really necessary ?)
if (DEFINED CMAKE_REQUIRED_LIBRARIES) if(DEFINED CMAKE_REQUIRED_LIBRARIES)
set (SAVED_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) set(SAVED_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
else (DEFINED CMAKE_REQUIRED_LIBRARIES) else(DEFINED CMAKE_REQUIRED_LIBRARIES)
unset (SAVED_REQUIRED_LIBRARIES) unset(SAVED_REQUIRED_LIBRARIES)
endif (DEFINED CMAKE_REQUIRED_LIBRARIES) endif(DEFINED CMAKE_REQUIRED_LIBRARIES)
set (CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
if (HAVE_DLFCN_H) if(HAVE_DLFCN_H)
set (HAVE_DLFCN_H 1) set(HAVE_DLFCN_H 1)
endif (HAVE_DLFCN_H) endif(HAVE_DLFCN_H)
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS}) set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
CHECK_FUNCTION_EXISTS (dlsym HAVE_DLSYM) CHECK_FUNCTION_EXISTS (dlsym HAVE_DLSYM)
set (CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
CHECK_FUNCTION_EXISTS (localeconv HAVE_LOCALECONV) CHECK_FUNCTION_EXISTS (localeconv HAVE_LOCALECONV)
if (LIB_png) if(LIB_png)
set (CMAKE_REQUIRED_LIBRARIES ${LIB_png}) set(CMAKE_REQUIRED_LIBRARIES ${LIB_png})
CHECK_FUNCTION_EXISTS (png_get_valid HAVE_PNG_GET_VALID) CHECK_FUNCTION_EXISTS (png_get_valid HAVE_PNG_GET_VALID)
CHECK_FUNCTION_EXISTS (png_set_tRNS_to_alpha HAVE_PNG_SET_TRNS_TO_ALPHA) CHECK_FUNCTION_EXISTS (png_set_tRNS_to_alpha HAVE_PNG_SET_TRNS_TO_ALPHA)
set (CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
endif (LIB_png) endif(LIB_png)
CHECK_FUNCTION_EXISTS (scandir HAVE_SCANDIR) CHECK_FUNCTION_EXISTS (scandir HAVE_SCANDIR)
CHECK_FUNCTION_EXISTS (snprintf HAVE_SNPRINTF) CHECK_FUNCTION_EXISTS (snprintf HAVE_SNPRINTF)
# not really true but we convert strcasecmp calls to _stricmp calls in flstring.h # not really true but we convert strcasecmp calls to _stricmp calls in flstring.h
if (MSVC) if(MSVC)
set (HAVE_STRCASECMP 1) set(HAVE_STRCASECMP 1)
endif (MSVC) endif(MSVC)
CHECK_FUNCTION_EXISTS (strcasecmp HAVE_STRCASECMP) CHECK_FUNCTION_EXISTS (strcasecmp HAVE_STRCASECMP)
@ -214,30 +217,30 @@ CHECK_FUNCTION_EXISTS (strlcat HAVE_STRLCAT)
CHECK_FUNCTION_EXISTS (strlcpy HAVE_STRLCPY) CHECK_FUNCTION_EXISTS (strlcpy HAVE_STRLCPY)
CHECK_FUNCTION_EXISTS (vsnprintf HAVE_VSNPRINTF) CHECK_FUNCTION_EXISTS (vsnprintf HAVE_VSNPRINTF)
if (HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX) if(HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX)
set (MSG "POSIX compatible scandir") set(MSG "POSIX compatible scandir")
message (STATUS "Looking for ${MSG}") message(STATUS "Looking for ${MSG}")
try_compile(V try_compile(V
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/CMake/posixScandir.cxx ${CMAKE_CURRENT_SOURCE_DIR}/CMake/posixScandir.cxx
) )
if (V) if(V)
message (STATUS "${MSG} - found") message(STATUS "${MSG} - found")
set (HAVE_SCANDIR_POSIX 1 CACHE INTERNAL "") set(HAVE_SCANDIR_POSIX 1 CACHE INTERNAL "")
else() else()
message (STATUS "${MSG} - not found") message(STATUS "${MSG} - not found")
set (HAVE_SCANDIR_POSIX HAVE_SCANDIR_POSIX-NOTFOUND) set(HAVE_SCANDIR_POSIX HAVE_SCANDIR_POSIX-NOTFOUND)
endif (V) endif(V)
endif (HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX) endif(HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX)
mark_as_advanced (HAVE_SCANDIR_POSIX) mark_as_advanced (HAVE_SCANDIR_POSIX)
# restore CMAKE_REQUIRED_LIBRARIES (is this really necessary ?) # restore CMAKE_REQUIRED_LIBRARIES (is this really necessary ?)
if (DEFINED SAVED_REQUIRED_LIBRARIES) if(DEFINED SAVED_REQUIRED_LIBRARIES)
set (CMAKE_REQUIRED_LIBRARIES ${SAVED_REQUIRED_LIBRARIES}) set(CMAKE_REQUIRED_LIBRARIES ${SAVED_REQUIRED_LIBRARIES})
unset (SAVED_REQUIRED_LIBRARIES) unset(SAVED_REQUIRED_LIBRARIES)
else(DEFINED SAVED_REQUIRED_LIBRARIES) else(DEFINED SAVED_REQUIRED_LIBRARIES)
unset (CMAKE_REQUIRED_LIBRARIES) unset(CMAKE_REQUIRED_LIBRARIES)
endif (DEFINED SAVED_REQUIRED_LIBRARIES) endif(DEFINED SAVED_REQUIRED_LIBRARIES)
####################################################################### #######################################################################
# packages # packages
@ -250,18 +253,18 @@ find_package (Doxygen)
# Note: we only check existence of `latex' (LATEX_COMPILER), hence # Note: we only check existence of `latex' (LATEX_COMPILER), hence
# building the pdf docs may still fail because of other missing tools. # building the pdf docs may still fail because of other missing tools.
set (LATEX_FOUND) set(LATEX_FOUND)
if (DOXYGEN_FOUND) if(DOXYGEN_FOUND)
find_package (LATEX) find_package (LATEX)
if (LATEX_COMPILER AND NOT LATEX_FOUND) if(LATEX_COMPILER AND NOT LATEX_FOUND)
set (LATEX_FOUND YES) set(LATEX_FOUND YES)
endif (LATEX_COMPILER AND NOT LATEX_FOUND) endif(LATEX_COMPILER AND NOT LATEX_FOUND)
endif (DOXYGEN_FOUND) endif(DOXYGEN_FOUND)
# message ("Doxygen found : ${DOXYGEN_FOUND}") # message("Doxygen found : ${DOXYGEN_FOUND}")
# message ("LaTex found : ${LATEX_FOUND}") # message("LaTex found : ${LATEX_FOUND}")
# message ("LaTex Compiler : ${LATEX_COMPILER}") # message("LaTex Compiler : ${LATEX_COMPILER}")
# Cleanup: unset local variables # Cleanup: unset local variables
unset (CMAKE_REQUIRED_QUIET) unset(CMAKE_REQUIRED_QUIET)

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
@ -19,107 +19,132 @@
# basic setup # basic setup
####################################################################### #######################################################################
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
set (LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib) set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib)
set (ARCHIVE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib) 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)
set (FLTK_BINDIR ${CMAKE_INSTALL_BINDIR} CACHE PATH set(FLTK_BINDIR ${CMAKE_INSTALL_BINDIR} CACHE PATH
"Binary install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.") "Binary install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
set (FLTK_LIBDIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH set(FLTK_LIBDIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH
"Library install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.") "Library install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
set (FLTK_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH set(FLTK_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH
"Public header install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.") "Public header install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
set (FLTK_DATADIR ${CMAKE_INSTALL_DATADIR} CACHE PATH set(FLTK_DATADIR ${CMAKE_INSTALL_DATADIR} CACHE PATH
"Non-arch data install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.") "Non-arch data install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
set (FLTK_MANDIR ${CMAKE_INSTALL_MANDIR} CACHE PATH set(FLTK_MANDIR ${CMAKE_INSTALL_MANDIR} CACHE PATH
"Manual install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.") "Manual install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
set (FLTK_DOCDIR ${CMAKE_INSTALL_DATADIR}/doc CACHE PATH set(FLTK_DOCDIR ${CMAKE_INSTALL_DATADIR}/doc CACHE PATH
"Non-arch doc install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.") "Non-arch doc install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute 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_LDLIBS "") set(FLTK_BUILD_INCLUDE_DIRECTORIES "")
set (FLTK_LIBRARIES "") set(FLTK_IMAGE_INCLUDE_DIRECTORIES "")
set (GLLIBS "") set(FLTK_IMAGE_LIBRARIES "")
set (IMAGELIBS "") set(FLTK_IMAGE_LIBRARIES_SHARED "")
set (LDFLAGS "")
set (LIBS "") set(FLTK_CFLAGS "")
set (LINK_LIBS "") set(FLTK_LIBRARIES "")
set (STATICIMAGELIBS "") 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_LIBRARIES "")
set(GLLIBS "")
set(IMAGELIBS "")
set(LDFLAGS "")
set(LIBS "")
set(LINK_LIBS "")
set(STATICIMAGELIBS "")
####################################################################### #######################################################################
# platform dependent information # platform dependent information
####################################################################### #######################################################################
# 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)
endif (WIN32 AND NOT CYGWIN) endif(WIN32 AND NOT CYGWIN)
include(TestBigEndian) include(TestBigEndian)
TEST_BIG_ENDIAN(WORDS_BIGENDIAN) TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
if (CMAKE_GENERATOR MATCHES "Xcode") if(CMAKE_GENERATOR MATCHES "Xcode")
# Tell Xcode to regenerate scheme information automatically whenever the # Tell Xcode to regenerate scheme information automatically whenever the
# CMake configuration changes without asking the user # CMake configuration changes without asking the user
set (CMAKE_XCODE_GENERATE_SCHEME 1) set(CMAKE_XCODE_GENERATE_SCHEME 1)
endif() endif()
if (APPLE) if(APPLE)
set (HAVE_STRCASECMP 1) set(HAVE_STRCASECMP 1)
set (HAVE_DIRENT_H 1) set(HAVE_DIRENT_H 1)
set (HAVE_SNPRINTF 1) set(HAVE_SNPRINTF 1)
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)
# we do no longer define WIN32 or _WIN32 (since FLTK 1.4.0) # we do no longer define WIN32 or _WIN32 (since FLTK 1.4.0)
# ... but if we did, we'd define _WIN32 (since FLTK 1.4.0) # ... but if we did, we'd define _WIN32 (since FLTK 1.4.0)
# add_definitions (-D_WIN32) # add_definitions (-D_WIN32)
if (MSVC) if(MSVC)
add_definitions (-DWIN32_LEAN_AND_MEAN) add_definitions (-DWIN32_LEAN_AND_MEAN)
add_definitions (-D_CRT_SECURE_NO_WARNINGS) add_definitions (-D_CRT_SECURE_NO_WARNINGS)
if (NOT MSVC_VERSION VERSION_LESS 1900) # Visual Studio 2015 if(NOT MSVC_VERSION VERSION_LESS 1900) # Visual Studio 2015
add_compile_options (/utf-8) # equivalent to `/source-charset:utf-8 /execution-charset:utf-8` add_compile_options (/utf-8) # equivalent to `/source-charset:utf-8 /execution-charset:utf-8`
endif () endif()
set (BORDER_WIDTH 2) set(BORDER_WIDTH 2)
endif (MSVC) endif(MSVC)
if (MINGW AND EXISTS /mingw) if(MINGW AND EXISTS /mingw)
list(APPEND CMAKE_PREFIX_PATH /mingw) list(APPEND CMAKE_PREFIX_PATH /mingw)
endif (MINGW AND EXISTS /mingw) endif(MINGW AND EXISTS /mingw)
endif (WIN32) endif(WIN32)
####################################################################### #######################################################################
# size of ints # size of ints
@ -130,22 +155,22 @@ CHECK_TYPE_SIZE(int SIZEOF_INT)
CHECK_TYPE_SIZE(long SIZEOF_LONG) CHECK_TYPE_SIZE(long SIZEOF_LONG)
CHECK_TYPE_SIZE("long long" HAVE_LONG_LONG) CHECK_TYPE_SIZE("long long" HAVE_LONG_LONG)
if (${SIZEOF_SHORT} MATCHES "^2$") if(${SIZEOF_SHORT} MATCHES "^2$")
set (U16 "unsigned short") set(U16 "unsigned short")
endif (${SIZEOF_SHORT} MATCHES "^2$") endif(${SIZEOF_SHORT} MATCHES "^2$")
if (${SIZEOF_INT} MATCHES "^4$") if(${SIZEOF_INT} MATCHES "^4$")
set (U32 "unsigned") set(U32 "unsigned")
else () else()
if (${SIZEOF_LONG} MATCHES "^4$") if(${SIZEOF_LONG} MATCHES "^4$")
set (U32 "unsigned long") set(U32 "unsigned long")
endif (${SIZEOF_LONG} MATCHES "^4$") endif(${SIZEOF_LONG} MATCHES "^4$")
endif (${SIZEOF_INT} MATCHES "^4$") endif(${SIZEOF_INT} MATCHES "^4$")
if (${SIZEOF_INT} MATCHES "^8$") if(${SIZEOF_INT} MATCHES "^8$")
set (U64 "unsigned") set(U64 "unsigned")
else () else()
if (${SIZEOF_LONG} MATCHES "^8$") if(${SIZEOF_LONG} MATCHES "^8$")
set (U64 "unsigned long") set(U64 "unsigned long")
endif (${SIZEOF_LONG} MATCHES "^8$") endif(${SIZEOF_LONG} MATCHES "^8$")
endif (${SIZEOF_INT} MATCHES "^8$") endif(${SIZEOF_INT} MATCHES "^8$")

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
@ -17,51 +17,52 @@
####################################################################### #######################################################################
set (DEBUG_VARIABLES_CMAKE 0) set(DEBUG_VARIABLES_CMAKE 0)
if (DEBUG_VARIABLES_CMAKE) if(DEBUG_VARIABLES_CMAKE)
message (STATUS "[** variables.cmake **]") message(STATUS "[** variables.cmake **]")
fl_debug_var (HAVE_DLSYM) fl_debug_var(HAVE_DLSYM)
fl_debug_var (CMAKE_DL_LIBS) fl_debug_var(CMAKE_DL_LIBS)
fl_debug_var (CMAKE_EXE_LINKER_FLAGS) fl_debug_var(CMAKE_EXE_LINKER_FLAGS)
fl_debug_var (LDFLAGS) fl_debug_var(LDFLAGS)
fl_debug_var (LIBS) fl_debug_var(LIBS)
fl_debug_var (GLLIBS) fl_debug_var(GLLIBS)
fl_debug_var (IMAGELIBS) fl_debug_var(IMAGELIBS)
fl_debug_var (STATICIMAGELIBS) fl_debug_var(STATICIMAGELIBS)
fl_debug_var (FLTK_LDLIBS) fl_debug_var(FLTK_LDLIBS)
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)
endif (DEBUG_VARIABLES_CMAKE) fl_debug_var(FLTK_LIBRARIES)
endif(DEBUG_VARIABLES_CMAKE)
####################################################################### #######################################################################
# add several libraries # add several libraries
# FIXME: libraries may need reordering. # FIXME: libraries may need reordering.
# FIXME: check fontconfig conditions (only if Xft is used or ...) # FIXME: check fontconfig conditions (only if Xft is used or ...)
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)
if (LIB_fontconfig) if(LIB_fontconfig)
list(APPEND FLTK_LDLIBS -lfontconfig) list(APPEND FLTK_LDLIBS -lfontconfig)
endif (LIB_fontconfig) endif(LIB_fontconfig)
# add "-ldl" or whatever is necessary according to CMake (CMAKE_DL_LIBS) # add "-ldl" or whatever is necessary according to CMake (CMAKE_DL_LIBS)
if (HAVE_DLSYM) if(HAVE_DLSYM)
foreach (LIB ${CMAKE_DL_LIBS}) foreach(LIB ${CMAKE_DL_LIBS})
list (APPEND FLTK_LDLIBS "-l${LIB}") list(APPEND FLTK_LDLIBS "-l${LIB}")
endforeach () endforeach()
endif (HAVE_DLSYM) endif(HAVE_DLSYM)
####################################################################### #######################################################################
# Set variables for fltk-config (generated from fltk-config.in) # Set variables for fltk-config (generated from fltk-config.in)
@ -75,90 +76,93 @@ endif (HAVE_DLSYM)
# should be set here, whereas variables with different values should # should be set here, whereas variables with different values should
# be set in install.cmake or export.cmake, respectively. # be set in install.cmake or export.cmake, respectively.
if (WIN32) if(WIN32)
set (LDFLAGS "${CMAKE_EXE_LINKER_FLAGS} -mwindows") set(LDFLAGS "${CMAKE_EXE_LINKER_FLAGS} -mwindows")
endif () 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})
endif (LIB_jpeg) list(APPEND STATICIMAGELIBS ${LIB_jpeg})
endif (FLTK_USE_BUILTIN_JPEG) endif(LIB_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})
endif (LIB_png) list(APPEND STATICIMAGELIBS ${LIB_png})
endif (FLTK_USE_BUILTIN_PNG) endif(LIB_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}")
####################################################################### #######################################################################
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})
set (CXXFLAGS "${CFLAGS}") set(CXXFLAGS "${CFLAGS}")
foreach (arg ${FLTK_LDLIBS}) foreach(arg ${FLTK_LDLIBS})
set (LINK_LIBS "${LINK_LIBS} ${arg}") set(LINK_LIBS "${LINK_LIBS} ${arg}")
endforeach (arg ${FLTK_LDLIBS}) endforeach(arg ${FLTK_LDLIBS})
set (LIBS "${LINK_LIBS}") set(LIBS "${LINK_LIBS}")
if (${CMAKE_SYSTEM_NAME} STREQUAL "AIX") if(${CMAKE_SYSTEM_NAME} STREQUAL "AIX")
set (SHAREDSUFFIX "_s") set(SHAREDSUFFIX "_s")
else () else()
set (SHAREDSUFFIX "") set(SHAREDSUFFIX "")
endif (${CMAKE_SYSTEM_NAME} STREQUAL "AIX") endif(${CMAKE_SYSTEM_NAME} STREQUAL "AIX")
if (DEBUG_VARIABLES_CMAKE) if(DEBUG_VARIABLES_CMAKE)
message (STATUS "") # empty line message(STATUS "") # empty line
fl_debug_var (HAVE_DLSYM) fl_debug_var(HAVE_DLSYM)
fl_debug_var (CMAKE_DL_LIBS) fl_debug_var(CMAKE_DL_LIBS)
fl_debug_var (CMAKE_EXE_LINKER_FLAGS) fl_debug_var(CMAKE_EXE_LINKER_FLAGS)
fl_debug_var (LDFLAGS) fl_debug_var(LDFLAGS)
fl_debug_var (LIBS) fl_debug_var(LIBS)
fl_debug_var (GLLIBS) fl_debug_var(GLLIBS)
fl_debug_var (IMAGELIBS) fl_debug_var(IMAGELIBS)
fl_debug_var (STATICIMAGELIBS) fl_debug_var(STATICIMAGELIBS)
fl_debug_var (FLTK_LDLIBS) fl_debug_var(FLTK_LDLIBS)
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)
message (STATUS "[** end of variables.cmake **]") fl_debug_var(FLTK_LIBRARIES)
endif (DEBUG_VARIABLES_CMAKE) message(STATUS "[** end of variables.cmake **]")
unset (DEBUG_VARIABLES_CMAKE) endif(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
@ -27,73 +27,76 @@
# used for Windows (MSVC) shared lib builds much earlier # used for Windows (MSVC) shared lib builds much earlier
# Note 3: More modern CMake features require 3.13...3.15 (Nov 2023) # Note 3: More modern CMake features require 3.13...3.15 (Nov 2023)
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
####################################################################### #######################################################################
project (FLTK VERSION 1.4.0) project(FLTK VERSION 1.4.0)
####################################################################### #######################################################################
# include macro and function definitions for general usage # include macro and function definitions for general usage
####################################################################### #######################################################################
include (CMake/fl_debug_var.cmake) include(CMake/fl_debug_var.cmake)
include (CMake/fl_debug_pkg.cmake) include(CMake/fl_debug_pkg.cmake)
include (CMake/fl_add_library.cmake) include(CMake/fl_add_library.cmake)
# right now we don't use compatibility functions # right now we don't use compatibility functions
# include (CMake/compatibility.cmake) # include(CMake/compatibility.cmake)
if (0) if(0)
fl_debug_var (FLTK_VERSION_MAJOR) fl_debug_var(FLTK_VERSION_MAJOR)
fl_debug_var (FLTK_VERSION_MINOR) fl_debug_var(FLTK_VERSION_MINOR)
fl_debug_var (FLTK_VERSION_PATCH) fl_debug_var(FLTK_VERSION_PATCH)
fl_debug_var (FLTK_VERSION) fl_debug_var(FLTK_VERSION)
fl_debug_var (CMAKE_VERSION) fl_debug_var(CMAKE_VERSION)
endif () endif()
####################################################################### #######################################################################
# basic setup # basic setup
####################################################################### #######################################################################
include (CMake/setup.cmake) include(CMake/setup.cmake)
####################################################################### #######################################################################
# check for headers, libraries and functions # check for headers, libraries and functions
####################################################################### #######################################################################
include (CMake/resources.cmake) include(CMake/resources.cmake)
####################################################################### #######################################################################
# options # options
####################################################################### #######################################################################
include (CMake/options.cmake) include(CMake/options.cmake)
####################################################################### #######################################################################
# print (debug) several build variables and options # print (debug) several build variables and options
####################################################################### #######################################################################
set (debug_build 0) # set to 1 to show debug info set(debug_build 0) # set to 1 to show debug info
if (debug_build) if(debug_build)
message ("") message("")
message (STATUS "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt: set 'debug_build' to 0 to disable the following info:") message(STATUS "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt: set 'debug_build' to 0 to disable the following info:")
fl_debug_var (WIN32) fl_debug_var(WIN32)
fl_debug_var (MINGW) fl_debug_var(MINGW)
fl_debug_var (CYGWIN) fl_debug_var(CYGWIN)
fl_debug_var (MSVC) fl_debug_var(MSVC)
fl_debug_var (UNIX) fl_debug_var(UNIX)
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)
message (STATUS "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt: end of debug_build info.") message(STATUS "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt: end of debug_build info.")
endif (debug_build) endif(debug_build)
unset (debug_build) unset(debug_build)
####################################################################### #######################################################################
# Build a dummy ("empty") Cairo library for backwards compatibility. # Build a dummy ("empty") Cairo library for backwards compatibility.
@ -101,9 +104,9 @@ unset (debug_build)
# in FLTK 1.4.1, 1.4.2, 1.5.0, or whatever the next minor release is. # in FLTK 1.4.1, 1.4.2, 1.5.0, or whatever the next minor release is.
####################################################################### #######################################################################
if (FLTK_HAVE_CAIRO) if(FLTK_HAVE_CAIRO)
add_subdirectory (cairo) add_subdirectory(cairo)
endif () endif()
####################################################################### #######################################################################
# build the standard FLTK libraries # build the standard FLTK libraries
@ -115,17 +118,17 @@ add_subdirectory(src)
# build fluid # build fluid
####################################################################### #######################################################################
if (FLTK_BUILD_FLUID) if(FLTK_BUILD_FLUID)
add_subdirectory (fluid) add_subdirectory(fluid)
endif (FLTK_BUILD_FLUID) endif(FLTK_BUILD_FLUID)
####################################################################### #######################################################################
# build fltk-options # build fltk-options
####################################################################### #######################################################################
if (FLTK_BUILD_FLTK_OPTIONS) if(FLTK_BUILD_FLTK_OPTIONS)
add_subdirectory (fltk-options) add_subdirectory(fltk-options)
endif (FLTK_BUILD_FLTK_OPTIONS) endif(FLTK_BUILD_FLTK_OPTIONS)
####################################################################### #######################################################################
# variables shared by export and install # variables shared by export and install
@ -134,15 +137,15 @@ endif (FLTK_BUILD_FLTK_OPTIONS)
# these two would only differ in paths, so common variables are set here # these two would only differ in paths, so common variables are set here
####################################################################### #######################################################################
include (CMake/variables.cmake) include(CMake/variables.cmake)
####################################################################### #######################################################################
# final config and export # final config and export
####################################################################### #######################################################################
include (CMake/export.cmake) include(CMake/export.cmake)
configure_file ( configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/fl_config.cmake.in ${CMAKE_CURRENT_SOURCE_DIR}/fl_config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/FL/fl_config.h ${CMAKE_CURRENT_BINARY_DIR}/FL/fl_config.h
@ONLY @ONLY
@ -152,184 +155,207 @@ configure_file (
# options to build test/demo and example programs # options to build test/demo and example programs
####################################################################### #######################################################################
if (FLTK_BUILD_TEST) if(FLTK_BUILD_TEST)
add_subdirectory (test) add_subdirectory(test)
endif (FLTK_BUILD_TEST) endif(FLTK_BUILD_TEST)
if (FLTK_BUILD_EXAMPLES) if(FLTK_BUILD_EXAMPLES)
add_subdirectory (examples) add_subdirectory(examples)
endif (FLTK_BUILD_EXAMPLES) endif(FLTK_BUILD_EXAMPLES)
####################################################################### #######################################################################
# installation # installation
####################################################################### #######################################################################
include (CMake/install.cmake) include(CMake/install.cmake)
####################################################################### #######################################################################
# Generate Library Export Headers *** EXPERIMENTAL *** WIP *** # Generate Library Export Headers *** EXPERIMENTAL *** WIP ***
####################################################################### #######################################################################
# 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)
generate_export_header (fltk_SHARED generate_export_header(fltk_SHARED
BASE_NAME fl BASE_NAME fl
EXPORT_FILE_NAME FL/fltk_export.h EXPORT_FILE_NAME FL/fltk_export.h
STATIC_DEFINE FL_STATIC_LIB STATIC_DEFINE FL_STATIC_LIB
) )
if (NOT MSVC) if(NOT MSVC)
# Visual Studio builds only one shared lib (DLL) # Visual Studio builds only one shared lib (DLL)
generate_export_header (fltk_images_SHARED generate_export_header(fltk_images_SHARED
BASE_NAME fl_images BASE_NAME fl_images
EXPORT_FILE_NAME FL/fltk_images_export.h EXPORT_FILE_NAME FL/fltk_images_export.h
STATIC_DEFINE FL_STATIC_LIB STATIC_DEFINE FL_STATIC_LIB
) )
generate_export_header (fltk_forms_SHARED generate_export_header(fltk_forms_SHARED
BASE_NAME fl_forms BASE_NAME fl_forms
EXPORT_FILE_NAME FL/fltk_forms_export.h EXPORT_FILE_NAME FL/fltk_forms_export.h
STATIC_DEFINE FL_STATIC_LIB STATIC_DEFINE FL_STATIC_LIB
) )
generate_export_header (fltk_gl_SHARED generate_export_header(fltk_gl_SHARED
BASE_NAME fl_gl BASE_NAME fl_gl
EXPORT_FILE_NAME FL/fltk_gl_export.h EXPORT_FILE_NAME FL/fltk_gl_export.h
STATIC_DEFINE FL_STATIC_LIB STATIC_DEFINE FL_STATIC_LIB
) )
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
####################################################################### #######################################################################
include (FeatureSummary) include(FeatureSummary)
message ("") message("")
set (_descr "${PROJECT_NAME} ${FLTK_VERSION} generated by CMake ${CMAKE_VERSION}") set(_descr "${PROJECT_NAME} ${FLTK_VERSION} generated by CMake ${CMAKE_VERSION}")
feature_summary (WHAT ALL DESCRIPTION "Configuration Summary for ${_descr} --\n") 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)
message (STATUS "The forms library will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib") message(STATUS "The forms library will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib")
else () 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 () endif()
if (FLTK_BUILD_FLTK_OPTIONS) if(FLTK_BUILD_FLUID)
message (STATUS "fltk-options will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fltk-options") message(STATUS "fluid will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fluid")
else () else()
message (STATUS "fltk-options will not be built (set FLTK_BUILD_FLTK_OPTIONS=ON to build)") message(STATUS "fluid will not be built (set FLTK_BUILD_FLUID=ON to build)")
endif () endif()
if (FLTK_BUILD_TEST) if(FLTK_BUILD_FLTK_OPTIONS)
message (STATUS "Test programs will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/test") message(STATUS "fltk-options will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fltk-options")
else () else()
message (STATUS "Test programs will not be built (set FLTK_BUILD_TEST=ON to build)") message(STATUS "fltk-options will not be built (set FLTK_BUILD_FLTK_OPTIONS=ON to build)")
endif () endif()
if (FLTK_BUILD_EXAMPLES) if(FLTK_BUILD_TEST)
message (STATUS "Example programs will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/examples") message(STATUS "Test programs will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/test")
else () else()
message (STATUS "Example programs will not be built (set FLTK_BUILD_EXAMPLES=ON to build)") message(STATUS "Test programs will not be built (set FLTK_BUILD_TEST=ON to build)")
endif () endif()
message (STATUS "") if(FLTK_BUILD_EXAMPLES)
message(STATUS "Example programs will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/examples")
else()
message(STATUS "Example programs will not be built (set FLTK_BUILD_EXAMPLES=ON to build)")
endif()
if (CMAKE_BUILD_TYPE STREQUAL "") message(STATUS "")
message (STATUS "Build configuration : <unspecified>")
else ()
message (STATUS "Build configuration : ${CMAKE_BUILD_TYPE}")
endif ()
message (STATUS "") if(CMAKE_BUILD_TYPE STREQUAL "")
message(STATUS "Build configuration : <unspecified>")
else()
message(STATUS "Build configuration : ${CMAKE_BUILD_TYPE}")
endif()
if (FLTK_USE_BUILTIN_JPEG) message(STATUS "")
message (STATUS "Image Libraries : JPEG = Builtin")
else ()
message (STATUS "Image Libraries : JPEG = System")
endif ()
if (FLTK_USE_BUILTIN_PNG) if(FLTK_USE_BUNDLED_JPEG)
message (STATUS " : PNG = Builtin") message(STATUS "Image Libraries : JPEG = Builtin")
else () else()
message (STATUS " : PNG = System") message(STATUS "Image Libraries : JPEG = System")
endif () endif()
if (FLTK_USE_BUILTIN_ZLIB) if(FLTK_USE_BUNDLED_PNG)
message (STATUS " : ZLIB = Builtin") message(STATUS " : PNG = Builtin")
else () else()
message (STATUS " : ZLIB = System") message(STATUS " : PNG = System")
endif () endif()
if (UNIX AND NOT (APPLE AND NOT OPTION_APPLE_X11)) if(FLTK_USE_BUNDLED_ZLIB)
message(STATUS " : ZLIB = Builtin")
else()
message(STATUS " : ZLIB = System")
endif()
if (OPTION_USE_WAYLAND) if(UNIX AND NOT (APPLE AND NOT FLTK_BACKEND_X11))
message (STATUS "Use Wayland : Yes (if available at run-time)")
if (OPTION_USE_SYSTEM_LIBDECOR)
message (STATUS "Use system libdecor : Yes")
else ()
message (STATUS "Use system libdecor : No")
endif ()
else ()
message (STATUS "Use Wayland : No (therefore, X11 is used)")
endif ()
if (FLTK_USE_CAIRO) if(FLTK_BACKEND_WAYLAND)
message (STATUS "All drawing uses Cairo : Yes") message(STATUS "Use Wayland : Yes (if available at run-time)")
else () if(USE_SYSTEM_LIBDECOR)
message (STATUS "All drawing uses Cairo : No") message(STATUS "Use system libdecor : Yes")
endif () else()
message(STATUS "Use system libdecor : No")
endif()
else()
message(STATUS "Use Wayland : No (therefore, X11 is used)")
endif()
if (USE_PANGO) if(FLTK_USE_CAIRO)
message (STATUS "Use Pango : Yes") message(STATUS "All drawing uses Cairo : Yes")
else (USE_PANGO) else()
message (STATUS "Use Pango : No") message(STATUS "All drawing uses Cairo : No")
if (USE_XFT) endif()
message (STATUS "Use Xft : Yes")
else ()
message (STATUS "Use Xft : No")
endif (USE_XFT)
endif (USE_PANGO)
endif (UNIX AND NOT (APPLE AND NOT OPTION_APPLE_X11)) if(USE_PANGO)
message(STATUS "Use Pango : Yes")
else()
message(STATUS "Use Pango : No")
if(USE_XFT)
message(STATUS "Use Xft : Yes")
else()
message(STATUS "Use Xft : No")
endif()
endif()
if (FLTK_HAVE_CAIROEXT) endif()
message (STATUS "Fl_Cairo_Window support : Yes (extended)")
elseif (FLTK_HAVE_CAIRO)
message (STATUS "Fl_Cairo_Window support : Yes (standard)")
else ()
message (STATUS "Fl_Cairo_Window support : No")
endif ()
if (FLTK_USE_STD) if(FLTK_HAVE_CAIROEXT)
message (STATUS "Use std:: : Yes") message(STATUS "Fl_Cairo_Window support : Yes (extended)")
else () elseif(FLTK_HAVE_CAIRO)
message (STATUS "Use std:: : No") message(STATUS "Fl_Cairo_Window support : Yes (standard)")
endif () else()
message(STATUS "Fl_Cairo_Window support : No")
endif()
message ("") if(FLTK_USE_STD)
message (STATUS "End of Configuration Summary --\n") message(STATUS "Use std:: : Yes")
else()
message(STATUS "Use std:: : No")
endif()
message("")
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

File diff suppressed because it is too large Load Diff

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.
@ -61,7 +77,7 @@ variable OPTION_CAIRO:BOOL=ON is set.
transparently a Cairo context to your custom Fl_Window derived class. transparently a Cairo context to your custom Fl_Window derived class.
This function is intended to be used in your overloaded draw() method. This function is intended to be used in your overloaded draw() method.
(3) FLTK instrumentation for cairo extended use : (3) FLTK instrumentation for cairo extended use:
Adding an optional Cairo autolink context mode support which permits Adding an optional Cairo autolink context mode support which permits
complete and automatic synchronization of OS dependent graphical context complete and automatic synchronization of OS dependent graphical context
and Cairo contexts, thus furthering a valid Cairo context anytime, and Cairo contexts, thus furthering a valid Cairo context anytime,
@ -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

@ -25,15 +25,19 @@
# Build dummy fltk_cairo library # Build dummy fltk_cairo library
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

@ -14,37 +14,37 @@
# https://www.fltk.org/bugs.php # https://www.fltk.org/bugs.php
# #
set (DOCS) set(DOCS)
set (GENERATE_DOCS FALSE) set(GENERATE_DOCS FALSE)
set (GIT_REVISION "") 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 "")
endif () endif()
#------------------------------------------------ #------------------------------------------------
# generate files used for both HTML and PDF docs # generate files used for both HTML and PDF docs
#------------------------------------------------ #------------------------------------------------
if (GENERATE_DOCS) if(GENERATE_DOCS)
# create required variables # create required variables
execute_process (COMMAND date "+%Y" execute_process(COMMAND date "+%Y"
OUTPUT_VARIABLE YEAR OUTPUT_VARIABLE YEAR
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
# note: current locale is used for abbreviated month # note: current locale is used for abbreviated month
execute_process (COMMAND date "+%b %d, %Y" execute_process(COMMAND date "+%b %d, %Y"
OUTPUT_VARIABLE CURRENT_DATE OUTPUT_VARIABLE CURRENT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
@ -56,16 +56,17 @@ if (GENERATE_DOCS)
# In the future tarball/zip generation should create a file # In the future tarball/zip generation should create a file
# 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
) )
# set to "'unkown'" if git is not available # set to "'unkown'" if git is not available
if (GIT_REVISION STREQUAL "") if(GIT_REVISION STREQUAL "")
set (GIT_REVISION "'unkown'") set(GIT_REVISION "'unkown'")
endif() endif()
# Find "short" doxygen version if it was built from Git # Find "short" doxygen version if it was built from Git
@ -75,56 +76,56 @@ if (GENERATE_DOCS)
# code once we require this as our minimal version and replace the # code once we require this as our minimal version and replace the
# variable DOXYGEN_VERSION_SHORT with DOXYGEN_VERSION below. # variable DOXYGEN_VERSION_SHORT with DOXYGEN_VERSION below.
if (DOXYGEN_FOUND) if(DOXYGEN_FOUND)
# strip trailing git revision if doxygen was built from source # strip trailing git revision if doxygen was built from source
string (REGEX REPLACE " .*$" "" DOXYGEN_VERSION_SHORT ${DOXYGEN_VERSION}) string(REGEX REPLACE " .*$" "" DOXYGEN_VERSION_SHORT ${DOXYGEN_VERSION})
endif (DOXYGEN_FOUND) endif(DOXYGEN_FOUND)
# configure copyright.dox (includes current year) # configure copyright.dox (includes current year)
configure_file ( configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/copyright.dox.in ${CMAKE_CURRENT_SOURCE_DIR}/copyright.dox.in
${CMAKE_CURRENT_BINARY_DIR}/copyright.dox ${CMAKE_CURRENT_BINARY_DIR}/copyright.dox
@ONLY @ONLY
) )
# configure generated.dox (includes date and versions) # configure generated.dox (includes date and versions)
configure_file ( configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/generated.dox.in ${CMAKE_CURRENT_SOURCE_DIR}/generated.dox.in
${CMAKE_CURRENT_BINARY_DIR}/generated.dox ${CMAKE_CURRENT_BINARY_DIR}/generated.dox
@ONLY @ONLY
) )
if (0) # debug if(0) # debug
fl_debug_var (YEAR) fl_debug_var(YEAR)
fl_debug_var (CURRENT_DATE) fl_debug_var(CURRENT_DATE)
fl_debug_var (GIT_REVISION) fl_debug_var(GIT_REVISION)
fl_debug_var (DOXYGEN_FOUND) fl_debug_var(DOXYGEN_FOUND)
fl_debug_var (DOXYGEN_EXECUTABLE) fl_debug_var(DOXYGEN_EXECUTABLE)
fl_debug_var (DOXYGEN_VERSION) fl_debug_var(DOXYGEN_VERSION)
fl_debug_var (DOXYGEN_VERSION_SHORT) fl_debug_var(DOXYGEN_VERSION_SHORT)
endif () endif()
endif (GENERATE_DOCS) 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)
# generate Doxygen file "Doxyfile" # generate Doxygen file "Doxyfile"
set (GENERATE_HTML YES) set(GENERATE_HTML YES)
set (GENERATE_LATEX NO) set(GENERATE_LATEX NO)
set (LATEX_HEADER "") set(LATEX_HEADER "")
set (DOXYFILE "Doxyfile") set(DOXYFILE "Doxyfile")
set (LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}_error.log") set(LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}_error.log")
# configure Doxygen input file for HTML docs (Doxyfile.in) # configure Doxygen input file for HTML docs (Doxyfile.in)
configure_file ( configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}.in ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}.in
@ONLY @ONLY
@ -132,7 +133,7 @@ if (OPTION_BUILD_HTML_DOCUMENTATION)
# convert Doxyfile to used doxygen version # convert Doxyfile to used doxygen version
add_custom_command ( add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE} OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/convert_doxyfile COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/convert_doxyfile
@ -146,34 +147,34 @@ if (OPTION_BUILD_HTML_DOCUMENTATION)
# generate HTML documentation # generate HTML documentation
add_custom_target (html add_custom_target(html
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE} COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
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)
# generate Doxygen input file "Doxybook" # generate Doxygen input file "Doxybook"
set (GENERATE_HTML NO) set(GENERATE_HTML NO)
set (GENERATE_LATEX YES) set(GENERATE_LATEX YES)
set (LATEX_HEADER "${CMAKE_CURRENT_BINARY_DIR}/fltk-book.tex") set(LATEX_HEADER "${CMAKE_CURRENT_BINARY_DIR}/fltk-book.tex")
set (DOXYFILE "Doxybook") set(DOXYFILE "Doxybook")
set (LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}_error.log") set(LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}_error.log")
# configure Doxygen input file for PDF docs (Doxybook.in) # configure Doxygen input file for PDF docs (Doxybook.in)
configure_file ( configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}.in ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}.in
@ONLY @ONLY
@ -181,7 +182,7 @@ if (OPTION_BUILD_PDF_DOCUMENTATION)
# convert Doxybook to current doxygen version # convert Doxybook to current doxygen version
add_custom_command ( add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE} OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/convert_doxyfile COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/convert_doxyfile
@ -195,7 +196,7 @@ if (OPTION_BUILD_PDF_DOCUMENTATION)
# generate LaTeX title fltk-title.tex # generate LaTeX title fltk-title.tex
configure_file ( configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/fltk-title.tex.in ${CMAKE_CURRENT_SOURCE_DIR}/src/fltk-title.tex.in
${CMAKE_CURRENT_BINARY_DIR}/fltk-title.tex ${CMAKE_CURRENT_BINARY_DIR}/fltk-title.tex
@ONLY @ONLY
@ -203,7 +204,7 @@ if (OPTION_BUILD_PDF_DOCUMENTATION)
# generate fltk.pdf # generate fltk.pdf
add_custom_command ( add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fltk.pdf OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fltk.pdf
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/make_header COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/make_header
${DOXYGEN_EXECUTABLE} ${DOXYGEN_EXECUTABLE}
@ -220,40 +221,40 @@ if (OPTION_BUILD_PDF_DOCUMENTATION)
# add target 'pdf' # add target 'pdf'
add_custom_target (pdf add_custom_target(pdf
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
#---------------------------------- #----------------------------------
if (DOCS) if(DOCS)
add_custom_target (docs add_custom_target(docs
DEPENDS ${DOCS} DEPENDS ${DOCS}
) )
endif (DOCS) 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
@ -15,11 +15,11 @@
# #
################################################################################ ################################################################################
include (../CMake/fl_create_example.cmake) include(../CMake/fl_create_example.cmake)
include (../CMake/FLTK-Functions.cmake) include(../CMake/FLTK-Functions.cmake)
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../bin/examples) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../bin/examples)
file (MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
################################################################################ ################################################################################
@ -30,7 +30,7 @@ file (MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
# simple examples w/o extra libs # simple examples w/o extra libs
############################################################ ############################################################
set (SIMPLE_SOURCES set(SIMPLE_SOURCES
browser-simple browser-simple
callbacks callbacks
chart-simple chart-simple
@ -75,7 +75,7 @@ set (SIMPLE_SOURCES
# simple FLUID examples w/o extra libs # simple FLUID examples w/o extra libs
############################################################ ############################################################
set (FLUID_SOURCES set(FLUID_SOURCES
fluid-callback fluid-callback
) )
@ -83,7 +83,7 @@ set (FLUID_SOURCES
# examples requiring fltk_images # examples requiring fltk_images
############################################################ ############################################################
set (IMAGE_SOURCES set(IMAGE_SOURCES
animgifimage animgifimage
animgifimage-play animgifimage-play
animgifimage-resize animgifimage-resize
@ -95,7 +95,7 @@ set (IMAGE_SOURCES
# examples requiring cairo # examples requiring cairo
############################################################ ############################################################
set (CAIRO_SOURCES set(CAIRO_SOURCES
cairo-draw-x cairo-draw-x
) )
@ -103,7 +103,7 @@ set (CAIRO_SOURCES
# examples requiring OpenGL + libGLEW # examples requiring OpenGL + libGLEW
############################################################ ############################################################
set (OPENGL_SOURCES set(OPENGL_SOURCES
OpenGL3-glut-test OpenGL3-glut-test
OpenGL3test OpenGL3test
) )
@ -112,42 +112,42 @@ set (OPENGL_SOURCES
# create simple example programs # create simple example programs
############################################################ ############################################################
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)
############################################################ ############################################################
# create FLUID example programs # create FLUID example programs
############################################################ ############################################################
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)
############################################################ ############################################################
# create example programs with fltk_images library # create example programs with fltk_images library
############################################################ ############################################################
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)
############################################################ ############################################################
# create example programs requiring cairo # create example programs requiring cairo
############################################################ ############################################################
if (FLTK_HAVE_CAIRO) if(FLTK_HAVE_CAIRO)
set (cairo_libs "fltk;cairo") set(cairo_libs "fltk;cairo")
if (TARGET fltk_cairo) if(TARGET fltk_cairo)
set (cairo_libs fltk_cairo ${cairo_libs}) set(cairo_libs fltk_cairo ${cairo_libs})
endif () endif()
else () else()
set(cairo_libs "fltk") set(cairo_libs "fltk")
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)
############################################################ ############################################################
# create example programs with OpenGL + libGLEW # create example programs with OpenGL + libGLEW
@ -155,25 +155,25 @@ 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()
set (REQUIRED_LIBS fltk_gl fltk ${OPENGL_LIBRARIES}) set(REQUIRED_LIBS fltk_gl fltk ${OPENGL_LIBRARIES})
else () else()
set (REQUIRED_LIBS fltk_gl fltk ${LIB_GLEW} ${OPENGL_LIBRARIES}) set(REQUIRED_LIBS fltk_gl fltk ${LIB_GLEW} ${OPENGL_LIBRARIES})
endif () 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
"OpenGL or libGLEW not present: OpenGL example programs will not be built.") "OpenGL or libGLEW not present: OpenGL example programs will not be built.")
fl_debug_var (OPENGL_FOUND) fl_debug_var(OPENGL_FOUND)
fl_debug_var (LIB_GLEW) fl_debug_var(LIB_GLEW)
message ("") message("")
endif (OPENGL_FOUND AND LIB_GLEW) endif(OPENGL_FOUND AND LIB_GLEW)
unset (REQUIRED_LIBS) unset(REQUIRED_LIBS)

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,71 +14,59 @@
# 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
set (WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/fltk-options") set(WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/fltk-options")
add_custom_command ( add_custom_command(
TARGET fltk-options POST_BUILD TARGET fltk-options POST_BUILD
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/../CMake/macOS-bundle-wrapper.in ${WRAPPER} COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/../CMake/macOS-bundle-wrapper.in ${WRAPPER}
COMMAND chmod u+x,g+x,o+x ${WRAPPER} COMMAND chmod u+x,g+x,o+x ${WRAPPER}
BYPRODUCTS ${WRAPPER} BYPRODUCTS ${WRAPPER}
VERBATIM VERBATIM
) )
unset (WRAPPER) unset(WRAPPER)
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) endif()
target_link_directories (fltk-options-cmd PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
endif (FLTK_HAVE_CAIRO)
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
@ -90,49 +78,49 @@ if (APPLE AND (NOT OPTION_APPLE_X11))
# one included in the bundle. # one included in the bundle.
# create bundle # create bundle
set_target_properties (fltk-options PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/fltk-options.plist") set_target_properties(fltk-options PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/fltk-options.plist")
set_target_properties (fltk-options PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME}) set_target_properties(fltk-options PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
set_target_properties (fltk-options PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.fltk-options") set_target_properties(fltk-options PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.fltk-options")
# The line below would wrongly install /Applications/fltk-options.icns # The line below would wrongly install /Applications/fltk-options.icns
# ## set_target_properties (fltk-options PROPERTIES RESOURCE ${ICON_PATH}) # ## set_target_properties(fltk-options PROPERTIES RESOURCE ${ICON_PATH})
# install fltk-options GUI and commandline tools # install fltk-options GUI and commandline tools
#install (TARGETS fltk-options DESTINATION "/Applications") # install(TARGETS fltk-options DESTINATION "/Applications")
# install command line tool # install command line tool
install (PROGRAMS $<TARGET_FILE:fltk-options> DESTINATION ${FLTK_BINDIR}) install(PROGRAMS $<TARGET_FILE:fltk-options> DESTINATION ${FLTK_BINDIR})
else() 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
DESTINATION ${FLTK_DATADIR}/applications DESTINATION ${FLTK_DATADIR}/applications
) )
# Install mime-type file (x-fltk-options.desktop method is deprecated) # Install mime-type file(x-fltk-options.desktop method is deprecated)
install (FILES fltk-options.xml install(FILES fltk-options.xml
DESTINATION ${FLTK_DATADIR}/mime/packages DESTINATION ${FLTK_DATADIR}/mime/packages
) )
# Install desktop icons # Install desktop icons
foreach (icon 32 48 64 128) foreach(icon 32 48 64 128)
install (FILES icons/fltk-options-${icon}.png install(FILES icons/fltk-options-${icon}.png
DESTINATION ${FLTK_DATADIR}/icons/hicolor/${icon}x${icon}/apps DESTINATION ${FLTK_DATADIR}/icons/hicolor/${icon}x${icon}/apps
RENAME fltk-options.png RENAME fltk-options.png
) )
endforeach() endforeach()
endif (UNIX) endif(UNIX)

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,9 +14,14 @@
# 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)
set (CPPFILES # 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
CodeEditor.cxx CodeEditor.cxx
StyleParse.cxx StyleParse.cxx
Fd_Snap_Action.cxx Fd_Snap_Action.cxx
@ -50,7 +55,7 @@ set (CPPFILES
# List header files in Apple's Xcode IDE # List header files in Apple's Xcode IDE
set (HEADERFILES set(HEADERFILES
CodeEditor.h CodeEditor.h
Fd_Snap_Action.h Fd_Snap_Action.h
Fl_Function_Type.h Fl_Function_Type.h
@ -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
@ -85,19 +91,19 @@ set (HEADERFILES
# Add ExternalCodeEditor: platform specific files # Add ExternalCodeEditor: platform specific files
if (WIN32) if(WIN32)
list (APPEND CPPFILES ExternalCodeEditor_WIN32.cxx) list(APPEND CPPFILES ExternalCodeEditor_WIN32.cxx)
list (APPEND HEADERFILES ExternalCodeEditor_WIN32.h) list(APPEND HEADERFILES ExternalCodeEditor_WIN32.h)
else () else()
list (APPEND CPPFILES ExternalCodeEditor_UNIX.cxx) list(APPEND CPPFILES ExternalCodeEditor_UNIX.cxx)
list (APPEND HEADERFILES ExternalCodeEditor_UNIX.h) list(APPEND HEADERFILES ExternalCodeEditor_UNIX.h)
endif (WIN32) endif(WIN32)
source_group("Header Files" FILES ${HEADERFILES}) source_group("Header Files" FILES ${HEADERFILES})
# make a group in the IDE for easy access to documentation files # make a group in the IDE for easy access to documentation files
set ( USER_DOC_FILES set(USER_DOC_FILES
Doxyfile Doxyfile
documentation/src/index.dox documentation/src/index.dox
documentation/src/page_introduction.dox documentation/src/page_introduction.dox
@ -119,7 +125,7 @@ set ( USER_DOC_FILES
) )
source_group("Documentation: User" FILES ${USER_DOC_FILES}) source_group("Documentation: User" FILES ${USER_DOC_FILES})
set ( DEV_DOC_FILES set(DEV_DOC_FILES
Doxyfile-dev Doxyfile-dev
documentation/src-dev/index.dox documentation/src-dev/index.dox
documentation/src-dev/page_introduction.dox documentation/src-dev/page_introduction.dox
@ -127,93 +133,61 @@ 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
set (WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/fluid") set(WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/fluid")
add_custom_command ( add_custom_command(
TARGET fluid POST_BUILD TARGET fluid POST_BUILD
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/../CMake/macOS-bundle-wrapper.in ${WRAPPER} COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/../CMake/macOS-bundle-wrapper.in ${WRAPPER}
COMMAND chmod u+x,g+x,o+x ${WRAPPER} COMMAND chmod u+x,g+x,o+x ${WRAPPER}
BYPRODUCTS ${WRAPPER} BYPRODUCTS ${WRAPPER}
VERBATIM VERBATIM
) )
unset (WRAPPER) unset(WRAPPER)
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)
endif()
# Link fluid-cmd with Cairo if OPTION_CAIRO is enabled (same as above) # Create aliases for all targets
if (FLTK_HAVE_CAIRO) foreach(tgt ${TARGETS})
target_include_directories (fluid-cmd PRIVATE ${PKG_CAIRO_INCLUDE_DIRS}) add_executable(fltk::${tgt} ALIAS ${tgt})
if (PKG_CAIRO_LIBRARY_DIRS) endforeach()
target_link_directories (fluid-cmd PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
endif ()
endif (FLTK_HAVE_CAIRO)
endif (WIN32)
# Build fluid-shared (experimental)
if (OPTION_BUILD_SHARED_LIBS)
list (APPEND FLUID_TARGETS fluid-shared)
add_executable (fluid-shared fluid.cxx fluid.h)
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
@ -224,48 +198,48 @@ if (APPLE AND (NOT OPTION_APPLE_X11))
# included in the bundle. # included in the bundle.
# create bundle # create bundle
set_target_properties (fluid PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/fluid.plist") set_target_properties(fluid PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/fluid.plist")
set_target_properties (fluid PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME}) set_target_properties(fluid PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
set_target_properties (fluid PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.fluid") set_target_properties(fluid PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.fluid")
# The line below would wrongly install /Applications/fluid.icns # The line below would wrongly install /Applications/fluid.icns
# ## set_target_properties (fluid PROPERTIES RESOURCE ${ICON_PATH}) # ## set_target_properties(fluid PROPERTIES RESOURCE ${ICON_PATH})
# install fluid GUI and commandline tools # install fluid GUI and commandline tools
# install (TARGETS fluid DESTINATION "/Applications") # install(TARGETS fluid DESTINATION "/Applications")
# install command line tool # install command line tool
install (PROGRAMS $<TARGET_FILE:fluid> DESTINATION ${FLTK_BINDIR}) install(PROGRAMS $<TARGET_FILE:fluid> DESTINATION ${FLTK_BINDIR})
else() 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
if (UNIX) if(UNIX)
install (FILES fluid.desktop install(FILES fluid.desktop
DESTINATION ${FLTK_DATADIR}/applications DESTINATION ${FLTK_DATADIR}/applications
) )
# Install mime-type file (x-fluid.desktop method is deprecated) # Install mime-type file(x-fluid.desktop method is deprecated)
install (FILES fluid.xml install(FILES fluid.xml
DESTINATION ${FLTK_DATADIR}/mime/packages DESTINATION ${FLTK_DATADIR}/mime/packages
) )
# Install desktop icons # Install desktop icons
foreach (icon 32 48 64 128) foreach(icon 32 48 64 128)
install (FILES icons/fluid-${icon}.png install(FILES icons/fluid-${icon}.png
DESTINATION ${FLTK_DATADIR}/icons/hicolor/${icon}x${icon}/apps DESTINATION ${FLTK_DATADIR}/icons/hicolor/${icon}x${icon}/apps
RENAME fluid.png RENAME fluid.png
) )
endforeach() endforeach()
endif (UNIX) endif(UNIX)

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
@ -18,70 +18,99 @@
# (For now, let's use the mode that requires the image fit into memory. # (For now, let's use the mode that requires the image fit into memory.
# This is the recommended mode for Win32 anyway.) # This is the recommended mode for Win32 anyway.)
set (systemdependent_SRCS jmemnobs.c) set(systemdependent_SRCS jmemnobs.c)
# library object files common to compression and decompression # library object files common to compression and decompression
set (common_SRCS set(common_SRCS
jaricom.c jcomapi.c jutils.c jerror.c jmemmgr.c jaricom.c jcomapi.c jutils.c jerror.c jmemmgr.c
) )
# compression library object files # compression library object files
set (compression_SRCS set(compression_SRCS
jcapimin.c jcapistd.c jcarith.c jctrans.c jcparam.c jdatadst.c jcinit.c jcapimin.c jcapistd.c jcarith.c jctrans.c jcparam.c jdatadst.c jcinit.c
jcmaster.c jcmarker.c jcmainct.c jcprepct.c jccoefct.c jccolor.c jcmaster.c jcmarker.c jcmainct.c jcprepct.c jccoefct.c jccolor.c
jcsample.c jchuff.c jcdctmgr.c jfdctfst.c jfdctflt.c jcsample.c jchuff.c jcdctmgr.c jfdctfst.c jfdctflt.c
jfdctint.c jfdctint.c
) )
# decompression library object files # decompression library object files
set (decompression_SRCS set(decompression_SRCS
jdapimin.c jdapistd.c jdarith.c jdtrans.c jdatasrc.c jdmaster.c jdapimin.c jdapistd.c jdarith.c jdtrans.c jdatasrc.c jdmaster.c
jdinput.c jdmarker.c jdhuff.c jdmainct.c jdcoefct.c jdinput.c jdmarker.c jdhuff.c jdmainct.c jdcoefct.c
jdpostct.c jddctmgr.c jidctfst.c jidctflt.c jidctint.c jdpostct.c jddctmgr.c jidctfst.c jidctflt.c jidctint.c
jdsample.c jdcolor.c jquant1.c jquant2.c jdmerge.c jdsample.c jdcolor.c jquant1.c jquant2.c jdmerge.c
) )
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>
)
set (msvc_warnings /wd4267) # Suppress Visual Studio compiler warnings
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)
if (MSVC) target_include_directories(${target} PUBLIC ${_include_dirs})
target_compile_options (fltk_jpeg PRIVATE ${msvc_warnings})
endif (MSVC) if(MSVC)
target_compile_options(${target} PRIVATE ${msvc_warnings})
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)
if (MSVC) fl_add_library(fltk_jpeg SHARED "${BUILD_SRCS}")
target_compile_options (fltk_jpeg_SHARED PRIVATE ${msvc_warnings}) set(target fltk_jpeg-shared)
endif (MSVC)
endif (OPTION_BUILD_SHARED_LIBS) target_include_directories(${target} PUBLIC ${_include_dirs})
if(MSVC)
target_compile_options(${target} PRIVATE ${msvc_warnings})
endif(MSVC)
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
@ -15,7 +15,7 @@
# #
# source files for png # source files for png
set (PNG_SRCS set(PNG_SRCS
png.c png.c
pngerror.c pngerror.c
pngget.c pngget.c
@ -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.
####################################################################### #######################################################################
####################################################################### #######################################################################
@ -49,55 +49,93 @@ set (PNG_SRCS
# compile these files even if this results in some warnings. # compile these files even if this results in some warnings.
# This includes all non-macOS platforms. # This includes all non-macOS platforms.
if (CMAKE_OSX_ARCHITECTURES) if(CMAKE_OSX_ARCHITECTURES)
string (REGEX MATCH "arm64" is_arm "${CMAKE_OSX_ARCHITECTURES}") string(REGEX MATCH "arm64" is_arm "${CMAKE_OSX_ARCHITECTURES}")
else () else()
set (is_arm TRUE) set(is_arm TRUE)
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
) )
endif () 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)
endif () 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()
####################################################################### #######################################################################
# Install the library headers # Install the library headers
####################################################################### #######################################################################
install (FILES png.h pngconf.h pnglibconf.h pngprefix.h install(FILES png.h pngconf.h pnglibconf.h pngprefix.h
DESTINATION ${FLTK_INCLUDEDIR}/FL/images DESTINATION ${FLTK_INCLUDEDIR}/FL/images
) )

File diff suppressed because it is too large Load Diff

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
@ -15,45 +15,39 @@
# #
####################################################################### #######################################################################
include (../CMake/FLTK-Functions.cmake) include(../CMake/FLTK-Functions.cmake)
include (../CMake/fl_create_example.cmake) include(../CMake/fl_create_example.cmake)
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../bin/test) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../bin/test)
set (TESTFILE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../data) set(TESTFILE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../data)
# create data and binary directory to copy scripts and data files # create data and binary directory to copy scripts and data files
file (MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
file (MAKE_DIRECTORY ${TESTFILE_PATH}) file(MAKE_DIRECTORY ${TESTFILE_PATH})
#######################################################################
# audio libs for test apps
if (WIN32)
set (AUDIOLIBS winmm)
elseif (APPLE)
set (AUDIOLIBS "-framework CoreAudio")
elseif (HAVE_ALSA_ASOUNDLIB_H)
find_library(LIB_asound asound)
if (LIB_asound)
set (AUDIOLIBS ${LIB_asound})
endif (LIB_asound)
mark_as_advanced (LIB_asound)
endif (WIN32)
#######################################################################
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
####################################################################### #######################################################################
# Define additional example programs for testing, for instance: # Define additional example programs for testing, for instance:
# set (extra_tests issue-276 str-1895) # set(extra_tests issue-276 str-1895)
# Use the source file test/'name'.cxx for each additional program. # Use the source file test/'name'.cxx for each additional program.
# These test programs will be built with image and GL libraries. # These test programs will be built with image and GL libraries.
# Leave the variable 'extra_tests' empty to disable extra test programs. # Leave the variable 'extra_tests' empty to disable extra test programs.
set (extra_tests) set(extra_tests)
#######################################################################
# audio libs for test apps
if(WIN32)
set(AUDIOLIBS winmm)
elseif(APPLE)
set(AUDIOLIBS "-framework CoreAudio")
elseif(HAVE_ALSA_ASOUNDLIB_H)
find_library(LIB_asound asound)
if(LIB_asound)
set(AUDIOLIBS ${LIB_asound})
endif(LIB_asound)
mark_as_advanced (LIB_asound)
endif(WIN32)
####################################################################### #######################################################################
# Define standard libraries for those OpenGL demos that can be built # Define standard libraries for those OpenGL demos that can be built
@ -63,119 +57,119 @@ set (extra_tests)
# Note: use "${GLDEMO_LIBS}" for their library parameter # Note: use "${GLDEMO_LIBS}" for their library parameter
# 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,43 +191,43 @@ 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
# We need to link with fl_call_main.c, but this must not be compiled with # We need to link with fl_call_main.c, but this must not be compiled with
# macro FL_DLL, whereas the other source file(s) must be compiled with FL_DLL # macro FL_DLL, whereas the other source file(s) must be compiled with FL_DLL
@ -251,44 +245,41 @@ if (OPTION_BUILD_SHARED_LIBS)
add_library (CALL_MAIN OBJECT EXCLUDE_FROM_ALL ../src/fl_call_main.c) add_library (CALL_MAIN OBJECT EXCLUDE_FROM_ALL ../src/fl_call_main.c)
# 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)
if (OPENGL_FOUND) list(APPEND SHARED_TARGETS hello pixmap_browser unittests)
CREATE_EXAMPLE (glpuzzle-shared glpuzzle.cxx "fltk_SHARED;CALL_MAIN;${OPENGL_LIBRARIES}")
CREATE_EXAMPLE (shape-shared shape.cxx "fltk_SHARED;CALL_MAIN;${OPENGL_LIBRARIES}") if(OPENGL_FOUND)
list (APPEND SHARED_TARGETS glpuzzle shape) fl_create_example(glpuzzle-shared glpuzzle.cxx "CALL_MAIN;${GLDEMO_SHARED}")
endif (OPENGL_FOUND) fl_create_example(shape-shared shape.cxx "CALL_MAIN;${GLDEMO_SHARED}")
list(APPEND SHARED_TARGETS glpuzzle shape)
endif(OPENGL_FOUND)
# apply property COMPILE_DEFINITIONS "-D FL_DLL" in a loop for all necessary source files # apply property COMPILE_DEFINITIONS "-D FL_DLL" in a loop for all necessary source files
foreach (tgt ${SHARED_TARGETS}) foreach(tgt ${SHARED_TARGETS})
target_compile_definitions (${tgt}-shared PRIVATE "FL_DLL") target_compile_definitions (${tgt}-shared PRIVATE "FL_DLL")
endforeach () endforeach()
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
@ -296,7 +287,7 @@ endif (OPTION_BUILD_SHARED_LIBS)
# copy the required test files # copy the required test files
file (COPY file(COPY
demo.menu rgb.txt browser.cxx editor.cxx valuators.fl demo.menu rgb.txt browser.cxx editor.cxx valuators.fl
help_dialog.html help_dialog.html
DESTINATION ${TESTFILE_PATH} DESTINATION ${TESTFILE_PATH}
@ -304,7 +295,7 @@ file (COPY
# copy the image directory for help_dialog.html # copy the image directory for help_dialog.html
file (COPY file(COPY
${CMAKE_CURRENT_SOURCE_DIR}/images ${CMAKE_CURRENT_SOURCE_DIR}/images
DESTINATION ${TESTFILE_PATH} DESTINATION ${TESTFILE_PATH}
) )

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
@ -16,58 +16,64 @@
# source files for zlib # source files for zlib
set (ZLIB_SRCS set(ZLIB_SRCS
adler32.c adler32.c
compress.c compress.c
crc32.c crc32.c
deflate.c deflate.c
gzclose.c gzclose.c
gzlib.c gzlib.c
gzread.c gzread.c
gzwrite.c gzwrite.c
inflate.c inflate.c
infback.c infback.c
inftrees.c inftrees.c
inffast.c inffast.c
trees.c trees.c
uncompr.c uncompr.c
zutil.c zutil.c
) )
####################################################################### #######################################################################
# Suppress some Visual Studio compiler warnings # Suppress some Visual Studio compiler warnings
set (msvc_warnings /wd4267 /wd4996) 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})
endif (MSVC) 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)
if (MSVC) fl_add_library(fltk_z SHARED "${ZLIB_SRCS}")
target_compile_options (fltk_z_SHARED PRIVATE ${msvc_warnings})
endif (MSVC)
endif (OPTION_BUILD_SHARED_LIBS) if(MSVC)
target_compile_options(fltk_z-shared PRIVATE ${msvc_warnings})
endif(MSVC)
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
####################################################################### #######################################################################
install (FILES zconf.h zlib.h zutil.h install(FILES zconf.h zlib.h zutil.h
DESTINATION ${FLTK_INCLUDEDIR}/FL/images DESTINATION ${FLTK_INCLUDEDIR}/FL/images
) )