From fd5cd809356dc73d2ede5bb2f0db25098771cb8e Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Wed, 7 Feb 2024 18:30:11 +0100 Subject: [PATCH] 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. --- .github/workflows/build.yml | 8 +- .gitlab-ci.yml | 2 +- CHANGES.txt | 26 +- CMake/FLTK-Functions.cmake | 79 +- CMake/FLTKConfig.cmake.in | 122 ++- CMake/cmake_uninstall.cmake.in | 39 +- CMake/compatibility.cmake | 2 +- CMake/export.cmake | 138 +-- CMake/fl_add_library.cmake | 253 +++-- CMake/fl_create_example.cmake | 181 ++-- CMake/fl_debug_pkg.cmake | 40 +- CMake/fl_debug_var.cmake | 101 +- CMake/install-symlinks.cmake.in | 4 +- CMake/install.cmake | 65 +- CMake/options.cmake | 1333 ++++++++++++++------------- CMake/resources.cmake | 179 ++-- CMake/setup.cmake | 185 ++-- CMake/variables.cmake | 220 ++--- CMakeLists.txt | 354 +++---- FL/Fl.H | 4 +- FL/Fl_Cairo.H | 2 +- FL/Fl_Cairo_Window.H | 2 +- FL/Fl_Native_File_Chooser.H | 4 +- FL/Fl_Printer.H | 2 +- FL/Fl_Table.H | 2 +- FL/x11.H | 2 +- README.CMake.txt | 810 +++++++++------- README.Cairo.txt | 89 +- README.Wayland.txt | 6 +- README.abi-version.txt | 8 +- README.macOS.md | 16 +- cairo/CMakeLists.txt | 18 +- documentation/CMakeLists.txt | 137 +-- documentation/Makefile | 2 +- documentation/README.txt | 8 +- documentation/src/drawing.dox | 2 +- documentation/src/migration_1_4.dox | 123 +++ documentation/src/wayland.dox | 6 +- examples/CMakeLists.txt | 96 +- examples/cairo-draw-x.cxx | 2 +- examples/howto-simple-svg.cxx | 2 +- fltk-options/CMakeLists.txt | 106 +-- fluid/CMakeLists.txt | 148 ++- jpeg/CMakeLists.txt | 91 +- libdecor/build/fl_libdecor.c | 4 +- png/CMakeLists.txt | 98 +- src/CMakeLists.txt | 743 ++++++++------- src/Fl_Cairo.cxx | 15 +- src/Fl_Message.cxx | 2 +- src/Fl_Table.cxx | 2 +- test/CMakeLists.txt | 365 ++++---- test/cairo_test.cxx | 6 +- zlib/CMakeLists.txt | 66 +- 53 files changed, 3571 insertions(+), 2749 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b1265db62..cbb1ecf36 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: # 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. # 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 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 # 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 - 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 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 # 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 - 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 working-directory: ${{github.workspace}}/build @@ -130,7 +130,7 @@ jobs: - name: Configure CMake 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 working-directory: ${{github.workspace}}/build diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c0b4aa908..899fb0ccf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -63,7 +63,7 @@ build-cmake: - date - gcc --version - 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 - time ninja - date diff --git a/CHANGES.txt b/CHANGES.txt index 7ff1e140c..025e1f8e4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 @@ -9,13 +9,17 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2022 CMake can be used to generate Makefiles, IDE project files, and several other build systems by using different "generators" provided 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 - 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 - distributions and FreeBSD. More information in README.Wayland.txt + distributions and FreeBSD. For details see README.Wayland.txt. 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 and right-to-left scripts. FLTK now outputs PostScript that draws 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. - Configure option --enable-wayland allows to build the FLTK library for 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 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 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 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 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. - FLTK's ABI version can be configured with 'configure' and CMake. See documentation in README.abi-version.txt. @@ -161,7 +165,7 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2022 Bundled libraries - 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 diff --git a/CMake/FLTK-Functions.cmake b/CMake/FLTK-Functions.cmake index 009653721..a8d339fac 100644 --- a/CMake/FLTK-Functions.cmake +++ b/CMake/FLTK-Functions.cmake @@ -1,8 +1,8 @@ # # 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 # the file "COPYING" which should have been included with this file. If this @@ -15,22 +15,37 @@ # https://www.fltk.org/bugs.php # -####################################################################### +################################################################################ # 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) - message (WARNING "Not building ${SOURCES}. FLUID executable not found.") - return () - endif (NOT FLTK_FLUID_EXECUTABLE) + if(NOT FLTK_FLUID_EXECUTABLE) + message(WARNING "Not building ${FL_FILES}. FLUID executable not found.") + return() + endif() - set (CXX_FILES) - foreach (src ${SOURCES}) - if ("${src}" MATCHES "\\.fl$") + set(CXX_FILES) + foreach(src ${FL_FILES}) + if("${src}" MATCHES "\\.fl$") string(REGEX REPLACE "(.*).fl" \\1 basename ${src}) add_custom_command( OUTPUT "${basename}.cxx" "${basename}.h" @@ -38,21 +53,33 @@ function (FLTK_RUN_FLUID TARGET SOURCES) DEPENDS ${src} MAIN_DEPENDENCY ${src} ) - list (APPEND CXX_FILES "${basename}.cxx") - endif ("${src}" MATCHES "\\.fl$") - endforeach () - set (${TARGET} ${CXX_FILES} PARENT_SCOPE) + list(APPEND CXX_FILES "${basename}.cxx") + endif() + endforeach() + 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) - get_filename_component (ICON_NAME "${ICON_PATH}" NAME) - set_target_properties ("${TARGET}" PROPERTIES - MACOSX_BUNDLE_ICON_FILE "${ICON_NAME}" - RESOURCE "${ICON_PATH}" +function(fltk_set_bundle_icon TARGET ICON_PATH) + get_filename_component(ICON_NAME "${ICON_PATH}" NAME) + set_target_properties(${TARGET} + PROPERTIES + 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) diff --git a/CMake/FLTKConfig.cmake.in b/CMake/FLTKConfig.cmake.in index e647e6453..23f784698 100644 --- a/CMake/FLTKConfig.cmake.in +++ b/CMake/FLTKConfig.cmake.in @@ -8,7 +8,7 @@ # # FLTK_VERSION - FLTK version string ("x.y.z") # 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 # (or the deprecated fltk_wrap_ui() CMake command) # @@ -21,28 +21,118 @@ # changed in future versions. This includes the list of defined variables # 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) - find_file(FLUID_PATH +# For compatibility with CMake's FindFLTK.cmake: + +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 PATHS ENV PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) - add_executable(fluid IMPORTED) - set_target_properties(fluid - PROPERTIES IMPORTED_LOCATION ${FLUID_PATH} - ) - set (FLTK_FLUID_EXECUTABLE ${FLUID_PATH}) -else () - set (FLTK_FLUID_EXECUTABLE fluid) -endif (CMAKE_CROSSCOMPILING) + + if(FLTK_FLUID_HOST) + + if(0) # Experimental: currently not used + # Import a special 'fluid' target called 'fluid-host' (fltk::fluid-host) + # Note: this is "the same as" the CMake variable FLTK_FLUID_EXECUTABLE + add_executable(fluid-host IMPORTED) + set_target_properties(fluid-host + PROPERTIES IMPORTED_LOCATION ${FLTK_FLUID_HOST} + ) + 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}'") diff --git a/CMake/cmake_uninstall.cmake.in b/CMake/cmake_uninstall.cmake.in index b2547ecf2..efd90e47f 100644 --- a/CMake/cmake_uninstall.cmake.in +++ b/CMake/cmake_uninstall.cmake.in @@ -1,8 +1,9 @@ # # Support file to uninstall the FLTK project using CMake +# # 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 # the file "COPYING" which should have been included with this file. If this @@ -15,13 +16,13 @@ # 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 "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") -endif () +endif() -file (READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) -string (REGEX REPLACE "\n" ";" files "${files}") +file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") # 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 @@ -30,13 +31,13 @@ string (REGEX REPLACE "\n" ";" files "${files}") # Note 3: # Remove this distinction if: cmake_minimum_required(VERSION 3.17) or higher. -if (CMAKE_VERSION VERSION_LESS 3.17) - set (rm_cmd remove) -else () - set (rm_cmd rm) -endif () +if(CMAKE_VERSION VERSION_LESS 3.17) + set(rm_cmd remove) +else() + set(rm_cmd rm) +endif() -foreach (file ${files}) +foreach(file ${files}) message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") execute_process( COMMAND "${CMAKE_COMMAND}" -E ${rm_cmd} -f "$ENV{DESTDIR}${file}" @@ -45,12 +46,12 @@ foreach (file ${files}) RESULT_VARIABLE rm_retval ) - if (NOT "${rm_retval}" STREQUAL 0) - message (STATUS "Error removing \"$ENV{DESTDIR}${file}\"") - message (STATUS " Status = '${rm_retval}'") - message (STATUS " Output = '${rm_out}'") - message (STATUS " Error = '${rm_err}'") - message (FATAL_ERROR "Exiting with fatal error.") - endif () + if(NOT "${rm_retval}" STREQUAL 0) + message(STATUS "Error removing \"$ENV{DESTDIR}${file}\"") + message(STATUS " Status = '${rm_retval}'") + message(STATUS " Output = '${rm_out}'") + message(STATUS " Error = '${rm_err}'") + message(FATAL_ERROR "Exiting - uninstall may be incomplete.") + endif() -endforeach (file) +endforeach(file) diff --git a/CMake/compatibility.cmake b/CMake/compatibility.cmake index 233b4001f..ba48d80e9 100644 --- a/CMake/compatibility.cmake +++ b/CMake/compatibility.cmake @@ -62,7 +62,7 @@ # # 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 # can be an empty list. diff --git a/CMake/export.cmake b/CMake/export.cmake index 63502a4d9..a466e37ae 100644 --- a/CMake/export.cmake +++ b/CMake/export.cmake @@ -1,8 +1,9 @@ # # Export CMake file to build the FLTK project using CMake (www.cmake.org) +# # 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 # 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 -if (FLTK_BUILD_FLUID AND NOT CMAKE_CROSSCOMPILING) - # use the fluid executable we build - if (WIN32) - set (FLTK_FLUID_EXECUTABLE fluid-cmd) - set (FLUID_EXPORT fluid fluid-cmd) # export fluid and fluid-cmd - else () - set (FLTK_FLUID_EXECUTABLE fluid) - set (FLUID_EXPORT fluid) # export fluid - endif () -else () - # find a fluid executable on the host system - find_file(FLUID_PATH +if(FLTK_BUILD_FLUID AND NOT CMAKE_CROSSCOMPILING) + # Use the fluid executable we build using its namespaced target name + if(WIN32) + set(FLTK_FLUID_EXECUTABLE fltk::fluid-cmd) + set(FLUID_EXPORT fluid fluid-cmd) # export fluid and fluid-cmd + else() + set(FLTK_FLUID_EXECUTABLE fltk::fluid) + set(FLUID_EXPORT fluid) # export fluid + endif() +else() + # We don't build fluid /or/ we are cross-compiling (or both): + # 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 PATHS ENV PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) - set (FLTK_FLUID_EXECUTABLE ${FLUID_PATH}) - set (FLUID_EXPORT "") # don't export fluid -endif (FLTK_BUILD_FLUID AND NOT CMAKE_CROSSCOMPILING) + if(NOT FLTK_FLUID_HOST) + message(STATUS "Warning: fluid not found on the build system!") + endif() + # Note: this *may* assign "FLTK_FLUID_HOST-NOTFOUND" + set(FLTK_FLUID_EXECUTABLE "${FLTK_FLUID_HOST}") + set(FLUID_EXPORT "") # don't export fluid +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 -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 -configure_file ( +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CMake/FLTK-Functions.cmake ${CMAKE_CURRENT_BINARY_DIR}/FLTK-Functions.cmake COPYONLY ) # generate FLTKConfig.cmake for build directory use -set (INCLUDE_DIRS "${FLTK_INCLUDE_DIRS}") -if (FLTK_HAVE_CAIRO) - list (APPEND INCLUDE_DIRS ${PKG_CAIRO_INCLUDE_DIRS}) -endif () -set (CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR}) +set(INCLUDE_DIRS "${FLTK_INCLUDE_DIRS}") +if(FLTK_HAVE_CAIRO OR FLTK_USE_CAIRO) + list(APPEND INCLUDE_DIRS ${PKG_CAIRO_INCLUDE_DIRS}) +endif() +list(REMOVE_DUPLICATES INCLUDE_DIRS) +set(CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR}) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CMake/FLTKConfig.cmake.in @@ -65,14 +89,14 @@ configure_file( ) # generate fltk-config for build directory use -set (prefix ${CMAKE_CURRENT_BINARY_DIR}) -set (exec_prefix "\${prefix}") -set (includedir "${CMAKE_CURRENT_SOURCE_DIR}") -set (BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") -set (libdir "\${exec_prefix}/lib") -set (srcdir ".") +set(prefix ${CMAKE_CURRENT_BINARY_DIR}) +set(exec_prefix "\${prefix}") +set(includedir "${CMAKE_CURRENT_SOURCE_DIR}") +set(BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") +set(libdir "\${exec_prefix}/lib") +set(srcdir ".") -set (LIBNAME "${libdir}/libfltk.a") +set(LIBNAME "${libdir}/libfltk.a") configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/fltk-config.in" @@ -80,38 +104,38 @@ configure_file( @ONLY ) -# Set execute permissions on fltk-config in build dir -# Note: file(CHMOD) available since CMake 3.19, +# Set execute permissions on fltk-config in the build directory. +# Note: file(CHMOD) is available since CMake 3.19, # use fallback before CMake 3.19 -if (CMAKE_VERSION VERSION_LESS 3.19) - if (UNIX OR MSYS OR MINGW) +if(CMAKE_VERSION VERSION_LESS 3.19) + if(UNIX OR MSYS OR MINGW) execute_process(COMMAND chmod 755 fltk-config WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - endif () -else (CMAKE_VERSION VERSION_LESS 3.19) - file (CHMOD "${CMAKE_CURRENT_BINARY_DIR}/fltk-config" + endif() +else(CMAKE_VERSION VERSION_LESS 3.19) + file(CHMOD "${CMAKE_CURRENT_BINARY_DIR}/fltk-config" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_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 -if (IS_ABSOLUTE "${FLTK_DATADIR}") - set (PREFIX_DATA "${FLTK_DATADIR}/fltk") -else (IS_ABSOLUTE "${FLTK_DATADIR}") - set (PREFIX_DATA "${CMAKE_INSTALL_PREFIX}/${FLTK_DATADIR}/fltk") -endif (IS_ABSOLUTE "${FLTK_DATADIR}") +if(IS_ABSOLUTE "${FLTK_DATADIR}") + set(PREFIX_DATA "${FLTK_DATADIR}/fltk") +else(IS_ABSOLUTE "${FLTK_DATADIR}") + set(PREFIX_DATA "${CMAKE_INSTALL_PREFIX}/${FLTK_DATADIR}/fltk") +endif(IS_ABSOLUTE "${FLTK_DATADIR}") -if (IS_ABSOLUTE "${FLTK_DOCDIR}") - set (PREFIX_DOC "${FLTK_DOCDIR}/fltk") -else (IS_ABSOLUTE "${FLTK_DOCDIR}") - set (PREFIX_DOC "${CMAKE_INSTALL_PREFIX}/${FLTK_DOCDIR}/fltk") -endif (IS_ABSOLUTE "${FLTK_DOCDIR}") +if(IS_ABSOLUTE "${FLTK_DOCDIR}") + set(PREFIX_DOC "${FLTK_DOCDIR}/fltk") +else(IS_ABSOLUTE "${FLTK_DOCDIR}") + set(PREFIX_DOC "${CMAKE_INSTALL_PREFIX}/${FLTK_DOCDIR}/fltk") +endif(IS_ABSOLUTE "${FLTK_DOCDIR}") -set (CONFIG_H_IN configh.cmake.in) -set (CONFIG_H config.h) +set(CONFIG_H_IN configh.cmake.in) +set(CONFIG_H config.h) # generate config.h @@ -121,15 +145,15 @@ configure_file( @ONLY ) -if (OPTION_CREATE_LINKS) +if(FLTK_INSTALL_LINKS) # Set PREFIX_INCLUDE to the proper value. - if (IS_ABSOLUTE ${FLTK_INCLUDEDIR}) - set (PREFIX_INCLUDE ${FLTK_INCLUDEDIR}) - else () - set (PREFIX_INCLUDE "${CMAKE_INSTALL_PREFIX}/${FLTK_INCLUDEDIR}") - endif (IS_ABSOLUTE ${FLTK_INCLUDEDIR}) + if(IS_ABSOLUTE ${FLTK_INCLUDEDIR}) + set(PREFIX_INCLUDE ${FLTK_INCLUDEDIR}) + else() + set(PREFIX_INCLUDE "${CMAKE_INSTALL_PREFIX}/${FLTK_INCLUDEDIR}") + endif(IS_ABSOLUTE ${FLTK_INCLUDEDIR}) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/install-symlinks.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/install-symlinks.cmake" @ONLY) -endif (OPTION_CREATE_LINKS) +endif(FLTK_INSTALL_LINKS) diff --git a/CMake/fl_add_library.cmake b/CMake/fl_add_library.cmake index ee7956560..a64f998d7 100644 --- a/CMake/fl_add_library.cmake +++ b/CMake/fl_add_library.cmake @@ -1,8 +1,8 @@ # # 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 # 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") - set (TARGET_NAME ${LIBNAME}_SHARED) - else () - set (TARGET_NAME ${LIBNAME}) - endif (${LIBTYPE} STREQUAL "SHARED") + # message(STATUS "Building library **************** ${LIBNAME} ${LIBTYPE}") - if (MSVC) - set (OUTPUT_NAME_DEBUG "${LIBNAME}d") - set (OUTPUT_NAME_RELEASE "${LIBNAME}") - else () - set (OUTPUT_NAME_DEBUG "${LIBNAME}") - set (OUTPUT_NAME_RELEASE "${LIBNAME}") - endif (MSVC) + set(suffix "") + if(LIBTYPE STREQUAL "SHARED") + set(suffix "-shared") + endif() - 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 # Set 'PRIVATE' target compile definitions for the library # so they are not inherited by consumers - target_compile_definitions(${TARGET_NAME} - PRIVATE "FL_LIBRARY") + target_compile_definitions (${TARGET_NAME} 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 + $ + $ + $ + ) + + ### 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 + $ + ) + endforeach() + + else() + + ### This generates a wrong string in property INTERFACE_INCLUDE_DIRECTORIES: + ### ... $;/git/fltk/modern-cmake/src/$') + ### 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 + $ + ) + fl_debug_target(${TARGET_NAME}) + + endif() + + target_link_directories(${TARGET_NAME} PUBLIC + $ + $ + ) + + 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} PROPERTIES OUTPUT_NAME ${LIBNAME} OUTPUT_NAME_DEBUG ${OUTPUT_NAME_DEBUG} 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") - set_target_properties(${TARGET_NAME} - PROPERTIES + if(LIBTYPE STREQUAL "SHARED") + set_target_properties(${TARGET_NAME} PROPERTIES VERSION ${FLTK_VERSION} SOVERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR} OUTPUT_NAME ${LIBNAME} OUTPUT_NAME_DEBUG ${OUTPUT_NAME_DEBUG} OUTPUT_NAME_RELEASE ${OUTPUT_NAME_RELEASE} + EXPORT_NAME ${EXPORT_NAME} ) - # MSVC only: - if (MSVC) - set_target_properties(${TARGET_NAME} - PROPERTIES - OUTPUT_NAME lib${LIBNAME} - OUTPUT_NAME_DEBUG lib${OUTPUT_NAME_DEBUG} - OUTPUT_NAME_RELEASE lib${OUTPUT_NAME_RELEASE} - # PREFIX "lib" # for MSVC static/shared coexistence *DOES NOT WORK* + # Visual Studio only: + if(MSVC) + set_target_properties(${TARGET_NAME} PROPERTIES + OUTPUT_NAME ${LIBNAME}_dll + OUTPUT_NAME_DEBUG ${LIBNAME}_dlld + OUTPUT_NAME_RELEASE ${LIBNAME}_dll ) - endif (MSVC) - endif (${LIBTYPE} STREQUAL "SHARED") + target_compile_definitions (${TARGET_NAME} PRIVATE FL_DLL) + endif(MSVC) + endif(LIBTYPE STREQUAL "SHARED") # 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_ONAME ${TARGET_NAME} OUTPUT_NAME) 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_EXPORT_NAME ${TARGET_NAME} EXPORT_NAME) - fl_debug_var (TARGET_NAME) - fl_debug_var (XX_NAME) - fl_debug_var (XX_ONAME) - fl_debug_var (XX_ONAME_DEBUG) - fl_debug_var (XX_ONAME_RELEASE) - message (STATUS "---") - endif (DEBUG_ONAME) + message(STATUS "--- DEBUG_ONAME ---") + fl_debug_var(TARGET_NAME) + fl_debug_var(XX_NAME) + fl_debug_var(XX_ONAME) + fl_debug_var(XX_ONAME_DEBUG) + fl_debug_var(XX_ONAME_RELEASE) + fl_debug_var(XX_EXPORT_NAME) + message(STATUS "--- /DEBUG_ONAME ---") + endif(DEBUG_ONAME) - if (MSVC) - if (OPTION_LARGE_FILE) - set_target_properties(${TARGET_NAME} - PROPERTIES + if(MSVC) + if(FLTK_OPTION_LARGE_FILE) + fl_debug_var(FLTK_OPTION_LARGE_FILE) + fl_debug_var(TARGET_NAME) + set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS /LARGEADDRESSAWARE ) - endif (OPTION_LARGE_FILE) + endif(FLTK_OPTION_LARGE_FILE) + endif(MSVC) - if (${LIBTYPE} STREQUAL "SHARED") - target_compile_definitions(${TARGET_NAME} - PRIVATE "FL_DLL") - endif () - endif (MSVC) - - install (TARGETS ${TARGET_NAME} - EXPORT FLTK-Targets + install(TARGETS ${TARGET_NAME} EXPORT FLTK-Targets RUNTIME DESTINATION ${FLTK_BINDIR} LIBRARY DESTINATION ${FLTK_LIBDIR} ARCHIVE DESTINATION ${FLTK_LIBDIR} ) - list (APPEND FLTK_LIBRARIES "${TARGET_NAME}") - set (FLTK_LIBRARIES ${FLTK_LIBRARIES} PARENT_SCOPE) + if(LIBTYPE STREQUAL "SHARED") + list(APPEND FLTK_LIBRARIES_SHARED "${TARGET_NAME}") + set(FLTK_LIBRARIES_SHARED "${FLTK_LIBRARIES_SHARED}" PARENT_SCOPE) + else() + list(APPEND FLTK_LIBRARIES "${TARGET_NAME}") + 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) diff --git a/CMake/fl_create_example.cmake b/CMake/fl_create_example.cmake index be1b27608..7e930ee9b 100644 --- a/CMake/fl_create_example.cmake +++ b/CMake/fl_create_example.cmake @@ -2,7 +2,7 @@ # A function used by the CMake build system for the Fast Light Tool Kit (FLTK). # 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 # 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: # @@ -27,9 +27,9 @@ # Sources can be: # - .c/.cxx files, e.g. 'hello.cxx' # - .fl (fluid) files, e.g. 'radio.fl' -# - .plist file (macOS), e.g. 'editor.plist' -# - .icns file (macOS Icon), e.g. 'checkers.icns' -# - .rc file (Windows resource file, e.g. icon definition) +# - .plist file(macOS), e.g. 'editor.plist' +# - .icns file(macOS Icon), e.g. 'checkers.icns' +# - .rc file(Windows resource file, e.g. icon definition) # # Order of sources doesn't matter, multiple .cxx and .fl files are # supported, but only one .plist and one .icns file. @@ -42,127 +42,127 @@ # These files must reside in the subdirectory 'mac-resources'. # # - LIBRARIES: -# List of libraries (CMake target names), separated by ';'. Needs -# quotes if more than one library is required, e.g. "fltk_gl;fltk" -# -# CREATE_EXAMPLE can have an optional fourth argument with a list of options -# - these options are currently not used +# List of libraries (CMake target names), separated by ';'. Must be +# quoted if more than one library is required, e.g. "fltk::gl;fltk::images" # ################################################################################ -function (CREATE_EXAMPLE NAME SOURCES LIBRARIES) +function (fl_create_example NAME SOURCES LIBRARIES) - set (srcs) # source files - set (flsrcs) # fluid source (.fl) files - set (TARGET_NAME ${NAME}) # CMake target name - set (ICON_NAME) # macOS icon (max. one) - set (PLIST) # macOS .plist file (max. one) - set (ICON_PATH) # macOS icon resource path + set(srcs) # source files + set(flsrcs) # fluid source (.fl) files + set(TARGET_NAME ${NAME}) # CMake target name + set(ICON_NAME) # macOS icon (max. one) + set(PLIST) # macOS .plist file(max. one) + set(ICON_PATH) # macOS icon resource path # create macOS bundle? 0 = no, 1 = yes - if (APPLE AND (NOT OPTION_APPLE_X11)) - set (MAC_BUNDLE 1) - else () - set (MAC_BUNDLE 0) - endif (APPLE AND (NOT OPTION_APPLE_X11)) - - # 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") + if(APPLE AND NOT FLTK_BACKEND_X11) + set(MAC_BUNDLE 1) + else() + set(MAC_BUNDLE 0) + endif() # filter input files for different handling (fluid, icon, plist, source) - foreach (src ${SOURCES}) - if ("${src}" MATCHES "\\.fl$") - list (APPEND flsrcs ${src}) - elseif ("${src}" MATCHES "\\.icns$") - set (ICON_NAME "${src}") - elseif ("${src}" MATCHES "\\.plist$") - set (PLIST "${src}") - else () - list (APPEND srcs ${src}) - endif ("${src}" MATCHES "\\.fl$") - endforeach (src) + foreach(src ${SOURCES}) + if("${src}" MATCHES "\\.fl$") + list(APPEND flsrcs ${src}) + elseif("${src}" MATCHES "\\.icns$") + set(ICON_NAME "${src}") + elseif("${src}" MATCHES "\\.plist$") + set(PLIST "${src}") + else() + list(APPEND srcs ${src}) + endif("${src}" MATCHES "\\.fl$") + endforeach(src) # generate source files from .fl files, add output to sources - if (flsrcs) - if (NOT FLTK_FLUID_EXECUTABLE) + if(flsrcs) + if(NOT FLTK_FLUID_EXECUTABLE) message(STATUS "Example app \"${NAME}\" will not be built. FLUID executable not found.") return () - endif () + endif() FLTK_RUN_FLUID (FLUID_SOURCES "${flsrcs}") - list (APPEND srcs ${FLUID_SOURCES}) - unset (FLUID_SOURCES) - endif (flsrcs) + list(APPEND srcs ${FLUID_SOURCES}) + unset(FLUID_SOURCES) + endif(flsrcs) # set macOS (icon) resource path if applicable - if (MAC_BUNDLE AND ICON_NAME) - set (ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/mac-resources/${ICON_NAME}") - endif (MAC_BUNDLE AND ICON_NAME) + if(MAC_BUNDLE AND ICON_NAME) + set(ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/mac-resources/${ICON_NAME}") + endif(MAC_BUNDLE AND ICON_NAME) ############################################################################## # add executable target and set properties (all platforms) ############################################################################## - if (MAC_BUNDLE) + if(MAC_BUNDLE) add_executable (${TARGET_NAME} MACOSX_BUNDLE ${srcs} ${ICON_PATH}) - else () + else() add_executable (${TARGET_NAME} WIN32 ${srcs}) - endif (MAC_BUNDLE) + endif(MAC_BUNDLE) 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', # see also README.Wayland.txt and CMake policy CMP0065. set_target_properties (${TARGET_NAME} PROPERTIES ENABLE_EXPORTS TRUE) - # we must link all programs with cairo if option CAIROEXT is enabled - if (FLTK_HAVE_CAIROEXT) - target_link_libraries (${TARGET_NAME} ${PKG_CAIRO_LIBRARIES}) - endif () + ### *FIXME* Remove the entire 'if' block below when verified: - if (FLTK_HAVE_CAIRO AND PKG_CAIRO_LIBRARY_DIRS) - target_link_directories (${TARGET_NAME} PUBLIC ${PKG_CAIRO_LIBRARY_DIRS}) - endif () + if(0) # This should no longer be necessary (implied by linking the libs) - if (USE_GDIPLUS) # can only be true on Windows - target_link_libraries (${TARGET_NAME} gdiplus) - endif () + # we must link all programs with Cairo if option CAIROEXT is enabled + if(FLTK_HAVE_CAIROEXT) + target_link_libraries(${TARGET_NAME} PRIVATE ${PKG_CAIRO_LIBRARIES}) + endif() - if (MAC_BUNDLE) - if (PLIST) - set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST + if(FLTK_HAVE_CAIRO AND PKG_CAIRO_LIBRARY_DIRS) + target_link_directories(${TARGET_NAME} PRIVATE ${PKG_CAIRO_LIBRARY_DIRS}) + 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}") endif() 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_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 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 XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${FLTK_BUNDLE_ID}") - if (ICON_NAME) - set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME}) - set_target_properties (${TARGET_NAME} PROPERTIES RESOURCE ${ICON_PATH}) - endif () - endif () + if(ICON_NAME) + set_target_properties(${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME}) + set_target_properties(${TARGET_NAME} PROPERTIES RESOURCE ${ICON_PATH}) + endif() + endif() ############################################################################## # Copy macOS "bundle wrapper" (shell script) to target directory. # The "custom command" will be executed "POST_BUILD". ############################################################################## - if (MAC_BUNDLE) - set (WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${TARGET_NAME}") + if(MAC_BUNDLE) + set(WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${TARGET_NAME}") - add_custom_command ( + add_custom_command( TARGET ${TARGET_NAME} POST_BUILD COMMAND cp ${FLTK_SOURCE_DIR}/CMake/macOS-bundle-wrapper.in ${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}" VERBATIM ) - unset (WRAPPER) - endif (MAC_BUNDLE) + unset(WRAPPER) + endif(MAC_BUNDLE) - if (MSVC AND TARGET fltk_SHARED) - set (DllDir "$>") - ## fl_debug_var (DllDir) + ############################################################################## + # MSVC: Add fltk-shared (DLL) path to Environment 'PATH' for debugging + ############################################################################## + + if(MSVC AND TARGET fltk-shared) + set(DllDir "$>") set_target_properties(${TARGET_NAME} PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=${DllDir};$ENV{PATH}" ) 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 () diff --git a/CMake/fl_debug_pkg.cmake b/CMake/fl_debug_pkg.cmake index 56df4ca37..1eebb63a6 100644 --- a/CMake/fl_debug_pkg.cmake +++ b/CMake/fl_debug_pkg.cmake @@ -41,29 +41,29 @@ macro (fl_debug_pkg PREFIX NAME) message("") message(STATUS "Results of pkg_check_modules(${PREFIX}, ${NAME}):") - fl_debug_var (${PREFIX}_FOUND) - if (${PREFIX}_FOUND) + fl_debug_var(${PREFIX}_FOUND) + if(${PREFIX}_FOUND) - fl_debug_var (${PREFIX}_INCLUDE_DIRS) - fl_debug_var (${PREFIX}_CFLAGS) - fl_debug_var (${PREFIX}_LIBRARIES) - fl_debug_var (${PREFIX}_LINK_LIBRARIES) - fl_debug_var (${PREFIX}_LIBRARY_DIRS) - fl_debug_var (${PREFIX}_LDFLAGS) - fl_debug_var (${PREFIX}_LDFLAGS_OTHER) - fl_debug_var (${PREFIX}_CFLAGS_OTHER) + fl_debug_var(${PREFIX}_INCLUDE_DIRS) + fl_debug_var(${PREFIX}_CFLAGS) + fl_debug_var(${PREFIX}_LIBRARIES) + fl_debug_var(${PREFIX}_LINK_LIBRARIES) + fl_debug_var(${PREFIX}_LIBRARY_DIRS) + fl_debug_var(${PREFIX}_LDFLAGS) + fl_debug_var(${PREFIX}_LDFLAGS_OTHER) + fl_debug_var(${PREFIX}_CFLAGS_OTHER) - fl_debug_var (${PREFIX}_STATIC_INCLUDE_DIRS) - fl_debug_var (${PREFIX}_STATIC_CFLAGS) - fl_debug_var (${PREFIX}_STATIC_LIBRARIES) - fl_debug_var (${PREFIX}_STATIC_LINK_LIBRARIES) - fl_debug_var (${PREFIX}_STATIC_LIBRARY_DIRS) + fl_debug_var(${PREFIX}_STATIC_INCLUDE_DIRS) + fl_debug_var(${PREFIX}_STATIC_CFLAGS) + fl_debug_var(${PREFIX}_STATIC_LIBRARIES) + fl_debug_var(${PREFIX}_STATIC_LINK_LIBRARIES) + fl_debug_var(${PREFIX}_STATIC_LIBRARY_DIRS) - fl_debug_var (${PREFIX}_VERSION) - fl_debug_var (${PREFIX}_PREFIX) - fl_debug_var (${PREFIX}_INCLUDEDIR) - fl_debug_var (${PREFIX}_LIBDIR) + fl_debug_var(${PREFIX}_VERSION) + fl_debug_var(${PREFIX}_PREFIX) + fl_debug_var(${PREFIX}_INCLUDEDIR) + fl_debug_var(${PREFIX}_LIBDIR) - endif () + endif() message("") endmacro (fl_debug_pkg) diff --git a/CMake/fl_debug_var.cmake b/CMake/fl_debug_var.cmake index 5717704a3..08f91bf1d 100644 --- a/CMake/fl_debug_var.cmake +++ b/CMake/fl_debug_var.cmake @@ -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 # 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) # (currently 30) characters wide for better readability. # VARNAME must be a string literal, e.g. WIN32 or "WIN32". @@ -32,15 +64,52 @@ # ####################################################################### -macro (fl_debug_var name) - set (min_len 32) - set (var "${name}") - string(LENGTH "${var}" len) - while (len LESS min_len) - # add one space until min_len is reached - # ** string(APPEND var " ") # requires CMake 3.4.x (otherwise loop...) - set (var "${var} ") - string(LENGTH "${var}" len) - endwhile (len LESS min_len) - message (STATUS "${var} = '${${name}}'") -endmacro (fl_debug_var) +function (fl_debug_var name) + set(var "${name}") + fl_expand_name(var "${name}" 40) + message(STATUS "${var} = '${${name}}'") +endfunction (fl_debug_var) + + +####################################################################### +# fl_debug_target - a function to output info about a target +####################################################################### +# +# This function displays properties of a CMake target. +# +# Currently there's a fixed number of properties. +# +# Syntax: +# fl_debug_target(target) +# +# Example: +# fl_debug_target(fltk) +# fl_debug_target(fluid) +# fl_debug_target(fltk_image) +# fl_debug_target(fltk::forms) +# +####################################################################### + +function (fl_debug_target name) + message(STATUS "+++ fl_debug_target (${name})") + set(var "${name}") + fl_expand_name(var "${name}" 40) + if(TARGET ${name}) + message(STATUS "${var} = ") + 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} = ") + endif() + message(STATUS "") + +endfunction (fl_debug_target) diff --git a/CMake/install-symlinks.cmake.in b/CMake/install-symlinks.cmake.in index b338163f1..595ed7fb2 100644 --- a/CMake/install-symlinks.cmake.in +++ b/CMake/install-symlinks.cmake.in @@ -22,7 +22,7 @@ if (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) -foreach (file ${FLTK_HEADER_FILES}) +foreach(file ${FLTK_HEADER_FILES}) GET_FILENAME_COMPONENT(nameWE ${file} NAME_WE) if (NOT EXISTS $ENV{DESTDIR}@PREFIX_INCLUDE@/FL/${nameWE}.h) EXECUTE_PROCESS( @@ -30,4 +30,4 @@ foreach (file ${FLTK_HEADER_FILES}) WORKING_DIRECTORY $ENV{DESTDIR}@PREFIX_INCLUDE@/FL ) endif (NOT EXISTS $ENV{DESTDIR}@PREFIX_INCLUDE@/FL/${nameWE}.h) -endforeach (file) +endforeach(file) diff --git a/CMake/install.cmake b/CMake/install.cmake index ea36ab301..651d8a0f1 100644 --- a/CMake/install.cmake +++ b/CMake/install.cmake @@ -2,7 +2,7 @@ # Installation support for building the FLTK project using CMake (www.cmake.org) # 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 # 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" @ONLY ) -add_custom_target (uninstall +add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" ) -install (DIRECTORY +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/FL DESTINATION ${FLTK_INCLUDEDIR} USE_SOURCE_PERMISSIONS FILES_MATCHING @@ -37,28 +37,29 @@ install (DIRECTORY PATTERN "fl_config.h" EXCLUDE ) -install (DIRECTORY +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/FL DESTINATION ${FLTK_INCLUDEDIR} USE_SOURCE_PERMISSIONS FILES_MATCHING PATTERN "*.[hH]" ) -if (OPTION_CREATE_LINKS) - install (SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/install-symlinks.cmake) -endif (OPTION_CREATE_LINKS) +if(FLTK_INSTALL_LINKS) + install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/install-symlinks.cmake) +endif(FLTK_INSTALL_LINKS) # generate FLTKConfig.cmake for installed directory use -set (INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include) -if (FLTK_HAVE_CAIRO) - list (APPEND INCLUDE_DIRS ${PKG_CAIRO_INCLUDE_DIRS}) -endif () +set(INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include) +if(FLTK_HAVE_CAIRO) + list(APPEND INCLUDE_DIRS ${PKG_CAIRO_INCLUDE_DIRS}) +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} FILE FLTK-Targets.cmake + NAMESPACE fltk:: ) configure_file( @@ -67,26 +68,26 @@ configure_file( @ONLY ) -install (FILES +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/etc/FLTKConfig.cmake DESTINATION ${FLTK_CONFIG_PATH} ) -install (FILES +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/CMake/FLTK-Functions.cmake DESTINATION ${FLTK_CONFIG_PATH} ) # Generate fltk-config -set (prefix ${CMAKE_INSTALL_PREFIX}) -set (exec_prefix "\${prefix}") -set (includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") -set (BINARY_DIR) -set (libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") -set (srcdir ".") +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(exec_prefix "\${prefix}") +set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") +set(BINARY_DIR) +set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") +set(srcdir ".") -set (LIBNAME "${libdir}/libfltk.a") +set(LIBNAME "${libdir}/libfltk.a") configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/fltk-config.in" @@ -95,14 +96,14 @@ configure_file( ) # 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 DESTINATION ${FLTK_BINDIR} ) -if (UNIX OR MSYS OR MINGW) +if(UNIX OR MSYS OR MINGW) macro(INSTALL_MAN FILE LEVEL) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/documentation/src/${FILE}.man @@ -111,20 +112,20 @@ if (UNIX OR MSYS OR MINGW) ) endmacro (INSTALL_MAN FILE LEVEL) - if (FLTK_BUILD_FLUID) + if(FLTK_BUILD_FLUID) INSTALL_MAN (fluid 1) - endif (FLTK_BUILD_FLUID) - if (FLTK_BUILD_FLTK_OPTIONS) + endif(FLTK_BUILD_FLUID) + if(FLTK_BUILD_FLTK_OPTIONS) INSTALL_MAN (fltk-options 1) - endif (FLTK_BUILD_FLTK_OPTIONS) + endif(FLTK_BUILD_FLTK_OPTIONS) INSTALL_MAN (fltk-config 1) 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) # INSTALL_MAN (blocks 6) # INSTALL_MAN (checkers 6) # INSTALL_MAN (sudoku 6) - endif () + endif() -endif (UNIX OR MSYS OR MINGW) +endif(UNIX OR MSYS OR MINGW) diff --git a/CMake/options.cmake b/CMake/options.cmake index 0a774b09b..2d0522ed1 100644 --- a/CMake/options.cmake +++ b/CMake/options.cmake @@ -2,7 +2,7 @@ # Main CMakeLists.txt to build the FLTK project using CMake (www.cmake.org) # 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 # the file "COPYING" which should have been included with this file. If this @@ -37,7 +37,7 @@ # bundled libraries (png, jpeg, zlib) *must* appear before any other # include_directories() statements that might introduce conflicts. # Currently 'resources.cmake' is included before this file and thus -# 'include_directories (${FREETYPE_PATH})' is executed before this +# 'include_directories(${FREETYPE_PATH})' is executed before this # file but this doesn't matter. # # This *MUST* be fixed using target_include_directories() as @@ -47,36 +47,37 @@ # ####################################################################### -set (DEBUG_OPTIONS_CMAKE 0) -if (DEBUG_OPTIONS_CMAKE) - message (STATUS "[** options.cmake **]") - fl_debug_var (WIN32) - fl_debug_var (FLTK_LDLIBS) -endif (DEBUG_OPTIONS_CMAKE) +set(DEBUG_OPTIONS_CMAKE 0) +if(DEBUG_OPTIONS_CMAKE) + message(STATUS "[** options.cmake **]") + fl_debug_var(WIN32) + fl_debug_var(FLTK_LDLIBS) +endif(DEBUG_OPTIONS_CMAKE) ####################################################################### # options ####################################################################### -set (OPTION_OPTIM "" +set(FLTK_OPTION_OPTIM "" CACHE STRING "custom optimization flags" ) -add_definitions (${OPTION_OPTIM}) +# *FIXME* add_definitions() +add_definitions(${FLTK_OPTION_OPTIM}) ####################################################################### -set (OPTION_ARCHFLAGS "" +set(FLTK_ARCHFLAGS "" CACHE STRING "custom architecture flags" ) -add_definitions (${OPTION_ARCHFLAGS}) +# *FIXME* add_definitions() +add_definitions(${FLTK_ARCHFLAGS}) ####################################################################### -set (OPTION_ABI_VERSION "" +set(FLTK_ABI_VERSION "" CACHE STRING "FLTK ABI Version FL_ABI_VERSION: 1xxyy for 1.x.y (xx,yy with leading zero)" ) -set (FL_ABI_VERSION ${OPTION_ABI_VERSION}) - +set(FL_ABI_VERSION ${FLTK_ABI_VERSION}) ####################################################################### # Select MSVC (Visual Studio) Runtime: DLL (/MDx) or static (/MTx) @@ -86,508 +87,549 @@ set (FL_ABI_VERSION ${OPTION_ABI_VERSION}) # CMake variable - but this version does the latter. ####################################################################### -if (MSVC) - option (FLTK_MSVC_RUNTIME_DLL "use MSVC Runtime-DLL (/MDx)" ON) - if (FLTK_MSVC_RUNTIME_DLL) - set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - else () - set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif () -endif (MSVC) +if(MSVC) + option(FLTK_MSVC_RUNTIME_DLL "use MSVC Runtime-DLL (/MDx)" ON) + if(FLTK_MSVC_RUNTIME_DLL) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") + else() + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + endif() +endif(MSVC) + +####################################################################### + +if(APPLE) + option(FLTK_BACKEND_X11 "use X11" OFF) + if(CMAKE_OSX_SYSROOT) + list(APPEND FLTK_CFLAGS "-isysroot ${CMAKE_OSX_SYSROOT}") + endif(CMAKE_OSX_SYSROOT) +elseif(UNIX) + option(FLTK_BACKEND_X11 "use X11" ON) +endif(APPLE) ####################################################################### # Bundled Library Options ####################################################################### -option (OPTION_USE_SYSTEM_ZLIB "use system zlib" ON) +if(WIN32 OR (APPLE AND NOT FLTK_BACKEND_X11)) + option(FLTK_USE_SYSTEM_LIBJPEG "use system libjpeg" OFF) + option(FLTK_USE_SYSTEM_LIBPNG "use system libpng" OFF) + option(FLTK_USE_SYSTEM_ZLIB "use system zlib" OFF) +else() + option(FLTK_USE_SYSTEM_LIBJPEG "use system libjpeg" ON) + option(FLTK_USE_SYSTEM_LIBPNG "use system libpng" ON) + option(FLTK_USE_SYSTEM_ZLIB "use system zlib" ON) +endif() -if (APPLE) - option (OPTION_USE_SYSTEM_LIBJPEG "use system libjpeg" OFF) - option (OPTION_USE_SYSTEM_LIBPNG "use system libpng" OFF) -else () - option (OPTION_USE_SYSTEM_LIBJPEG "use system libjpeg" ON) - option (OPTION_USE_SYSTEM_LIBPNG "use system libpng" ON) -endif () +# Set default values of internal build options + +set(FLTK_USE_BUNDLED_JPEG FALSE) +set(FLTK_USE_BUNDLED_PNG FALSE) +set(FLTK_USE_BUNDLED_ZLIB FALSE) + +# Collect libraries to build fltk_images (starting empty) + +set(FLTK_IMAGE_LIBRARIES "") ####################################################################### -# Make sure that png and zlib are either system or local for compatibility +# Ensure that png and zlib are both system or both local for compatibility ####################################################################### -if (OPTION_USE_SYSTEM_ZLIB) - find_package (ZLIB) -endif () +if(FLTK_USE_SYSTEM_ZLIB) + find_package(ZLIB) + if(NOT ZLIB_FOUND) + set(FLTK_USE_BUNDLED_ZLIB TRUE) + endif() +else() + set(FLTK_USE_BUNDLED_ZLIB TRUE) +endif() -if (OPTION_USE_SYSTEM_LIBPNG) - find_package (PNG) -endif () +if(FLTK_USE_SYSTEM_LIBPNG AND NOT FLTK_USE_BUNDLED_ZLIB) + find_package(PNG) + if(NOT PNG_FOUND) + set(FLTK_USE_BUNDLED_PNG TRUE) + set(FLTK_USE_BUNDLED_ZLIB TRUE) + endif() +else() + set(FLTK_USE_BUNDLED_PNG TRUE) + set(FLTK_USE_BUNDLED_ZLIB TRUE) +endif() -# If we use the system zlib, we must also use the system png zlib and vice versa -# If either of them is not available, we fall back to using both local libraries -if (OPTION_USE_SYSTEM_LIBPNG AND NOT (OPTION_USE_SYSTEM_ZLIB AND ZLIB_FOUND)) - set (PNG_FOUND FALSE) - set (OPTION_USE_SYSTEM_LIBPNG OFF) - message (STATUS "Local z lib selected: overriding png lib to local for compatibility.\n") -endif () -if (OPTION_USE_SYSTEM_ZLIB AND NOT (OPTION_USE_SYSTEM_LIBPNG AND PNG_FOUND)) - set (ZLIB_FOUND FALSE) - set (OPTION_USE_SYSTEM_ZLIB OFF) - message (STATUS "Local png lib selected: overriding z lib to local for compatibility.\n") -endif () +# Issue warnings if we deviate from the user's choice + +if(FLTK_USE_SYSTEM_LIBPNG AND FLTK_USE_BUNDLED_PNG) + message(STATUS "System PNG or ZLIB not usable, falling back to local PNG for compatibility.") +endif() + +if(FLTK_USE_SYSTEM_ZLIB AND FLTK_USE_BUNDLED_ZLIB) + message(STATUS "System PNG or ZLIB not usable, falling back to local ZLIB for compatibility.") +endif() ####################################################################### # Bundled Compression Library : zlib ####################################################################### -if (OPTION_USE_SYSTEM_ZLIB AND ZLIB_FOUND) - set (FLTK_USE_BUILTIN_ZLIB FALSE) - set (FLTK_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) - include_directories (${ZLIB_INCLUDE_DIRS}) -else() - if (OPTION_USE_SYSTEM_ZLIB) - message (STATUS "cannot find system zlib library - using built-in\n") - endif () +if(FLTK_USE_BUNDLED_ZLIB) - add_subdirectory (zlib) - set (FLTK_USE_BUILTIN_ZLIB TRUE) - set (FLTK_ZLIB_LIBRARIES fltk_z) - set (ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zlib) - include_directories (${CMAKE_CURRENT_SOURCE_DIR}/zlib) -endif () + add_subdirectory(zlib) -set (HAVE_LIBZ 1) + set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zlib) -####################################################################### -# Bundled Image Library : libjpeg -####################################################################### + # FIXME - include_directories() + include_directories(${ZLIB_INCLUDE_DIR}) -if (OPTION_USE_SYSTEM_LIBJPEG) - find_package (JPEG) -endif () +endif() -if (OPTION_USE_SYSTEM_LIBJPEG AND JPEG_FOUND) - set (FLTK_USE_BUILTIN_JPEG FALSE) - set (FLTK_JPEG_LIBRARIES ${JPEG_LIBRARIES}) - include_directories (${JPEG_INCLUDE_DIR}) -else () - if (OPTION_USE_SYSTEM_LIBJPEG) - message (STATUS "cannot find system jpeg library - using built-in\n") - endif () - - add_subdirectory (jpeg) - set (FLTK_USE_BUILTIN_JPEG TRUE) - set (FLTK_JPEG_LIBRARIES fltk_jpeg) - include_directories (${CMAKE_CURRENT_SOURCE_DIR}/jpeg) -endif () - -set (HAVE_LIBJPEG 1) +set(HAVE_LIBZ 1) ####################################################################### # Bundled Image Library : libpng ####################################################################### -if (OPTION_USE_SYSTEM_LIBPNG AND PNG_FOUND) +if(FLTK_USE_BUNDLED_PNG) - set (FLTK_USE_BUILTIN_PNG FALSE) - set (FLTK_PNG_LIBRARIES ${PNG_LIBRARIES}) - include_directories (${PNG_INCLUDE_DIRS}) - add_definitions (${PNG_DEFINITIONS}) + add_subdirectory(png) + set(FLTK_PNG_LIBRARIES fltk::png) + list(APPEND FLTK_IMAGE_LIBRARIES fltk::png) - set (_INCLUDE_SAVED ${CMAKE_REQUIRED_INCLUDES}) - list (APPEND CMAKE_REQUIRED_INCLUDES ${PNG_INCLUDE_DIRS}) + # Definitions for 'config.h' - do we still need this? + # See also png/CMakeLists.txt (target_compile_definitions). + # Note: config.h is generated by either configure or CMake, + # hence we should support it in 1.4.0 (may be changed in 1.5.0) + + set(HAVE_PNG_H 1) + set(HAVE_PNG_GET_VALID 1) + set(HAVE_PNG_SET_TRNS_TO_ALPHA 1) + + # *FIXME* include_directories() + include_directories(${FLTK_SOURCE_DIR}/png) + +else() # use system libpng and zlib + + set(FLTK_PNG_LIBRARIES ${PNG_LIBRARIES}) + list(APPEND FLTK_IMAGE_LIBRARIES ${PNG_LIBRARIES}) + + # *FIXME* include_directories() + include_directories(${PNG_INCLUDE_DIRS}) + + set(_INCLUDE_SAVED ${CMAKE_REQUIRED_INCLUDES}) + list(APPEND CMAKE_REQUIRED_INCLUDES ${PNG_INCLUDE_DIRS}) # Note: we do not check for explicitly. # This is assumed to exist if we have PNG_FOUND and don't find # FIXME - Force search by unsetting the chache variable. Maybe use # FIXME - another cache variable to check for option changes? + # unset(HAVE_PNG_H CACHE) # force search - unset (HAVE_PNG_H CACHE) # force search - check_include_file (png.h HAVE_PNG_H) - mark_as_advanced (HAVE_PNG_H) + check_include_file(png.h HAVE_PNG_H) + mark_as_advanced(HAVE_PNG_H) - set (CMAKE_REQUIRED_INCLUDES ${_INCLUDE_SAVED}) - unset (_INCLUDE_SAVED) + set(CMAKE_REQUIRED_INCLUDES ${_INCLUDE_SAVED}) + unset(_INCLUDE_SAVED) -else () +endif() - if (OPTION_USE_SYSTEM_LIBPNG) - message (STATUS "cannot find system png library - using built-in\n") - endif () - - add_subdirectory (png) - set (FLTK_USE_BUILTIN_PNG TRUE) - set (FLTK_PNG_LIBRARIES fltk_png) - set (HAVE_PNG_H 1) - set (HAVE_PNG_GET_VALID 1) - set (HAVE_PNG_SET_TRNS_TO_ALPHA 1) - include_directories (${CMAKE_CURRENT_SOURCE_DIR}/png) -endif () - -set (HAVE_LIBPNG 1) +set(HAVE_LIBPNG 1) ####################################################################### -if (UNIX) - option (OPTION_CREATE_LINKS "create backwards compatibility links" OFF) - list (APPEND FLTK_LDLIBS -lm) - if (NOT APPLE) - option (OPTION_USE_WAYLAND "support both Wayland and X11 backends" ON) - endif (NOT APPLE) - if (OPTION_USE_WAYLAND) +# Bundled Image Library : libjpeg +####################################################################### + +if(FLTK_USE_SYSTEM_LIBJPEG) + find_package(JPEG) + if(NOT JPEG_FOUND) + set(FLTK_USE_BUNDLED_JPEG TRUE) + message(STATUS "cannot find system jpeg library - using built-in") + endif() +else() + set(FLTK_USE_BUNDLED_JPEG TRUE) +endif() + +if(FLTK_USE_BUNDLED_JPEG) + + add_subdirectory(jpeg) + set(FLTK_JPEG_LIBRARIES fltk::jpeg) + # list(APPEND FLTK_IMAGE_LIBRARIES fltk::jpeg) + + # *FIXME* include_directories + include_directories(${FLTK_SOURCE_DIR}/jpeg) + +else() + + set(FLTK_JPEG_LIBRARIES ${JPEG_LIBRARIES}) + list(APPEND FLTK_IMAGE_LIBRARIES ${JPEG_LIBRARIES}) + +endif() + +set(HAVE_LIBJPEG 1) + +####################################################################### + +if(UNIX) + option(FLTK_INSTALL_LINKS "create backwards compatibility links" OFF) + list(APPEND FLTK_LDLIBS -lm) + if(NOT APPLE) + option(FLTK_BACKEND_WAYLAND "support the Wayland backend" ON) + endif(NOT APPLE) + if(FLTK_BACKEND_WAYLAND) pkg_check_modules(WLDCLIENT wayland-client>=1.18) pkg_check_modules(WLDCURSOR wayland-cursor) pkg_check_modules(WLDPROTO wayland-protocols>=1.15) pkg_check_modules(XKBCOMMON xkbcommon) - if (NOT(WLDCLIENT_FOUND AND WLDCURSOR_FOUND AND WLDPROTO_FOUND AND XKBCOMMON_FOUND)) - message (STATUS "Not all software modules 'wayland-client>=1.18 wayland-cursor wayland-protocols>=1.15 xkbcommon' are present") - message (STATUS "Consequently, OPTION_USE_WAYLAND is set to OFF.") - unset (OPTION_USE_WAYLAND CACHE) - set (OPTION_USE_WAYLAND 0) - endif (NOT(WLDCLIENT_FOUND AND WLDCURSOR_FOUND AND WLDPROTO_FOUND AND XKBCOMMON_FOUND)) - endif (OPTION_USE_WAYLAND) + if(NOT(WLDCLIENT_FOUND AND WLDCURSOR_FOUND AND WLDPROTO_FOUND AND XKBCOMMON_FOUND)) + message(STATUS "Not all software modules 'wayland-client>=1.18 wayland-cursor wayland-protocols>=1.15 xkbcommon' are present") + message(STATUS "Consequently, FLTK_BACKEND_WAYLAND is set to OFF.") + unset(FLTK_BACKEND_WAYLAND CACHE) + set(FLTK_BACKEND_WAYLAND 0) + endif(NOT(WLDCLIENT_FOUND AND WLDCURSOR_FOUND AND WLDPROTO_FOUND AND XKBCOMMON_FOUND)) + endif(FLTK_BACKEND_WAYLAND) - if (OPTION_USE_WAYLAND) - option (OPTION_WAYLAND_ONLY "support Wayland backend only" OFF) - set (FLTK_USE_WAYLAND 1) - if (NOT OPTION_WAYLAND_ONLY) - include (FindX11) - endif (NOT OPTION_WAYLAND_ONLY) - if (X11_FOUND) - set (FLTK_USE_X11 1) # to build a hybrid Wayland/X11 library - else () - set (FLTK_USE_X11 0) # to build a Wayland-only library - endif (X11_FOUND) - unset (OPTION_USE_CAIRO CACHE) - set (OPTION_USE_CAIRO TRUE CACHE BOOL "all drawing to X11 windows uses Cairo") - option (OPTION_USE_SYSTEM_LIBDECOR "use libdecor from the system" ON) - unset (OPTION_USE_XRENDER CACHE) - unset (OPTION_USE_XINERAMA CACHE) - unset (OPTION_USE_XFT CACHE) - unset (OPTION_USE_XCURSOR CACHE) - unset (OPTION_USE_XFIXES CACHE) - if (X11_FOUND) - if (NOT X11_Xfixes_FOUND) + if(FLTK_BACKEND_WAYLAND) + set(FLTK_USE_WAYLAND 1) + if(FLTK_BACKEND_X11) + include(FindX11) + endif() + if(X11_FOUND) + set(FLTK_USE_X11 1) # to build a hybrid Wayland/X11 library + else() + set(FLTK_USE_X11 0) # to build a Wayland-only library + endif(X11_FOUND) + unset(FLTK_GRAPHICS_CAIRO CACHE) + set(FLTK_GRAPHICS_CAIRO TRUE CACHE BOOL "all drawing to X11 windows uses Cairo") + option(FLTK_USE_SYSTEM_LIBDECOR "use libdecor from the system" ON) + set(USE_SYSTEM_LIBDECOR 1) + unset(FLTK_USE_XRENDER CACHE) + unset(FLTK_USE_XINERAMA CACHE) + unset(FLTK_USE_XFT CACHE) + unset(FLTK_USE_XCURSOR CACHE) + unset(FLTK_USE_XFIXES CACHE) + if(X11_FOUND) + if(NOT X11_Xfixes_FOUND) message(WARNING "Install development headers for libXfixes (e.g., libxfixes-dev)") endif() - set (HAVE_XFIXES 1) - if (NOT X11_Xrender_FOUND) + set(HAVE_XFIXES 1) + if(NOT X11_Xrender_FOUND) message(WARNING "Install development headers for libXrender (e.g., libxrender-dev)") endif() - set (HAVE_XRENDER 1) - if (NOT X11_Xft_FOUND) + set(HAVE_XRENDER 1) + if(NOT X11_Xft_FOUND) message(WARNING "Install development headers for libXft (e.g., libxft-dev)") endif() - set (USE_XFT 1) - if (NOT X11_Xcursor_FOUND) + set(USE_XFT 1) + if(NOT X11_Xcursor_FOUND) message(WARNING "Install development headers for libXcursor (e.g., libxcursor-dev)") endif() - set (HAVE_XCURSOR 1) - if (NOT X11_Xinerama_FOUND) + set(HAVE_XCURSOR 1) + if(NOT X11_Xinerama_FOUND) message(WARNING "Install development headers for libXinerama (e.g., libxinerama-dev)") endif() - set (HAVE_XINERAMA 1) - if (NOT (X11_Xfixes_FOUND AND X11_Xrender_FOUND AND X11_Xft_FOUND AND X11_Xcursor_FOUND + set(HAVE_XINERAMA 1) + if(NOT (X11_Xfixes_FOUND AND X11_Xrender_FOUND AND X11_Xft_FOUND AND X11_Xcursor_FOUND AND X11_Xinerama_FOUND)) - message (FATAL_ERROR "*** Terminating: one or more required software package(s) missing.") - endif () - endif (X11_FOUND) - unset (OPTION_USE_PANGO CACHE) - set (OPTION_USE_PANGO TRUE CACHE BOOL "use lib Pango") - if (OPTION_USE_SYSTEM_LIBDECOR) - pkg_check_modules(SYSTEM_LIBDECOR libdecor-0>=0.2.0) - if (NOT SYSTEM_LIBDECOR_FOUND) - set (OPTION_USE_SYSTEM_LIBDECOR OFF) - else () + message(FATAL_ERROR "*** Terminating: one or more required software package(s) missing.") + endif() + endif(X11_FOUND) + unset(FLTK_USE_PANGO CACHE) + set(FLTK_USE_PANGO TRUE CACHE BOOL "use lib Pango") + if(FLTK_USE_SYSTEM_LIBDECOR) + pkg_check_modules(SYSTEM_LIBDECOR libdecor-0>=0.2.0 QUIET) + if(NOT SYSTEM_LIBDECOR_FOUND) + message(STATUS "Warning: system libdecor doesn't satisfy version >= 0.2.0,") + message(STATUS " using bundled libdecor library instead.") + set(USE_SYSTEM_LIBDECOR 0) + else() pkg_get_variable(LIBDECOR_LIBDIR libdecor-0 libdir) - set (LIBDECOR_PLUGIN_DIR ${LIBDECOR_LIBDIR}/libdecor/plugins-1) - if (EXISTS ${LIBDECOR_PLUGIN_DIR} AND IS_DIRECTORY ${LIBDECOR_PLUGIN_DIR}) - set (LIBDECOR_PLUGIN_DIR "\"${LIBDECOR_PLUGIN_DIR}\"" ) - else () - set (OPTION_USE_SYSTEM_LIBDECOR OFF) - endif () - endif (NOT SYSTEM_LIBDECOR_FOUND) - endif (OPTION_USE_SYSTEM_LIBDECOR) + set(LIBDECOR_PLUGIN_DIR ${LIBDECOR_LIBDIR}/libdecor/plugins-1) + if(EXISTS ${LIBDECOR_PLUGIN_DIR} AND IS_DIRECTORY ${LIBDECOR_PLUGIN_DIR}) + set(LIBDECOR_PLUGIN_DIR "\"${LIBDECOR_PLUGIN_DIR}\"" ) + else() + set(USE_SYSTEM_LIBDECOR 0) + endif() + endif(NOT SYSTEM_LIBDECOR_FOUND) + endif(FLTK_USE_SYSTEM_LIBDECOR) - if (OPTION_USE_SYSTEM_LIBDECOR) - set (OPTION_ALLOW_GTK_PLUGIN ON) - else () - option (OPTION_ALLOW_GTK_PLUGIN "Allow to use libdecor's GTK plugin" ON) - endif (OPTION_USE_SYSTEM_LIBDECOR) + if(USE_SYSTEM_LIBDECOR) + set(FLTK_USE_LIBDECOR_GTK ON) + else() + option(FLTK_USE_LIBDECOR_GTK "Allow to use libdecor's GTK plugin" ON) + endif(USE_SYSTEM_LIBDECOR) - if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD") - CHECK_INCLUDE_FILE (linux/input.h LINUX_INPUT_H) - if (NOT LINUX_INPUT_H) - message (FATAL_ERROR "Required include file 'linux/input.h' is missing. Please install package 'evdev-proto'") - endif (NOT LINUX_INPUT_H) - endif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD") + if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD") + check_include_file(linux/input.h LINUX_INPUT_H) + if(NOT LINUX_INPUT_H) + message(FATAL_ERROR "Required include file 'linux/input.h' is missing. Please install package 'evdev-proto'") + endif(NOT LINUX_INPUT_H) + endif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD") - endif (OPTION_USE_WAYLAND) -endif (UNIX) + endif(FLTK_BACKEND_WAYLAND) +endif(UNIX) -if (WIN32) - option (OPTION_USE_GDIPLUS "use GDI+ when possible for antialiased graphics" ON) - if (OPTION_USE_GDIPLUS) - set (USE_GDIPLUS TRUE) - if (NOT MSVC) - list (APPEND FLTK_LDLIBS "-lgdiplus") - endif (NOT MSVC) - endif (OPTION_USE_GDIPLUS) -endif (WIN32) +if(WIN32) + option(FLTK_GRAPHICS_GDIPLUS "use GDI+ when possible for antialiased graphics" ON) + if(FLTK_GRAPHICS_GDIPLUS) + set(USE_GDIPLUS TRUE) + if(NOT MSVC) + list(APPEND FLTK_LDLIBS "-lgdiplus") + endif(NOT MSVC) + endif(FLTK_GRAPHICS_GDIPLUS) +endif(WIN32) ####################################################################### -if (APPLE) - option (OPTION_APPLE_X11 "use X11" OFF) - if (CMAKE_OSX_SYSROOT) - list (APPEND FLTK_CFLAGS "-isysroot ${CMAKE_OSX_SYSROOT}") - endif (CMAKE_OSX_SYSROOT) -endif (APPLE) - -####################################################################### -option (OPTION_USE_STD "allow FLTK to use some std:: features" OFF) -if (OPTION_USE_STD) - set (FLTK_USE_STD 1) -else () - set (FLTK_USE_STD 0) -endif () +option(FLTK_OPTION_STD "allow FLTK to use some std:: features" OFF) +if(FLTK_OPTION_STD) + set(FLTK_USE_STD 1) +else() + set(FLTK_USE_STD 0) +endif() ####################################################################### # find X11 libraries and headers -set (PATH_TO_XLIBS) -if ((NOT APPLE OR OPTION_APPLE_X11) AND NOT WIN32 AND NOT OPTION_USE_WAYLAND) - include (FindX11) - if (X11_FOUND) - set (FLTK_USE_X11 1) - list (APPEND FLTK_LDLIBS -lX11) - if (X11_Xext_FOUND) - list (APPEND FLTK_LDLIBS -lXext) - endif (X11_Xext_FOUND) - get_filename_component (PATH_TO_XLIBS ${X11_X11_LIB} PATH) - endif (X11_FOUND) -endif ((NOT APPLE OR OPTION_APPLE_X11) AND NOT WIN32 AND NOT OPTION_USE_WAYLAND) +set(PATH_TO_XLIBS) +if((NOT APPLE OR FLTK_BACKEND_X11) AND NOT WIN32 AND NOT FLTK_BACKEND_WAYLAND) + include(FindX11) + if(X11_FOUND) + set(FLTK_USE_X11 1) + list(APPEND FLTK_LDLIBS -lX11) + if(X11_Xext_FOUND) + list(APPEND FLTK_LDLIBS -lXext) + endif(X11_Xext_FOUND) + get_filename_component(PATH_TO_XLIBS ${X11_X11_LIB} PATH) + endif(X11_FOUND) +endif() -if (OPTION_APPLE_X11) - if (NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0)) # a.k.a. macOS version ≥ 10.13 - list (APPEND FLTK_CFLAGS "-D_LIBCPP_HAS_THREAD_API_PTHREAD") - endif (NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0)) - include_directories (AFTER SYSTEM /opt/X11/include/freetype2) - include_directories (AFTER SYSTEM /opt/X11/include) # for Xft.h - if (PATH_TO_XLIBS) - set (LDFLAGS "-L${PATH_TO_XLIBS} ${LDFLAGS}") - endif (PATH_TO_XLIBS) - if (X11_INCLUDE_DIR) - set (TEMP_INCLUDE_DIR ${X11_INCLUDE_DIR}) - list (TRANSFORM TEMP_INCLUDE_DIR PREPEND "-I") - list (APPEND FLTK_CFLAGS "${TEMP_INCLUDE_DIR}") - endif (X11_INCLUDE_DIR) -endif (OPTION_APPLE_X11) +if(FLTK_BACKEND_X11) + if(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0)) # a.k.a. macOS version ≥ 10.13 + list(APPEND FLTK_CFLAGS "-D_LIBCPP_HAS_THREAD_API_PTHREAD") + endif(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0)) + # FIXME: include_directories(!) + # FIXME: how can we implement "AFTER SYSTEM" ? + include_directories(AFTER SYSTEM /opt/X11/include/freetype2) + include_directories(AFTER SYSTEM /opt/X11/include) # for Xft.h + if(PATH_TO_XLIBS) + set(LDFLAGS "-L${PATH_TO_XLIBS} ${LDFLAGS}") + endif(PATH_TO_XLIBS) + if(X11_INCLUDE_DIR) + set(TEMP_INCLUDE_DIR ${X11_INCLUDE_DIR}) + list(TRANSFORM TEMP_INCLUDE_DIR PREPEND "-I") + list(APPEND FLTK_CFLAGS "${TEMP_INCLUDE_DIR}") + endif(X11_INCLUDE_DIR) +endif(FLTK_BACKEND_X11) ####################################################################### -option (OPTION_USE_POLL "use poll if available" OFF) -mark_as_advanced (OPTION_USE_POLL) +option(FLTK_USE_POLL "use poll if available" OFF) +mark_as_advanced(FLTK_USE_POLL) -if (OPTION_USE_POLL) +if(FLTK_USE_POLL) CHECK_FUNCTION_EXISTS(poll USE_POLL) -endif (OPTION_USE_POLL) +endif(FLTK_USE_POLL) ####################################################################### -option (OPTION_BUILD_SHARED_LIBS - "Build shared libraries (in addition to static libraries)" +option(FLTK_BUILD_SHARED_LIBS + "Build shared libraries in addition to static libraries" OFF ) ####################################################################### -option (OPTION_PRINT_SUPPORT "allow print support" ON) -option (OPTION_FILESYSTEM_SUPPORT "allow file system support" ON) +option(FLTK_OPTION_PRINT_SUPPORT "allow print support" ON) +option(FLTK_OPTION_FILESYSTEM_SUPPORT "allow file system support" ON) -option (FLTK_BUILD_FORMS "Build forms compatibility library" ON) -option (FLTK_BUILD_FLUID "Build FLUID" ON) -option (FLTK_BUILD_FLTK_OPTIONS "Build fltk-options" ON) -option (FLTK_BUILD_TEST "Build test/demo programs" ON) -option (FLTK_BUILD_EXAMPLES "Build example programs" OFF) +option(FLTK_BUILD_FORMS "Build forms compatibility library" ON) +option(FLTK_BUILD_FLUID "Build FLUID" ON) +option(FLTK_BUILD_FLTK_OPTIONS "Build fltk-options" ON) +option(FLTK_BUILD_EXAMPLES "Build example programs" OFF) -if (FLTK_BUILD_FORMS) - set (FLTK_HAVE_FORMS 1) -else () - set (FLTK_HAVE_FORMS 0) -endif () +if(FLTK_IS_TOPLEVEL) + option(FLTK_BUILD_TEST "Build test/demo programs" ON) +else() + option(FLTK_BUILD_TEST "Build test/demo programs" OFF) +endif() -if (DEFINED OPTION_BUILD_EXAMPLES) - message (WARNING - "'OPTION_BUILD_EXAMPLES' is obsolete, please use 'FLTK_BUILD_TEST' instead.") - message (STATUS - "To remove this warning, please delete 'OPTION_BUILD_EXAMPLES' from the CMake cache") -endif (DEFINED OPTION_BUILD_EXAMPLES) +if(FLTK_BUILD_FORMS) + set(FLTK_HAVE_FORMS 1) +else() + set(FLTK_HAVE_FORMS 0) +endif() ####################################################################### -if (DOXYGEN_FOUND) - option (OPTION_BUILD_HTML_DOCUMENTATION "build html docs" ON) - option (OPTION_INSTALL_HTML_DOCUMENTATION "install html docs" OFF) +if(DOXYGEN_FOUND) + option(FLTK_BUILD_HTML_DOCS "build html docs" ON) + option(FLTK_INSTALL_HTML_DOCS "install html docs" OFF) - option (OPTION_INCLUDE_DRIVER_DOCUMENTATION "include driver (developer) docs" OFF) - mark_as_advanced (OPTION_INCLUDE_DRIVER_DOCUMENTATION) + option(FLTK_INCLUDE_DRIVER_DOCS "include driver (developer) docs" OFF) + mark_as_advanced(FLTK_INCLUDE_DRIVER_DOCS) - if (LATEX_FOUND) - option (OPTION_BUILD_PDF_DOCUMENTATION "build pdf docs" ON) - option (OPTION_INSTALL_PDF_DOCUMENTATION "install pdf docs" OFF) - endif (LATEX_FOUND) -endif (DOXYGEN_FOUND) + if(LATEX_FOUND) + option(FLTK_BUILD_PDF_DOCS "build pdf docs" ON) + option(FLTK_INSTALL_PDF_DOCS "install pdf docs" OFF) + endif(LATEX_FOUND) +endif(DOXYGEN_FOUND) -if (OPTION_BUILD_HTML_DOCUMENTATION OR OPTION_BUILD_PDF_DOCUMENTATION) - add_subdirectory (documentation) -endif (OPTION_BUILD_HTML_DOCUMENTATION OR OPTION_BUILD_PDF_DOCUMENTATION) +if(FLTK_BUILD_HTML_DOCS OR FLTK_BUILD_PDF_DOCS) + add_subdirectory(documentation) +endif(FLTK_BUILD_HTML_DOCS OR FLTK_BUILD_PDF_DOCS) ####################################################################### # Include optional Cairo support ####################################################################### -option (OPTION_CAIRO "add support for Fl_Cairo_Window" OFF) -option (OPTION_CAIROEXT +option(FLTK_OPTION_CAIRO_WINDOW "add support for Fl_Cairo_Window" OFF) +option(FLTK_OPTION_CAIRO_EXT "use FLTK code instrumentation for Cairo extended use" OFF ) -set (FLTK_HAVE_CAIRO 0) -set (FLTK_HAVE_CAIROEXT 0) +set(FLTK_HAVE_CAIRO 0) +set(FLTK_HAVE_CAIROEXT 0) -if (OPTION_CAIRO OR OPTION_CAIROEXT) - pkg_search_module (PKG_CAIRO cairo) +if(FLTK_OPTION_CAIRO_WINDOW OR FLTK_OPTION_CAIRO_EXT) + pkg_search_module(PKG_CAIRO cairo) - # fl_debug_var (PKG_CAIRO_FOUND) + if(PKG_CAIRO_FOUND) + set(FLTK_HAVE_CAIRO 1) + if(FLTK_OPTION_CAIRO_EXT) + set(FLTK_HAVE_CAIROEXT 1) + endif(FLTK_OPTION_CAIRO_EXT) - if (PKG_CAIRO_FOUND) - set (FLTK_HAVE_CAIRO 1) - if (OPTION_CAIROEXT) - set (FLTK_HAVE_CAIROEXT 1) - endif (OPTION_CAIROEXT) - - ### FIXME ### - include_directories (${PKG_CAIRO_INCLUDE_DIRS}) + list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${PKG_CAIRO_INCLUDE_DIRS}) # Cairo libs and flags for fltk-config # Hint: use either PKG_CAIRO_* or PKG_CAIRO_STATIC_* variables to - # create the list of libraries used to link programs with cairo + # create the list of libraries used to link programs with Cairo # by running fltk-config --use-cairo --compile ... - # Currently we're using the non-STATIC variables to link cairo shared. + # Currently we're using the non-STATIC variables to link Cairo shared. - set (CAIROLIBS) - foreach (lib ${PKG_CAIRO_LIBRARIES}) - list (APPEND CAIROLIBS "-l${lib}") + set(CAIROLIBS) + foreach(lib ${PKG_CAIRO_LIBRARIES}) + list(APPEND CAIROLIBS "-l${lib}") endforeach() - string (REPLACE ";" " " CAIROLIBS "${CAIROLIBS}") - string (REPLACE ";" " " CAIROFLAGS "${PKG_CAIRO_CFLAGS}") + string(REPLACE ";" " " CAIROLIBS "${CAIROLIBS}") + string(REPLACE ";" " " CAIROFLAGS "${PKG_CAIRO_CFLAGS}") - else (PKG_CAIRO_FOUND) + else(PKG_CAIRO_FOUND) - if (NOT MSVC) - message (STATUS "*** Cairo was requested but not found - please check your cairo installation") - message (STATUS "*** or disable options OPTION_CAIRO and OPTION_CAIRO_EXT.") - message (FATAL_ERROR "*** Terminating: missing Cairo libs or headers.") - endif () + if(NOT MSVC) + message(STATUS "*** Cairo was requested but not found - please check your Cairo installation") + message(STATUS "*** or disable options FLTK_OPTION_CAIRO_WINDOW and FLTK_OPTION_CAIRO_EXT.") + message(FATAL_ERROR "*** Terminating: missing Cairo libs or headers.") + endif() # Tweak Cairo includes / libs / paths for Visual Studio (TEMPORARY solution). # Todo: find a better way to set the required variables and flags! # AlbrechtS 03/2023 - message (STATUS "--- Cairo not found: trying to find Cairo for MSVC ...") + message(STATUS "--- Cairo not found: trying to find Cairo for MSVC ...") - if (NOT FLTK_CAIRO_DIR) - message (STATUS "--- Please set FLTK_CAIRO_DIR to point at the Cairo installation folder ...") - message (STATUS " ... with files 'include/cairo.h' and 'lib/x64/cairo.lib'") - message (STATUS "--- Example: cmake -DFLTK_CAIRO_DIR=\"C:/cairo-windows\" ...") - message (STATUS "--- Note: this will be changed in the future; currently only 64-bit supported") - message (FATAL_ERROR "*** Terminating: missing Cairo libs or headers.") - endif () + if(NOT FLTK_CAIRO_DIR) + message(STATUS "--- Please set FLTK_CAIRO_DIR to point at the Cairo installation folder ...") + message(STATUS " ... with files 'include/cairo.h' and 'lib/x64/cairo.lib'") + message(STATUS "--- Example: cmake -DFLTK_CAIRO_DIR=\"C:/cairo-windows\" ...") + message(STATUS "--- Note: this will be changed in the future; currently only 64-bit supported") + message(FATAL_ERROR "*** Terminating: missing Cairo libs or headers.") + endif() - set (CAIROLIBS "-lcairo") # should be correct: needs cairo.lib + set(CAIROLIBS "-lcairo") # should be correct: needs cairo.lib # simulate results of 'pkg_search_module (PKG_CAIRO cairo)' and more (above) # these variables will be used later - set (PKG_CAIRO_LIBRARIES "cairo") - set (PKG_CAIRO_INCLUDE_DIRS "${FLTK_CAIRO_DIR}/include") - set (PKG_CAIRO_LIBRARY_DIRS "${FLTK_CAIRO_DIR}/lib/x64/") + set(PKG_CAIRO_LIBRARIES "cairo") + set(PKG_CAIRO_INCLUDE_DIRS "${FLTK_CAIRO_DIR}/include") + set(PKG_CAIRO_LIBRARY_DIRS "${FLTK_CAIRO_DIR}/lib/x64/") ### FIXME ### - include_directories (${PKG_CAIRO_INCLUDE_DIRS}) + include_directories(${PKG_CAIRO_INCLUDE_DIRS}) - set (FLTK_HAVE_CAIRO 1) - if (OPTION_CAIROEXT) - set (FLTK_HAVE_CAIROEXT 1) - endif (OPTION_CAIROEXT) + set(FLTK_HAVE_CAIRO 1) + if(FLTK_OPTION_CAIRO_EXT) + set(FLTK_HAVE_CAIROEXT 1) + endif(FLTK_OPTION_CAIRO_EXT) - endif (PKG_CAIRO_FOUND) + endif(PKG_CAIRO_FOUND) - if (0) # 1 = DEBUG, 0 = no output - message (STATUS "--- options.cmake: Cairo related variables ---") - if (MSVC) - fl_debug_var (FLTK_CAIRO_DIR) - endif (MSVC) - fl_debug_var (PKG_CAIRO_INCLUDE_DIRS) - fl_debug_var (PKG_CAIRO_CFLAGS) - fl_debug_var (PKG_CAIRO_LIBRARIES) - fl_debug_var (PKG_CAIRO_LIBRARY_DIRS) - fl_debug_var (PKG_CAIRO_STATIC_INCLUDE_DIRS) - fl_debug_var (PKG_CAIRO_STATIC_CFLAGS) - fl_debug_var (PKG_CAIRO_STATIC_LIBRARIES) - fl_debug_var (PKG_CAIRO_STATIC_LIBRARY_DIRS) - message (STATUS "--- fltk-config/Cairo variables ---") - fl_debug_var (FLTK_LDLIBS) - fl_debug_var (CAIROFLAGS) - fl_debug_var (CAIROLIBS) - message (STATUS "--- End of Cairo related variables ---") + if(0) # 1 = DEBUG, 0 = no output + message(STATUS "--- options.cmake: Cairo related variables ---") + if(MSVC) + fl_debug_var(FLTK_CAIRO_DIR) + endif(MSVC) + # fl_debug_pkg(PKG_CAIRO cairo) + fl_debug_var(PKG_CAIRO_INCLUDE_DIRS) + fl_debug_var(PKG_CAIRO_CFLAGS) + fl_debug_var(PKG_CAIRO_LIBRARIES) + fl_debug_var(PKG_CAIRO_LIBRARY_DIRS) + fl_debug_var(PKG_CAIRO_STATIC_INCLUDE_DIRS) + fl_debug_var(PKG_CAIRO_STATIC_CFLAGS) + fl_debug_var(PKG_CAIRO_STATIC_LIBRARIES) + fl_debug_var(PKG_CAIRO_STATIC_LIBRARY_DIRS) + message(STATUS "--- fltk-config/Cairo variables ---") + fl_debug_var(FLTK_LDLIBS) + fl_debug_var(CAIROFLAGS) + fl_debug_var(CAIROLIBS) + message(STATUS "--- End of Cairo related variables ---") endif() # 1 = DEBUG, ... -endif (OPTION_CAIRO OR OPTION_CAIROEXT) +endif(FLTK_OPTION_CAIRO_WINDOW OR FLTK_OPTION_CAIRO_EXT) ####################################################################### -option (OPTION_USE_SVG "read/write SVG files" ON) -if (OPTION_USE_SVG) - set (FLTK_USE_SVG 1) -endif (OPTION_USE_SVG) +option(FLTK_OPTION_SVG "read/write SVG image files" ON) + +if(FLTK_OPTION_SVG) + set(FLTK_USE_SVG 1) +else() + set(FLTK_USE_SVG 0) +endif(FLTK_OPTION_SVG) ####################################################################### -set (HAVE_GL LIB_GL OR LIB_MesaGL) -if (HAVE_GL) - option (OPTION_USE_GL "use OpenGL" ON) -endif (HAVE_GL) +# FIXME: GL libs have already been searched in resources.cmake -if (OPTION_USE_GL) - if (OPTION_USE_WAYLAND) +set(HAVE_GL LIB_GL OR LIB_MesaGL) +set(FLTK_USE_GL FALSE) + +if(HAVE_GL) + option(FLTK_BUILD_GL "use OpenGL and build fltk_gl library" ON) + if (FLTK_BUILD_GL) + set(FLTK_USE_GL TRUE) + endif() +endif() + +if(FLTK_BUILD_GL) + if(FLTK_BACKEND_WAYLAND) pkg_check_modules(WLD_EGL wayland-egl) pkg_check_modules(PKG_EGL egl) pkg_check_modules(PKG_GL gl) - if (NOT (WLD_EGL_FOUND AND PKG_EGL_FOUND AND PKG_GL_FOUND)) - message (STATUS "Modules 'wayland-egl, egl, and gl' are required to build for the Wayland backend.") - message (FATAL_ERROR "*** Aborting ***") - endif (NOT (WLD_EGL_FOUND AND PKG_EGL_FOUND AND PKG_GL_FOUND)) - endif (OPTION_USE_WAYLAND) - if (OPTION_APPLE_X11) - set (OPENGL_FOUND TRUE) + if(NOT (WLD_EGL_FOUND AND PKG_EGL_FOUND AND PKG_GL_FOUND)) + message(STATUS "Modules 'wayland-egl, egl, and gl' are required to build for the Wayland backend.") + message(FATAL_ERROR "*** Aborting ***") + endif(NOT (WLD_EGL_FOUND AND PKG_EGL_FOUND AND PKG_GL_FOUND)) + endif(FLTK_BACKEND_WAYLAND) + if(FLTK_BACKEND_X11) + set(OPENGL_FOUND TRUE) find_library(OPENGL_LIB GL) - get_filename_component (PATH_TO_GLLIB ${OPENGL_LIB} DIRECTORY) + get_filename_component(PATH_TO_GLLIB ${OPENGL_LIB} DIRECTORY) # with GL, must use XQuartz libX11 else "Insufficient GL support" - set (OPENGL_LIBRARIES -L${PATH_TO_GLLIB} -lX11 -lGLU -lGL) + set(OPENGL_LIBRARIES -L${PATH_TO_GLLIB} -lX11 -lGLU -lGL) unset(HAVE_GL_GLU_H CACHE) - find_file (HAVE_GL_GLU_H GL/glu.h PATHS ${X11_INCLUDE_DIR}) + find_file(HAVE_GL_GLU_H GL/glu.h PATHS ${X11_INCLUDE_DIR}) else() find_package(OpenGL) - if (APPLE) - set (HAVE_GL_GLU_H ${HAVE_OPENGL_GLU_H}) - endif (APPLE) - endif (OPTION_APPLE_X11) -else () - set (OPENGL_FOUND FALSE) - set (HAVE_GL FALSE) - set (HAVE_GL_GLU_H FALSE) - set (HAVE_GLXGETPROCADDRESSARB FALSE) -endif (OPTION_USE_GL) + if(APPLE) + set(HAVE_GL_GLU_H ${HAVE_OPENGL_GLU_H}) + endif(APPLE) + endif(FLTK_BACKEND_X11) +else() + set(OPENGL_FOUND FALSE) + set(HAVE_GL FALSE) + set(HAVE_GL_GLU_H FALSE) + set(HAVE_GLXGETPROCADDRESSARB FALSE) +endif(FLTK_BUILD_GL) -if (OPENGL_FOUND) - set (CMAKE_REQUIRED_INCLUDES ${OPENGL_INCLUDE_DIR}/GL) +if(OPENGL_FOUND) + set(CMAKE_REQUIRED_INCLUDES ${OPENGL_INCLUDE_DIR}/GL) # Set GLLIBS (used in fltk-config). # We should probably deduct this from OPENGL_LIBRARIES but it turned @@ -595,38 +637,38 @@ if (OPENGL_FOUND) # syntax depending on the platform (and maybe also CMake version). # Hence we use the following code... - if (WIN32) - set (GLLIBS "-lglu32 -lopengl32") - elseif (APPLE AND NOT OPTION_APPLE_X11) - set (GLLIBS "-framework OpenGL") - elseif (OPTION_USE_WAYLAND) - set (GLLIBS "-lwayland-egl -lEGL -lGLU -lGL") - else () - set (GLLIBS "-lGLU -lGL") - endif (WIN32) + if(WIN32) + set(GLLIBS "-lglu32 -lopengl32") + elseif(APPLE AND NOT FLTK_BACKEND_X11) + set(GLLIBS "-framework OpenGL") + elseif(FLTK_BACKEND_WAYLAND) + set(GLLIBS "-lwayland-egl -lEGL -lGLU -lGL") + else() + set(GLLIBS "-lGLU -lGL") + endif(WIN32) # check if function glXGetProcAddressARB exists - set (TEMP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) - set (CMAKE_REQUIRED_LIBRARIES ${OPENGL_LIBRARIES}) - CHECK_FUNCTION_EXISTS (glXGetProcAddressARB HAVE_GLXGETPROCADDRESSARB) - set (CMAKE_REQUIRED_LIBRARIES ${TEMP_REQUIRED_LIBRARIES}) - unset (TEMP_REQUIRED_LIBRARIES) + set(TEMP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_LIBRARIES}) + check_function_exists(glXGetProcAddressARB HAVE_GLXGETPROCADDRESSARB) + set(CMAKE_REQUIRED_LIBRARIES ${TEMP_REQUIRED_LIBRARIES}) + unset(TEMP_REQUIRED_LIBRARIES) - set (FLTK_GL_FOUND TRUE) -else () - set (FLTK_GL_FOUND FALSE) - set (GLLIBS) -endif (OPENGL_FOUND) + set(FLTK_GL_FOUND TRUE) +else() + set(FLTK_GL_FOUND FALSE) + set(GLLIBS) +endif(OPENGL_FOUND) ####################################################################### -option (OPTION_LARGE_FILE "enable large file support" ON) +option(FLTK_OPTION_LARGE_FILE "enable large file support" ON) -if (OPTION_LARGE_FILE) - if (NOT MSVC) - add_definitions (-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) - list (APPEND FLTK_CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) - endif (NOT MSVC) -endif (OPTION_LARGE_FILE) +if(FLTK_OPTION_LARGE_FILE) + if(NOT MSVC) + add_definitions(-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) + list(APPEND FLTK_CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) + endif(NOT MSVC) +endif(FLTK_OPTION_LARGE_FILE) ####################################################################### # Create an option whether we want to check for pthreads. @@ -636,221 +678,222 @@ endif (OPTION_LARGE_FILE) # Note: HAVE_PTHREAD_H has already been determined in resources.cmake # before this file is included (or set to 0 for WIN32). -if (WIN32 AND NOT CYGWIN) - # set (HAVE_PTHREAD_H 0) # (see resources.cmake) - set (OPTION_USE_THREADS FALSE) -else () - option (OPTION_USE_THREADS "use multi-threading with pthreads" ON) -endif (WIN32 AND NOT CYGWIN) +if(WIN32 AND NOT CYGWIN) + # set(HAVE_PTHREAD_H 0) # (see resources.cmake) + set(FLTK_USE_PTHREADS FALSE) +else() + option(FLTK_USE_PTHREADS "use multi-threading with pthreads" ON) +endif(WIN32 AND NOT CYGWIN) # initialize more variables -set (USE_THREADS 0) -set (HAVE_PTHREAD 0) -set (FLTK_PTHREADS_FOUND FALSE) +set(USE_THREADS 0) +set(HAVE_PTHREAD 0) +set(FLTK_PTHREADS_FOUND FALSE) -if (OPTION_USE_THREADS) +if(FLTK_USE_PTHREADS) - include (FindThreads) + include(FindThreads) - if (CMAKE_HAVE_THREADS_LIBRARY) - add_definitions ("-D_THREAD_SAFE -D_REENTRANT") - set (USE_THREADS 1) - set (FLTK_THREADS_FOUND TRUE) - endif (CMAKE_HAVE_THREADS_LIBRARY) + if(CMAKE_HAVE_THREADS_LIBRARY) + add_definitions("-D_THREAD_SAFE -D_REENTRANT") + set(USE_THREADS 1) + set(FLTK_THREADS_FOUND TRUE) + endif(CMAKE_HAVE_THREADS_LIBRARY) - if (CMAKE_USE_PTHREADS_INIT AND NOT WIN32) - set (HAVE_PTHREAD 1) - if (NOT APPLE) - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread") - endif (NOT APPLE) - list (APPEND FLTK_LDLIBS -lpthread) - list (APPEND FLTK_CFLAGS -D_THREAD_SAFE -D_REENTRANT) - set (FLTK_PTHREADS_FOUND TRUE) + if(CMAKE_USE_PTHREADS_INIT AND NOT WIN32) + set(HAVE_PTHREAD 1) + if(NOT APPLE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread") + endif(NOT APPLE) + list(APPEND FLTK_LDLIBS -lpthread) + list(APPEND FLTK_CFLAGS -D_THREAD_SAFE -D_REENTRANT) + set(FLTK_PTHREADS_FOUND TRUE) else() - set (HAVE_PTHREAD 0) - set (HAVE_PTHREAD_H 0) - set (FLTK_PTHREADS_FOUND FALSE) - endif (CMAKE_USE_PTHREADS_INIT AND NOT WIN32) + set(HAVE_PTHREAD 0) + set(HAVE_PTHREAD_H 0) + set(FLTK_PTHREADS_FOUND FALSE) + endif(CMAKE_USE_PTHREADS_INIT AND NOT WIN32) -else (OPTION_USE_THREADS) +else(FLTK_USE_PTHREADS) - set (HAVE_PTHREAD_H 0) + set(HAVE_PTHREAD_H 0) -endif (OPTION_USE_THREADS) +endif(FLTK_USE_PTHREADS) -set (debug_threads 0) # set to 1 to show debug info -if (debug_threads) - message ("") - message (STATUS "options.cmake: set debug_threads to 0 to disable the following info:") - fl_debug_var(OPTION_USE_THREADS) +set(debug_threads 0) # set to 1 to show debug info +if(debug_threads) + message("") + message(STATUS "options.cmake: set debug_threads to 0 to disable the following info:") + fl_debug_var(FLTK_USE_PTHREADS) fl_debug_var(HAVE_PTHREAD) fl_debug_var(HAVE_PTHREAD_H) fl_debug_var(FLTK_THREADS_FOUND) fl_debug_var(CMAKE_EXE_LINKER_FLAGS) - message (STATUS "options.cmake: end of debug_threads info.") -endif (debug_threads) -unset (debug_threads) + message(STATUS "options.cmake: end of debug_threads info.") +endif(debug_threads) +unset(debug_threads) ####################################################################### -if (X11_Xinerama_FOUND) - option (OPTION_USE_XINERAMA "use lib Xinerama" ON) -endif (X11_Xinerama_FOUND) +if(X11_Xinerama_FOUND) + option(FLTK_USE_XINERAMA "use lib Xinerama" ON) +endif(X11_Xinerama_FOUND) -if (OPTION_USE_XINERAMA) - set (HAVE_XINERAMA ${X11_Xinerama_FOUND}) - include_directories (${X11_Xinerama_INCLUDE_PATH}) - list (APPEND FLTK_LDLIBS -lXinerama) - set (FLTK_XINERAMA_FOUND TRUE) +if(FLTK_USE_XINERAMA) + set(HAVE_XINERAMA ${X11_Xinerama_FOUND}) + list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${X11_Xinerama_INCLUDE_PATH}) + list(APPEND FLTK_LDLIBS -lXinerama) + set(FLTK_XINERAMA_FOUND TRUE) else() - set (FLTK_XINERAMA_FOUND FALSE) -endif (OPTION_USE_XINERAMA) + set(FLTK_XINERAMA_FOUND FALSE) +endif(FLTK_USE_XINERAMA) ####################################################################### -if (X11_Xfixes_FOUND) - option (OPTION_USE_XFIXES "use lib Xfixes" ON) -endif (X11_Xfixes_FOUND) +if(X11_Xfixes_FOUND) + option(FLTK_USE_XFIXES "use lib Xfixes" ON) +endif(X11_Xfixes_FOUND) -if (OPTION_USE_XFIXES) - set (HAVE_XFIXES ${X11_Xfixes_FOUND}) - include_directories (${X11_Xfixes_INCLUDE_PATH}) - list (APPEND FLTK_LDLIBS -lXfixes) - set (FLTK_XFIXES_FOUND TRUE) +if(FLTK_USE_XFIXES) + set(HAVE_XFIXES ${X11_Xfixes_FOUND}) + list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${X11_Xfixes_INCLUDE_PATH}) + list(APPEND FLTK_LDLIBS -lXfixes) + set(FLTK_XFIXES_FOUND TRUE) else() - set (FLTK_XFIXES_FOUND FALSE) -endif (OPTION_USE_XFIXES) + set(FLTK_XFIXES_FOUND FALSE) +endif(FLTK_USE_XFIXES) ####################################################################### -if (X11_Xcursor_FOUND) - option (OPTION_USE_XCURSOR "use lib Xcursor" ON) -endif (X11_Xcursor_FOUND) +if(X11_Xcursor_FOUND) + option(FLTK_USE_XCURSOR "use lib Xcursor" ON) +endif(X11_Xcursor_FOUND) -if (OPTION_USE_XCURSOR) - set (HAVE_XCURSOR ${X11_Xcursor_FOUND}) - include_directories (${X11_Xcursor_INCLUDE_PATH}) - list (APPEND FLTK_LDLIBS -lXcursor) - set (FLTK_XCURSOR_FOUND TRUE) +if(FLTK_USE_XCURSOR) + set(HAVE_XCURSOR ${X11_Xcursor_FOUND}) + list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${X11_Xcursor_INCLUDE_PATH}) + list(APPEND FLTK_LDLIBS -lXcursor) + set(FLTK_XCURSOR_FOUND TRUE) else() - set (FLTK_XCURSOR_FOUND FALSE) -endif (OPTION_USE_XCURSOR) + set(FLTK_XCURSOR_FOUND FALSE) +endif(FLTK_USE_XCURSOR) ####################################################################### -if (X11_Xft_FOUND) - option (OPTION_USE_XFT "use lib Xft" ON) - option (OPTION_USE_PANGO "use lib Pango" OFF) - if (NOT OPTION_USE_WAYLAND) - option (OPTION_USE_CAIRO "all drawing to X11 windows uses Cairo" OFF) - endif (NOT OPTION_USE_WAYLAND) -endif (X11_Xft_FOUND) +if(X11_Xft_FOUND) + option(FLTK_USE_XFT "use lib Xft" ON) + option(FLTK_USE_PANGO "use lib Pango" OFF) + if(NOT FLTK_BACKEND_WAYLAND) + option(FLTK_GRAPHICS_CAIRO "all drawing to X11 windows uses Cairo" OFF) + endif(NOT FLTK_BACKEND_WAYLAND) +endif(X11_Xft_FOUND) # test option compatibility: Cairo for Xlib requires Pango -if (OPTION_USE_CAIRO) - unset (OPTION_USE_PANGO CACHE) - set (OPTION_USE_PANGO TRUE CACHE BOOL "use lib Pango") -endif (OPTION_USE_CAIRO) +if(FLTK_GRAPHICS_CAIRO) + unset(FLTK_USE_PANGO CACHE) + set(FLTK_USE_PANGO TRUE CACHE BOOL "use lib Pango") +endif(FLTK_GRAPHICS_CAIRO) -if (OPTION_USE_PANGO OR OPTION_USE_CAIRO) - if (OPTION_USE_WAYLAND OR OPTION_APPLE_X11) - set (USE_PANGOXFT false) - else () - set (USE_PANGOXFT true) - endif (OPTION_USE_WAYLAND OR OPTION_APPLE_X11) -endif (OPTION_USE_PANGO OR OPTION_USE_CAIRO) +if(FLTK_USE_PANGO OR FLTK_GRAPHICS_CAIRO) + if(FLTK_BACKEND_WAYLAND OR FLTK_BACKEND_X11) + set(USE_PANGOXFT false) + else() + set(USE_PANGOXFT true) + endif() +endif() # test option compatibility: Pango requires Xft -if (USE_PANGOXFT) - if (NOT X11_Xft_FOUND) - message (STATUS "Pango requires Xft but Xft library or headers could not be found.") - message (STATUS "Please install Xft development files and try again or disable OPTION_USE_PANGO.") - message (FATAL_ERROR "*** Aborting ***") - else () - if (NOT OPTION_USE_XFT) - message (STATUS "Pango requires Xft but usage of Xft was disabled.") - message (STATUS "Please enable OPTION_USE_XFT and try again or disable OPTION_USE_PANGO.") - message (FATAL_ERROR "*** Aborting ***") - endif (NOT OPTION_USE_XFT) - endif (NOT X11_Xft_FOUND) -endif (USE_PANGOXFT) +if(USE_PANGOXFT) + if(NOT X11_Xft_FOUND) + message(STATUS "Pango requires Xft but Xft library or headers could not be found.") + message(STATUS "Please install Xft development files and try again or disable FLTK_USE_PANGO.") + message(FATAL_ERROR "*** Aborting ***") + else() + if(NOT FLTK_USE_XFT) + message(STATUS "Pango requires Xft but usage of Xft was disabled.") + message(STATUS "Please enable FLTK_USE_XFT and try again or disable FLTK_USE_PANGO.") + message(FATAL_ERROR "*** Aborting ***") + endif(NOT FLTK_USE_XFT) + endif(NOT X11_Xft_FOUND) +endif(USE_PANGOXFT) ####################################################################### -if ((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND OPTION_USE_PANGO) +if((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND FLTK_USE_PANGO) pkg_check_modules(CAIRO cairo) - if (USE_PANGOXFT) + if(USE_PANGOXFT) pkg_check_modules(PANGOXFT pangoxft) - endif (USE_PANGOXFT) + endif(USE_PANGOXFT) pkg_check_modules(PANGOCAIRO pangocairo) - if ((PANGOXFT_FOUND OR NOT USE_PANGOXFT) AND PANGOCAIRO_FOUND AND CAIRO_FOUND) - if (USE_PANGOXFT) - include_directories (${PANGOXFT_INCLUDE_DIRS}) - else () - include_directories (${PANGOCAIRO_INCLUDE_DIRS}) - endif (USE_PANGOXFT) - include_directories (${CAIRO_INCLUDE_DIRS}) + if((PANGOXFT_FOUND OR NOT USE_PANGOXFT) AND PANGOCAIRO_FOUND AND CAIRO_FOUND) + if(USE_PANGOXFT) + list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${PANGOXFT_INCLUDE_DIRS}) + else() + list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${PANGOCAIRO_INCLUDE_DIRS}) + endif(USE_PANGOXFT) + list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${CAIRO_INCLUDE_DIRS}) - find_library (HAVE_LIB_PANGO pango-1.0 ${CMAKE_LIBRARY_PATH}) - if (USE_PANGOXFT) - find_library (HAVE_LIB_PANGOXFT pangoxft-1.0 ${CMAKE_LIBRARY_PATH}) - endif (USE_PANGOXFT) - find_library (HAVE_LIB_PANGOCAIRO pangocairo-1.0 ${CMAKE_LIBRARY_PATH}) - find_library (HAVE_LIB_CAIRO cairo ${CMAKE_LIBRARY_PATH}) - find_library (HAVE_LIB_GOBJECT gobject-2.0 ${CMAKE_LIBRARY_PATH}) + find_library(HAVE_LIB_PANGO pango-1.0 ${CMAKE_LIBRARY_PATH}) + mark_as_advanced(HAVE_LIB_PANGO) - mark_as_advanced (HAVE_LIB_PANGO) - if (USE_PANGOXFT) - mark_as_advanced (HAVE_LIB_PANGOXFT) - endif (USE_PANGOXFT) - mark_as_advanced (HAVE_LIB_PANGOCAIRO) - mark_as_advanced (HAVE_LIB_CAIRO) - mark_as_advanced (HAVE_LIB_GOBJECT) + if(USE_PANGOXFT) + find_library(HAVE_LIB_PANGOXFT pangoxft-1.0 ${CMAKE_LIBRARY_PATH}) + mark_as_advanced(HAVE_LIB_PANGOXFT) + endif(USE_PANGOXFT) - set (USE_PANGO TRUE) + find_library(HAVE_LIB_PANGOCAIRO pangocairo-1.0 ${CMAKE_LIBRARY_PATH}) + mark_as_advanced(HAVE_LIB_PANGOCAIRO) + + find_library(HAVE_LIB_CAIRO cairo ${CMAKE_LIBRARY_PATH}) + mark_as_advanced(HAVE_LIB_CAIRO) + + find_library(HAVE_LIB_GOBJECT gobject-2.0 ${CMAKE_LIBRARY_PATH}) + mark_as_advanced(HAVE_LIB_GOBJECT) + + set(USE_PANGO TRUE) # add required libraries to fltk-config ... - if (USE_PANGOXFT) - list (APPEND FLTK_LDLIBS ${PANGOXFT_LDFLAGS}) - endif (USE_PANGOXFT) - list (APPEND FLTK_LDLIBS ${PANGOCAIRO_LDFLAGS}) - list (APPEND FLTK_LDLIBS ${CAIRO_LDFLAGS}) + if(USE_PANGOXFT) + list(APPEND FLTK_LDLIBS ${PANGOXFT_LDFLAGS}) + endif(USE_PANGOXFT) + list(APPEND FLTK_LDLIBS ${PANGOCAIRO_LDFLAGS}) + list(APPEND FLTK_LDLIBS ${CAIRO_LDFLAGS}) # *FIXME* Libraries should not be added explicitly if possible - if (OPTION_USE_WAYLAND) - list (APPEND FLTK_LDLIBS -lgtk-3 -lgdk-3 -lgio-2.0) - if (NOT OPTION_WAYLAND_ONLY) - list (APPEND FLTK_LDLIBS -lX11) - endif (NOT OPTION_WAYLAND_ONLY) - endif (OPTION_USE_WAYLAND) + if(FLTK_BACKEND_WAYLAND) + list(APPEND FLTK_LDLIBS -lgtk-3 -lgdk-3 -lgio-2.0) + if(FLTK_BACKEND_X11) + list(APPEND FLTK_LDLIBS -lX11) + endif() + endif() - if (APPLE) + if(APPLE) get_filename_component(PANGO_L_PATH ${HAVE_LIB_PANGO} PATH) - set (LDFLAGS "${LDFLAGS} -L${PANGO_L_PATH}") - endif (APPLE) + set(LDFLAGS "${LDFLAGS} -L${PANGO_L_PATH}") + endif(APPLE) - else () + else() # this covers Debian, Ubuntu, FreeBSD, NetBSD, Darwin - if (APPLE AND OPTION_APPLE_X11) + if(APPLE AND FLTK_BACKEND_X11) find_file(FINK_PREFIX NAMES /opt/sw /sw) - list (APPEND CMAKE_INCLUDE_PATH ${FINK_PREFIX}/include) - include_directories (${FINK_PREFIX}/include/cairo) - list (APPEND CMAKE_LIBRARY_PATH ${FINK_PREFIX}/lib) - endif (APPLE AND OPTION_APPLE_X11) + list(APPEND CMAKE_INCLUDE_PATH ${FINK_PREFIX}/include) + list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${FINK_PREFIX}/include/cairo) + list(APPEND CMAKE_LIBRARY_PATH ${FINK_PREFIX}/lib) + endif(APPLE AND FLTK_BACKEND_X11) find_file(HAVE_PANGO_H pango-1.0/pango/pango.h ${CMAKE_INCLUDE_PATH}) find_file(HAVE_PANGOXFT_H pango-1.0/pango/pangoxft.h ${CMAKE_INCLUDE_PATH}) - if (HAVE_PANGO_H AND HAVE_PANGOXFT_H) + if(HAVE_PANGO_H AND HAVE_PANGOXFT_H) find_library(HAVE_LIB_PANGO pango-1.0 ${CMAKE_LIBRARY_PATH}) find_library(HAVE_LIB_PANGOXFT pangoxft-1.0 ${CMAKE_LIBRARY_PATH}) - if (APPLE) - set (HAVE_LIB_GOBJECT TRUE) + if(APPLE) + set(HAVE_LIB_GOBJECT TRUE) else() find_library(HAVE_LIB_GOBJECT gobject-2.0 ${CMAKE_LIBRARY_PATH}) - endif (APPLE) - endif (HAVE_PANGO_H AND HAVE_PANGOXFT_H) + endif(APPLE) + endif(HAVE_PANGO_H AND HAVE_PANGOXFT_H) - if (HAVE_LIB_PANGO AND HAVE_LIB_PANGOXFT AND HAVE_LIB_GOBJECT) - set (USE_PANGO TRUE) + if(HAVE_LIB_PANGO AND HAVE_LIB_PANGOXFT AND HAVE_LIB_GOBJECT) + set(USE_PANGO TRUE) # remove last 3 components of HAVE_PANGO_H and put in PANGO_H_PREFIX get_filename_component(PANGO_H_PREFIX ${HAVE_PANGO_H} PATH) get_filename_component(PANGO_H_PREFIX ${PANGO_H_PREFIX} PATH) @@ -861,122 +904,136 @@ if ((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND OPTION_USE_PANGO) find_path(GLIB_H_PATH glib.h PATHS ${PANGO_H_PREFIX}/glib-2.0 ${PANGO_H_PREFIX}/glib/glib-2.0) - include_directories (${PANGO_H_PREFIX}/pango-1.0 ${GLIB_H_PATH} ${PANGOLIB_DIR}/glib-2.0/include) + list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${PANGO_H_PREFIX}/pango-1.0 ${GLIB_H_PATH} ${PANGOLIB_DIR}/glib-2.0/include) # *FIXME* Libraries should not be added explicitly if possible - list (APPEND FLTK_LDLIBS -lpango-1.0 -lpangoxft-1.0 -lgobject-2.0) + list(APPEND FLTK_LDLIBS -lpango-1.0 -lpangoxft-1.0 -lgobject-2.0) - endif (HAVE_LIB_PANGO AND HAVE_LIB_PANGOXFT AND HAVE_LIB_GOBJECT) - endif ((PANGOXFT_FOUND OR NOT USE_PANGOXFT) AND PANGOCAIRO_FOUND AND CAIRO_FOUND) + endif(HAVE_LIB_PANGO AND HAVE_LIB_PANGOXFT AND HAVE_LIB_GOBJECT) + endif((PANGOXFT_FOUND OR NOT USE_PANGOXFT) AND PANGOCAIRO_FOUND AND CAIRO_FOUND) - if (USE_PANGO AND (OPTION_USE_CAIRO OR OPTION_USE_WAYLAND)) - set (FLTK_USE_CAIRO 1) - # fl_debug_var (FLTK_USE_CAIRO) - endif (USE_PANGO AND (OPTION_USE_CAIRO OR OPTION_USE_WAYLAND)) + if(USE_PANGO AND (FLTK_GRAPHICS_CAIRO OR FLTK_BACKEND_WAYLAND)) + set(FLTK_USE_CAIRO 1) + # fl_debug_var(FLTK_USE_CAIRO) + endif() -endif ((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND OPTION_USE_PANGO) +endif((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND FLTK_USE_PANGO) -if (OPTION_USE_WAYLAND) +if(FLTK_BACKEND_WAYLAND) - # Note: Disable OPTION_ALLOW_GTK_PLUGIN to get cairo titlebars rather than GTK - if (OPTION_ALLOW_GTK_PLUGIN) + # Note: Disable FLTK_USE_LIBDECOR_GTK to get cairo titlebars rather than GTK + if(FLTK_USE_LIBDECOR_GTK) pkg_check_modules(GTK gtk+-3.0) - if (GTK_FOUND) - include_directories (${GTK_INCLUDE_DIRS}) - else () + if(GTK_FOUND) + list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${GTK_INCLUDE_DIRS}) + else() message(WARNING "Installation of the development files for the GTK library " "(e.g., libgtk-3-dev) is recommended when using the gnome desktop.") - endif (GTK_FOUND) - endif (OPTION_ALLOW_GTK_PLUGIN) + endif(GTK_FOUND) + endif(FLTK_USE_LIBDECOR_GTK) -endif (OPTION_USE_WAYLAND) +endif() -if (OPTION_USE_XFT) - set (USE_XFT X11_Xft_FOUND) - list (APPEND FLTK_LDLIBS -lXft) - set (FLTK_XFT_FOUND TRUE) - if (APPLE AND OPTION_APPLE_X11) +if(FLTK_USE_XFT) + set(USE_XFT X11_Xft_FOUND) + list(APPEND FLTK_LDLIBS -lXft) + set(FLTK_XFT_FOUND TRUE) + if(APPLE AND FLTK_BACKEND_X11) find_library(LIB_fontconfig fontconfig "/opt/X11/lib") - endif (APPLE AND OPTION_APPLE_X11) + endif() else() - set (FLTK_XFT_FOUND FALSE) -endif (OPTION_USE_XFT) + set(FLTK_XFT_FOUND FALSE) +endif(FLTK_USE_XFT) ####################################################################### -if (X11_Xrender_FOUND) - option (OPTION_USE_XRENDER "use lib Xrender" ON) -endif (X11_Xrender_FOUND) +if(X11_Xrender_FOUND) + option(FLTK_USE_XRENDER "use lib Xrender" ON) +endif(X11_Xrender_FOUND) -if (OPTION_USE_XRENDER) - set (HAVE_XRENDER ${X11_Xrender_FOUND}) - if (HAVE_XRENDER) - include_directories (${X11_Xrender_INCLUDE_PATH}) - list (APPEND FLTK_LDLIBS -lXrender) - set (FLTK_XRENDER_FOUND TRUE) +if(FLTK_USE_XRENDER) + set(HAVE_XRENDER ${X11_Xrender_FOUND}) + if(HAVE_XRENDER) + list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${X11_Xrender_INCLUDE_PATH}) + list(APPEND FLTK_LDLIBS -lXrender) + set(FLTK_XRENDER_FOUND TRUE) else(HAVE_XRENDER) - set (FLTK_XRENDER_FOUND FALSE) - endif (HAVE_XRENDER) -else(OPTION_USE_XRENDER) - set (FLTK_XRENDER_FOUND FALSE) -endif (OPTION_USE_XRENDER) + set(FLTK_XRENDER_FOUND FALSE) + endif(HAVE_XRENDER) +else(FLTK_USE_XRENDER) + set(FLTK_XRENDER_FOUND FALSE) +endif(FLTK_USE_XRENDER) ####################################################################### -set (FL_NO_PRINT_SUPPORT FALSE) -if (X11_FOUND AND NOT OPTION_PRINT_SUPPORT) - set (FL_NO_PRINT_SUPPORT TRUE) -endif (X11_FOUND AND NOT OPTION_PRINT_SUPPORT) +set(FL_NO_PRINT_SUPPORT FALSE) +if(X11_FOUND AND NOT FLTK_OPTION_PRINT_SUPPORT) + set(FL_NO_PRINT_SUPPORT TRUE) +endif(X11_FOUND AND NOT FLTK_OPTION_PRINT_SUPPORT) ####################################################################### ####################################################################### -set (FL_CFG_NO_FILESYSTEM_SUPPORT TRUE) -if (OPTION_FILESYSTEM_SUPPORT) - set (FL_CFG_NO_FILESYSTEM_SUPPORT FALSE) -endif (OPTION_FILESYSTEM_SUPPORT) +set(FL_CFG_NO_FILESYSTEM_SUPPORT TRUE) +if(FLTK_OPTION_FILESYSTEM_SUPPORT) + set(FL_CFG_NO_FILESYSTEM_SUPPORT FALSE) +endif(FLTK_OPTION_FILESYSTEM_SUPPORT) ####################################################################### ####################################################################### -option (OPTION_USE_KDIALOG "Fl_Native_File_Chooser may run kdialog" ON) -if (OPTION_USE_KDIALOG) - set (USE_KDIALOG 1) -else () - set (USE_KDIALOG 0) -endif (OPTION_USE_KDIALOG) +option(FLTK_USE_KDIALOG "Fl_Native_File_Chooser may run kdialog" ON) +if(FLTK_USE_KDIALOG) + set(USE_KDIALOG 1) +else() + set(USE_KDIALOG 0) +endif() ####################################################################### ####################################################################### -option (CMAKE_SUPPRESS_REGENERATION "suppress rules to re-run CMake on rebuild" OFF) -mark_as_advanced (CMAKE_SUPPRESS_REGENERATION) +option(CMAKE_SUPPRESS_REGENERATION "suppress rules to re-run CMake on rebuild" OFF) +mark_as_advanced(CMAKE_SUPPRESS_REGENERATION) + +####################################################################### +# Clean up ... + +# *** FIXME *** Do we need all these variables ? + +list(REMOVE_DUPLICATES FLTK_BUILD_INCLUDE_DIRECTORIES) +list(REMOVE_DUPLICATES FLTK_IMAGE_INCLUDE_DIRECTORIES) +list(REMOVE_DUPLICATES FLTK_IMAGE_LIBRARIES) ####################################################################### # Debugging ... -if (DEBUG_OPTIONS_CMAKE) - message (STATUS "") # empty line - fl_debug_var (WIN32) - fl_debug_var (LIBS) - fl_debug_var (GLLIBS) - fl_debug_var (FLTK_LDLIBS) - fl_debug_var (OPENGL_FOUND) - fl_debug_var (OPENGL_INCLUDE_DIR) - fl_debug_var (OPENGL_LIBRARIES) - fl_debug_var (CMAKE_MSVC_RUNTIME_LIBRARY) - message ("--- bundled libraries ---") - fl_debug_var (OPTION_USE_SYSTEM_LIBJPEG) - fl_debug_var (OPTION_USE_SYSTEM_LIBPNG) - fl_debug_var (OPTION_USE_SYSTEM_ZLIB) - fl_debug_var (FLTK_USE_BUILTIN_JPEG) - fl_debug_var (FLTK_USE_BUILTIN_PNG) - fl_debug_var (FLTK_USE_BUILTIN_ZLIB) - message ("--- X11 ---") - fl_debug_var (X11_FOUND) - fl_debug_var (X11_INCLUDE_DIR) - fl_debug_var (X11_LIBRARIES) - fl_debug_var (X11_X11_LIB) - fl_debug_var (X11_X11_INCLUDE_PATH) - fl_debug_var (X11_Xft_INCLUDE_PATH) - fl_debug_var (X11_Xft_LIB) - fl_debug_var (X11_Xft_FOUND) - fl_debug_var (PATH_TO_XLIBS) - message (STATUS "[** end of options.cmake **]") -endif (DEBUG_OPTIONS_CMAKE) -unset (DEBUG_OPTIONS_CMAKE) +if(DEBUG_OPTIONS_CMAKE) + message(STATUS "") # empty line + fl_debug_var(WIN32) + fl_debug_var(LIBS) + fl_debug_var(GLLIBS) + fl_debug_var(FLTK_LDLIBS) + fl_debug_var(OPENGL_FOUND) + fl_debug_var(OPENGL_INCLUDE_DIR) + fl_debug_var(OPENGL_LIBRARIES) + fl_debug_var(CMAKE_MSVC_RUNTIME_LIBRARY) + message("--- bundled libraries ---") + fl_debug_var(FLTK_USE_SYSTEM_LIBJPEG) + fl_debug_var(FLTK_USE_SYSTEM_LIBPNG) + fl_debug_var(FLTK_USE_SYSTEM_ZLIB) + fl_debug_var(FLTK_USE_BUNDLED_JPEG) + fl_debug_var(FLTK_USE_BUNDLED_PNG) + fl_debug_var(FLTK_USE_BUNDLED_ZLIB) + + message(STATUS "--- *FIXME* include directories ---") + fl_debug_var(FLTK_BUILD_INCLUDE_DIRECTORIES) + fl_debug_var(FLTK_IMAGE_INCLUDE_DIRECTORIES) + + message("--- X11 ---") + fl_debug_var(X11_FOUND) + fl_debug_var(X11_INCLUDE_DIR) + fl_debug_var(X11_LIBRARIES) + fl_debug_var(X11_X11_LIB) + fl_debug_var(X11_X11_INCLUDE_PATH) + fl_debug_var(X11_Xft_INCLUDE_PATH) + fl_debug_var(X11_Xft_LIB) + fl_debug_var(X11_Xft_FOUND) + fl_debug_var(PATH_TO_XLIBS) + message(STATUS "[** end of options.cmake **]") +endif(DEBUG_OPTIONS_CMAKE) +unset(DEBUG_OPTIONS_CMAKE) diff --git a/CMake/resources.cmake b/CMake/resources.cmake index aa17f73b3..7ee2c665d 100644 --- a/CMake/resources.cmake +++ b/CMake/resources.cmake @@ -1,8 +1,8 @@ # # 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 # 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(). # 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) - check_include_files ("${HEADER}" ${VAR}) - if (NOT CMAKE_REQUIRED_QUIET) - fl_debug_var (${VAR}) - endif (NOT CMAKE_REQUIRED_QUIET) + check_include_files("${HEADER}" ${VAR}) + if(NOT CMAKE_REQUIRED_QUIET) + fl_debug_var(${VAR}) + endif(NOT CMAKE_REQUIRED_QUIET) endmacro (fl_find_header) ####################################################################### # Include FindPkgConfig for later use of pkg-config ####################################################################### -include (FindPkgConfig) +include(FindPkgConfig) -# fl_debug_var (PKG_CONFIG_FOUND) -# fl_debug_var (PKG_CONFIG_EXECUTABLE) -# fl_debug_var (PKG_CONFIG_VERSION_STRING) +# fl_debug_var(PKG_CONFIG_FOUND) +# fl_debug_var(PKG_CONFIG_EXECUTABLE) +# fl_debug_var(PKG_CONFIG_VERSION_STRING) ####################################################################### # Find header files... ####################################################################### -if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD") - list (APPEND CMAKE_REQUIRED_INCLUDES /usr/local/include) -endif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD") +if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD") + list(APPEND CMAKE_REQUIRED_INCLUDES /usr/local/include) +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_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") -if (WIN32 AND NOT CYGWIN) +if(WIN32 AND NOT CYGWIN) # we don't use pthreads on Windows (except for Cygwin, see options.cmake) - set (HAVE_PTHREAD_H 0) -else () + set(HAVE_PTHREAD_H 0) +else() fl_find_header (HAVE_PTHREAD_H pthread.h) -endif (WIN32 AND NOT CYGWIN) +endif(WIN32 AND NOT CYGWIN) # Do we have PTHREAD_MUTEX_RECURSIVE ? -if (HAVE_PTHREAD_H) +if(HAVE_PTHREAD_H) try_compile(HAVE_PTHREAD_MUTEX_RECURSIVE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/CMake/pthread_mutex_recursive.c ) -else () - set (HAVE_PTHREAD_MUTEX_RECURSIVE 0) -endif () +else() + set(HAVE_PTHREAD_MUTEX_RECURSIVE 0) +endif() # Special case for Microsoft Visual Studio generator (MSVC): # @@ -94,19 +97,19 @@ endif () # # Note: these cache variables can only be seen in "advanced" mode. -if (MSVC) +if(MSVC) - if (NOT HAVE_GL_GLU_H) - message (STATUS "Info: Header file GL/glu.h was not found. Continuing...") - set (HAVE_GL_GLU_H 1) - endif (NOT HAVE_GL_GLU_H) + if(NOT HAVE_GL_GLU_H) + message(STATUS "Info: Header file GL/glu.h was not found. Continuing...") + set(HAVE_GL_GLU_H 1) + endif(NOT HAVE_GL_GLU_H) - if (NOT HAVE_LOCALE_H) - message (STATUS "Info: Header file locale.h was not found. Continuing...") - set (HAVE_LOCALE_H 1) - endif (NOT HAVE_LOCALE_H) + if(NOT HAVE_LOCALE_H) + message(STATUS "Info: Header file locale.h was not found. Continuing...") + set(HAVE_LOCALE_H 1) + endif(NOT HAVE_LOCALE_H) -endif (MSVC) +endif(MSVC) # 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 @@ -118,15 +121,15 @@ endif (MSVC) 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) - if (NOT HAVE_SYS_NDIR_H) + if(NOT HAVE_SYS_NDIR_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) - endif (NOT HAVE_SYS_DIR_H) - endif (NOT HAVE_SYS_NDIR_H) -endif (NOT HAVE_DIRENT_H) + endif(NOT HAVE_SYS_DIR_H) + endif(NOT HAVE_SYS_NDIR_H) +endif(NOT HAVE_DIRENT_H) mark_as_advanced (HAVE_ALSA_ASOUNDLIB_H HAVE_DIRENT_H HAVE_DLFCN_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/freetype.h PATH_SUFFIXES freetype2) -if (FREETYPE_PATH) - include_directories (${FREETYPE_PATH}) -endif (FREETYPE_PATH) +if(FREETYPE_PATH) + list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${FREETYPE_PATH}) +endif(FREETYPE_PATH) mark_as_advanced (FREETYPE_PATH) ####################################################################### # libraries find_library (LIB_dl dl) -if ((NOT APPLE) OR OPTION_APPLE_X11) +if((NOT APPLE) OR FLTK_BACKEND_X11) 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_GL GL) find_library (LIB_MesaGL MesaGL) @@ -173,40 +176,40 @@ mark_as_advanced (LIB_jpeg LIB_png LIB_zlib) ####################################################################### # functions -include (CheckFunctionExists) +include(CheckFunctionExists) # save CMAKE_REQUIRED_LIBRARIES (is this really necessary ?) -if (DEFINED CMAKE_REQUIRED_LIBRARIES) - set (SAVED_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) -else (DEFINED CMAKE_REQUIRED_LIBRARIES) - unset (SAVED_REQUIRED_LIBRARIES) -endif (DEFINED CMAKE_REQUIRED_LIBRARIES) -set (CMAKE_REQUIRED_LIBRARIES) +if(DEFINED CMAKE_REQUIRED_LIBRARIES) + set(SAVED_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) +else(DEFINED CMAKE_REQUIRED_LIBRARIES) + unset(SAVED_REQUIRED_LIBRARIES) +endif(DEFINED CMAKE_REQUIRED_LIBRARIES) +set(CMAKE_REQUIRED_LIBRARIES) -if (HAVE_DLFCN_H) - set (HAVE_DLFCN_H 1) -endif (HAVE_DLFCN_H) +if(HAVE_DLFCN_H) + set(HAVE_DLFCN_H 1) +endif(HAVE_DLFCN_H) -set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS}) +set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS}) CHECK_FUNCTION_EXISTS (dlsym HAVE_DLSYM) -set (CMAKE_REQUIRED_LIBRARIES) +set(CMAKE_REQUIRED_LIBRARIES) CHECK_FUNCTION_EXISTS (localeconv HAVE_LOCALECONV) -if (LIB_png) - set (CMAKE_REQUIRED_LIBRARIES ${LIB_png}) +if(LIB_png) + set(CMAKE_REQUIRED_LIBRARIES ${LIB_png}) CHECK_FUNCTION_EXISTS (png_get_valid HAVE_PNG_GET_VALID) CHECK_FUNCTION_EXISTS (png_set_tRNS_to_alpha HAVE_PNG_SET_TRNS_TO_ALPHA) - set (CMAKE_REQUIRED_LIBRARIES) -endif (LIB_png) + set(CMAKE_REQUIRED_LIBRARIES) +endif(LIB_png) CHECK_FUNCTION_EXISTS (scandir HAVE_SCANDIR) CHECK_FUNCTION_EXISTS (snprintf HAVE_SNPRINTF) # not really true but we convert strcasecmp calls to _stricmp calls in flstring.h -if (MSVC) - set (HAVE_STRCASECMP 1) -endif (MSVC) +if(MSVC) + set(HAVE_STRCASECMP 1) +endif(MSVC) 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 (vsnprintf HAVE_VSNPRINTF) -if (HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX) - set (MSG "POSIX compatible scandir") - message (STATUS "Looking for ${MSG}") +if(HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX) + set(MSG "POSIX compatible scandir") + message(STATUS "Looking for ${MSG}") try_compile(V ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/CMake/posixScandir.cxx ) - if (V) - message (STATUS "${MSG} - found") - set (HAVE_SCANDIR_POSIX 1 CACHE INTERNAL "") + if(V) + message(STATUS "${MSG} - found") + set(HAVE_SCANDIR_POSIX 1 CACHE INTERNAL "") else() - message (STATUS "${MSG} - not found") - set (HAVE_SCANDIR_POSIX HAVE_SCANDIR_POSIX-NOTFOUND) - endif (V) -endif (HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX) + message(STATUS "${MSG} - not found") + set(HAVE_SCANDIR_POSIX HAVE_SCANDIR_POSIX-NOTFOUND) + endif(V) +endif(HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX) mark_as_advanced (HAVE_SCANDIR_POSIX) # restore CMAKE_REQUIRED_LIBRARIES (is this really necessary ?) -if (DEFINED SAVED_REQUIRED_LIBRARIES) - set (CMAKE_REQUIRED_LIBRARIES ${SAVED_REQUIRED_LIBRARIES}) - unset (SAVED_REQUIRED_LIBRARIES) +if(DEFINED SAVED_REQUIRED_LIBRARIES) + set(CMAKE_REQUIRED_LIBRARIES ${SAVED_REQUIRED_LIBRARIES}) + unset(SAVED_REQUIRED_LIBRARIES) else(DEFINED SAVED_REQUIRED_LIBRARIES) - unset (CMAKE_REQUIRED_LIBRARIES) -endif (DEFINED SAVED_REQUIRED_LIBRARIES) + unset(CMAKE_REQUIRED_LIBRARIES) +endif(DEFINED SAVED_REQUIRED_LIBRARIES) ####################################################################### # packages @@ -250,18 +253,18 @@ find_package (Doxygen) # Note: we only check existence of `latex' (LATEX_COMPILER), hence # building the pdf docs may still fail because of other missing tools. -set (LATEX_FOUND) -if (DOXYGEN_FOUND) +set(LATEX_FOUND) +if(DOXYGEN_FOUND) find_package (LATEX) - if (LATEX_COMPILER AND NOT LATEX_FOUND) - set (LATEX_FOUND YES) - endif (LATEX_COMPILER AND NOT LATEX_FOUND) -endif (DOXYGEN_FOUND) + if(LATEX_COMPILER AND NOT LATEX_FOUND) + set(LATEX_FOUND YES) + endif(LATEX_COMPILER AND NOT LATEX_FOUND) +endif(DOXYGEN_FOUND) -# message ("Doxygen found : ${DOXYGEN_FOUND}") -# message ("LaTex found : ${LATEX_FOUND}") -# message ("LaTex Compiler : ${LATEX_COMPILER}") +# message("Doxygen found : ${DOXYGEN_FOUND}") +# message("LaTex found : ${LATEX_FOUND}") +# message("LaTex Compiler : ${LATEX_COMPILER}") # Cleanup: unset local variables -unset (CMAKE_REQUIRED_QUIET) +unset(CMAKE_REQUIRED_QUIET) diff --git a/CMake/setup.cmake b/CMake/setup.cmake index 7dd91ebd4..b663813be 100644 --- a/CMake/setup.cmake +++ b/CMake/setup.cmake @@ -2,7 +2,7 @@ # CMakeLists.txt to build the FLTK project using CMake (www.cmake.org) # 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 # the file "COPYING" which should have been included with this file. If this @@ -19,107 +19,132 @@ # basic setup ####################################################################### -set (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin) -set (LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib) -set (ARCHIVE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib) +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin) +set(LIBRARY_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 -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}) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake") # Setup install locations (requires CMake 2.8.4) 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.") -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.") -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.") -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.") -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.") -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.") ####################################################################### -# initialize internally used variables -# some of these variables are used to *append* other values later +# Initialize variables needed to collect include directories etc.. +# 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 "") +set(FLTK_BUILD_INCLUDE_DIRECTORIES "") +set(FLTK_IMAGE_INCLUDE_DIRECTORIES "") +set(FLTK_IMAGE_LIBRARIES "") +set(FLTK_IMAGE_LIBRARIES_SHARED "") + +set(FLTK_CFLAGS "") +set(FLTK_LIBRARIES "") +set(FLTK_LIBRARIES_SHARED "") + +# Remember root of FLTK source directory in case we're later in a subdirectory. +# Used for instance to find the source directory for doxygen docs + +set(FLTK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + +if(FLTK_SOURCE_DIR STREQUAL ${CMAKE_SOURCE_DIR}) + set(FLTK_IS_TOPLEVEL TRUE) +else() + set(FLTK_IS_TOPLEVEL FALSE) +endif() + +# Note: FLTK_INCLUDE_DIRS is used to export the required include directories +# in FLTKConfig.cmake etc. +# ### FIXME ### check if we really need this ... + +set(FLTK_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) + +# FLTK_BUILD_INCLUDE_DIRECTORIES is used to build the main FLTK lib + +set(FLTK_BUILD_INCLUDE_DIRECTORIES) + +# Some of these variables are used to *append* other values later + +set(FLTK_LDLIBS "") +set(FLTK_LIBRARIES "") +set(GLLIBS "") +set(IMAGELIBS "") +set(LDFLAGS "") +set(LIBS "") +set(LINK_LIBS "") +set(STATICIMAGELIBS "") ####################################################################### # platform dependent information ####################################################################### # set where config files go -if (WIN32 AND NOT CYGWIN) - set (FLTK_CONFIG_PATH CMake) -elseif (APPLE AND NOT OPTION_APPLE_X11) - set (FLTK_CONFIG_PATH FLTK.framework/Resources/CMake) -else () - set (FLTK_CONFIG_PATH ${FLTK_DATADIR}/fltk) -endif (WIN32 AND NOT CYGWIN) +if(WIN32 AND NOT CYGWIN) + set(FLTK_CONFIG_PATH CMake) +elseif(APPLE AND NOT FLTK_BACKEND_X11) + set(FLTK_CONFIG_PATH FLTK.framework/Resources/CMake) +else() + set(FLTK_CONFIG_PATH ${FLTK_DATADIR}/fltk) +endif(WIN32 AND NOT CYGWIN) include(TestBigEndian) TEST_BIG_ENDIAN(WORDS_BIGENDIAN) -if (CMAKE_GENERATOR MATCHES "Xcode") +if(CMAKE_GENERATOR MATCHES "Xcode") # Tell Xcode to regenerate scheme information automatically whenever the # CMake configuration changes without asking the user - set (CMAKE_XCODE_GENERATE_SCHEME 1) + set(CMAKE_XCODE_GENERATE_SCHEME 1) endif() -if (APPLE) - set (HAVE_STRCASECMP 1) - set (HAVE_DIRENT_H 1) - set (HAVE_SNPRINTF 1) - set (HAVE_VSNPRINTF 1) - set (HAVE_SCANDIR 1) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") - if (OPTION_APPLE_X11) - 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") - endif (NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0)) - else () - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa") - set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework Cocoa") - endif (OPTION_APPLE_X11) -endif (APPLE) +if(APPLE) + set(HAVE_STRCASECMP 1) + set(HAVE_DIRENT_H 1) + set(HAVE_SNPRINTF 1) + set(HAVE_VSNPRINTF 1) + set(HAVE_SCANDIR 1) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") + if(FLTK_BACKEND_X11) + 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") + endif(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0)) + else() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework Cocoa") + endif(FLTK_BACKEND_X11) +endif(APPLE) -if (WIN32) +if(WIN32) # 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) # add_definitions (-D_WIN32) - if (MSVC) + if(MSVC) add_definitions (-DWIN32_LEAN_AND_MEAN) add_definitions (-D_CRT_SECURE_NO_WARNINGS) - 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` - endif () - set (BORDER_WIDTH 2) - endif (MSVC) - if (MINGW AND EXISTS /mingw) + 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` + endif() + set(BORDER_WIDTH 2) + endif(MSVC) + if(MINGW AND EXISTS /mingw) list(APPEND CMAKE_PREFIX_PATH /mingw) - endif (MINGW AND EXISTS /mingw) -endif (WIN32) + endif(MINGW AND EXISTS /mingw) +endif(WIN32) ####################################################################### # size of ints @@ -130,22 +155,22 @@ CHECK_TYPE_SIZE(int SIZEOF_INT) CHECK_TYPE_SIZE(long SIZEOF_LONG) CHECK_TYPE_SIZE("long long" HAVE_LONG_LONG) -if (${SIZEOF_SHORT} MATCHES "^2$") - set (U16 "unsigned short") -endif (${SIZEOF_SHORT} MATCHES "^2$") +if(${SIZEOF_SHORT} MATCHES "^2$") + set(U16 "unsigned short") +endif(${SIZEOF_SHORT} MATCHES "^2$") -if (${SIZEOF_INT} MATCHES "^4$") - set (U32 "unsigned") -else () - if (${SIZEOF_LONG} MATCHES "^4$") - set (U32 "unsigned long") - endif (${SIZEOF_LONG} MATCHES "^4$") -endif (${SIZEOF_INT} MATCHES "^4$") +if(${SIZEOF_INT} MATCHES "^4$") + set(U32 "unsigned") +else() + if(${SIZEOF_LONG} MATCHES "^4$") + set(U32 "unsigned long") + endif(${SIZEOF_LONG} MATCHES "^4$") +endif(${SIZEOF_INT} MATCHES "^4$") -if (${SIZEOF_INT} MATCHES "^8$") - set (U64 "unsigned") -else () - if (${SIZEOF_LONG} MATCHES "^8$") - set (U64 "unsigned long") - endif (${SIZEOF_LONG} MATCHES "^8$") -endif (${SIZEOF_INT} MATCHES "^8$") +if(${SIZEOF_INT} MATCHES "^8$") + set(U64 "unsigned") +else() + if(${SIZEOF_LONG} MATCHES "^8$") + set(U64 "unsigned long") + endif(${SIZEOF_LONG} MATCHES "^8$") +endif(${SIZEOF_INT} MATCHES "^8$") diff --git a/CMake/variables.cmake b/CMake/variables.cmake index 25bbefaeb..3d37aecad 100644 --- a/CMake/variables.cmake +++ b/CMake/variables.cmake @@ -1,8 +1,8 @@ # # 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 # the file "COPYING" which should have been included with this file. If this @@ -17,51 +17,52 @@ ####################################################################### -set (DEBUG_VARIABLES_CMAKE 0) -if (DEBUG_VARIABLES_CMAKE) - message (STATUS "[** variables.cmake **]") - fl_debug_var (HAVE_DLSYM) - fl_debug_var (CMAKE_DL_LIBS) - fl_debug_var (CMAKE_EXE_LINKER_FLAGS) - fl_debug_var (LDFLAGS) - fl_debug_var (LIBS) - fl_debug_var (GLLIBS) - fl_debug_var (IMAGELIBS) - fl_debug_var (STATICIMAGELIBS) - fl_debug_var (FLTK_LDLIBS) - fl_debug_var (LIB_jpeg) - fl_debug_var (LIB_png) - fl_debug_var (LIB_zlib) -endif (DEBUG_VARIABLES_CMAKE) +set(DEBUG_VARIABLES_CMAKE 0) +if(DEBUG_VARIABLES_CMAKE) + message(STATUS "[** variables.cmake **]") + fl_debug_var(HAVE_DLSYM) + fl_debug_var(CMAKE_DL_LIBS) + fl_debug_var(CMAKE_EXE_LINKER_FLAGS) + fl_debug_var(LDFLAGS) + fl_debug_var(LIBS) + fl_debug_var(GLLIBS) + fl_debug_var(IMAGELIBS) + fl_debug_var(STATICIMAGELIBS) + fl_debug_var(FLTK_LDLIBS) + fl_debug_var(LIB_jpeg) + fl_debug_var(LIB_png) + fl_debug_var(LIB_zlib) + fl_debug_var(FLTK_LIBRARIES) +endif(DEBUG_VARIABLES_CMAKE) ####################################################################### # add several libraries # FIXME: libraries may need reordering. # FIXME: check fontconfig conditions (only if Xft is used or ...) -if (WIN32) - list (APPEND FLTK_LDLIBS -lole32 -luuid -lcomctl32 -lws2_32) -elseif (APPLE AND NOT OPTION_APPLE_X11) - list (APPEND FLTK_LDLIBS "-framework Cocoa") -elseif (OPTION_USE_WAYLAND) - list (APPEND FLTK_LDLIBS "-lwayland-cursor -lwayland-client -lxkbcommon -ldbus-1") - if (OPTION_USE_SYSTEM_LIBDECOR) - list (APPEND FLTK_LDLIBS "-ldecor-0") - endif (OPTION_USE_SYSTEM_LIBDECOR) -else () - list (APPEND FLTK_LDLIBS -lm) -endif (WIN32) +if(WIN32) + list(APPEND FLTK_LDLIBS -lole32 -luuid -lcomctl32 -lws2_32) +elseif(APPLE AND NOT FLTK_BACKEND_X11) + list(APPEND FLTK_LDLIBS "-framework Cocoa") +elseif(FLTK_BACKEND_WAYLAND) + list(APPEND FLTK_LDLIBS "-lwayland-cursor -lwayland-client -lxkbcommon -ldbus-1") + if(USE_SYSTEM_LIBDECOR) + list(APPEND FLTK_LDLIBS "-ldecor-0") + endif(USE_SYSTEM_LIBDECOR) +else() + list(APPEND FLTK_LDLIBS -lm) +endif(WIN32) -if (LIB_fontconfig) +if(LIB_fontconfig) list(APPEND FLTK_LDLIBS -lfontconfig) -endif (LIB_fontconfig) +endif(LIB_fontconfig) # add "-ldl" or whatever is necessary according to CMake (CMAKE_DL_LIBS) -if (HAVE_DLSYM) - foreach (LIB ${CMAKE_DL_LIBS}) - list (APPEND FLTK_LDLIBS "-l${LIB}") - endforeach () -endif (HAVE_DLSYM) +if(HAVE_DLSYM) + foreach(LIB ${CMAKE_DL_LIBS}) + list(APPEND FLTK_LDLIBS "-l${LIB}") + endforeach() +endif(HAVE_DLSYM) ####################################################################### # 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 # be set in install.cmake or export.cmake, respectively. -if (WIN32) - set (LDFLAGS "${CMAKE_EXE_LINKER_FLAGS} -mwindows") -endif () +if(WIN32) + set(LDFLAGS "${CMAKE_EXE_LINKER_FLAGS} -mwindows") +endif() -set (IMAGELIBS) -set (STATICIMAGELIBS) +set(IMAGELIBS) +set(STATICIMAGELIBS) -if (FLTK_USE_BUILTIN_JPEG) - list (APPEND IMAGELIBS -lfltk_jpeg) - list (APPEND STATICIMAGELIBS \$libdir/libfltk_jpeg.a) -else () - if (LIB_jpeg) - list (APPEND IMAGELIBS -ljpeg) - list (APPEND STATICIMAGELIBS -ljpeg) - endif (LIB_jpeg) -endif (FLTK_USE_BUILTIN_JPEG) +if(FLTK_USE_BUNDLED_JPEG) + list(APPEND IMAGELIBS -lfltk_jpeg) + list(APPEND STATICIMAGELIBS \$libdir/libfltk_jpeg.a) +else() + if(LIB_jpeg) + # fl_debug_var(LIB_jpeg) + list(APPEND IMAGELIBS ${LIB_jpeg}) + list(APPEND STATICIMAGELIBS ${LIB_jpeg}) + endif(LIB_jpeg) +endif(FLTK_USE_BUNDLED_JPEG) -if (FLTK_USE_BUILTIN_PNG) - list (APPEND IMAGELIBS -lfltk_png) - list (APPEND STATICIMAGELIBS \$libdir/libfltk_png.a) -else () - if (LIB_png) - list (APPEND IMAGELIBS -lpng) - list (APPEND STATICIMAGELIBS -lpng) - endif (LIB_png) -endif (FLTK_USE_BUILTIN_PNG) +if(FLTK_USE_BUNDLED_PNG) + list(APPEND IMAGELIBS -lfltk_png) + list(APPEND STATICIMAGELIBS \$libdir/libfltk_png.a) +else() + if(LIB_png) + # fl_debug_var(LIB_png) + list(APPEND IMAGELIBS ${LIB_png}) + list(APPEND STATICIMAGELIBS ${LIB_png}) + endif(LIB_png) +endif(FLTK_USE_BUNDLED_PNG) -if (FLTK_USE_BUILTIN_ZLIB) - list (APPEND IMAGELIBS -lfltk_z) - list (APPEND STATICIMAGELIBS \$libdir/libfltk_z.a) -else () - if (LIB_zlib) - list (APPEND IMAGELIBS -lz) - list (APPEND STATICIMAGELIBS -lz) - endif (LIB_zlib) -endif (FLTK_USE_BUILTIN_ZLIB) +if(FLTK_USE_BUNDLED_ZLIB) + list(APPEND IMAGELIBS -lfltk_z) + list(APPEND STATICIMAGELIBS \$libdir/libfltk_z.a) +else() + if(LIB_zlib) + list(APPEND IMAGELIBS ${LIB_zlib}) + list(APPEND STATICIMAGELIBS ${LIB_zlib}) + endif(LIB_zlib) +endif(FLTK_USE_BUNDLED_ZLIB) -string (REPLACE ";" " " IMAGELIBS "${IMAGELIBS}") -string (REPLACE ";" " " STATICIMAGELIBS "${STATICIMAGELIBS}") +string(REPLACE ";" " " IMAGELIBS "${IMAGELIBS}") +string(REPLACE ";" " " STATICIMAGELIBS "${STATICIMAGELIBS}") ####################################################################### -set (CC ${CMAKE_C_COMPILER}) -set (CXX ${CMAKE_CXX_COMPILER}) +set(CC ${CMAKE_C_COMPILER}) +set(CXX ${CMAKE_CXX_COMPILER}) -set (ARCHFLAGS ${OPTION_ARCHFLAGS}) +set(ARCHFLAGS ${FLTK_ARCHFLAGS}) string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_UPPER) -if (${BUILD_UPPER}) - set (CFLAGS "${CMAKE_C_FLAGS_${BUILD_UPPER}} ${CFLAGS}") -endif (${BUILD_UPPER}) +if(${BUILD_UPPER}) + set(CFLAGS "${CMAKE_C_FLAGS_${BUILD_UPPER}} ${CFLAGS}") +endif(${BUILD_UPPER}) -set (CFLAGS "${OPTION_OPTIM} ${CMAKE_C_FLAGS} ${CFLAGS}") -foreach (arg ${FLTK_CFLAGS}) - set (CFLAGS "${CFLAGS} ${arg}") -endforeach (arg ${FLTK_CFLAGS}) +set(CFLAGS "${FLTK_OPTION_OPTIM} ${CMAKE_C_FLAGS} ${CFLAGS}") +foreach(arg ${FLTK_CFLAGS}) + set(CFLAGS "${CFLAGS} ${arg}") +endforeach(arg ${FLTK_CFLAGS}) -set (CXXFLAGS "${CFLAGS}") +set(CXXFLAGS "${CFLAGS}") -foreach (arg ${FLTK_LDLIBS}) - set (LINK_LIBS "${LINK_LIBS} ${arg}") -endforeach (arg ${FLTK_LDLIBS}) +foreach(arg ${FLTK_LDLIBS}) + set(LINK_LIBS "${LINK_LIBS} ${arg}") +endforeach(arg ${FLTK_LDLIBS}) -set (LIBS "${LINK_LIBS}") +set(LIBS "${LINK_LIBS}") -if (${CMAKE_SYSTEM_NAME} STREQUAL "AIX") - set (SHAREDSUFFIX "_s") -else () - set (SHAREDSUFFIX "") -endif (${CMAKE_SYSTEM_NAME} STREQUAL "AIX") +if(${CMAKE_SYSTEM_NAME} STREQUAL "AIX") + set(SHAREDSUFFIX "_s") +else() + set(SHAREDSUFFIX "") +endif(${CMAKE_SYSTEM_NAME} STREQUAL "AIX") -if (DEBUG_VARIABLES_CMAKE) - message (STATUS "") # empty line - fl_debug_var (HAVE_DLSYM) - fl_debug_var (CMAKE_DL_LIBS) - fl_debug_var (CMAKE_EXE_LINKER_FLAGS) - fl_debug_var (LDFLAGS) - fl_debug_var (LIBS) - fl_debug_var (GLLIBS) - fl_debug_var (IMAGELIBS) - fl_debug_var (STATICIMAGELIBS) - fl_debug_var (FLTK_LDLIBS) - fl_debug_var (LIB_jpeg) - fl_debug_var (LIB_png) - fl_debug_var (LIB_zlib) - message (STATUS "[** end of variables.cmake **]") -endif (DEBUG_VARIABLES_CMAKE) -unset (DEBUG_VARIABLES_CMAKE) +if(DEBUG_VARIABLES_CMAKE) + message(STATUS "") # empty line + fl_debug_var(HAVE_DLSYM) + fl_debug_var(CMAKE_DL_LIBS) + fl_debug_var(CMAKE_EXE_LINKER_FLAGS) + fl_debug_var(LDFLAGS) + fl_debug_var(LIBS) + fl_debug_var(GLLIBS) + fl_debug_var(IMAGELIBS) + fl_debug_var(STATICIMAGELIBS) + fl_debug_var(FLTK_LDLIBS) + fl_debug_var(LIB_jpeg) + fl_debug_var(LIB_png) + fl_debug_var(LIB_zlib) + fl_debug_var(FLTK_LIBRARIES) + message(STATUS "[** end of variables.cmake **]") +endif(DEBUG_VARIABLES_CMAKE) +unset(DEBUG_VARIABLES_CMAKE) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cc4813c2..ac5adb44e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # Main CMakeLists.txt to build the FLTK project using CMake (www.cmake.org) # 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 # 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 @@ -27,73 +27,76 @@ # used for Windows (MSVC) shared lib builds much earlier # 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 ####################################################################### -project (FLTK VERSION 1.4.0) +project(FLTK VERSION 1.4.0) ####################################################################### # include macro and function definitions for general usage ####################################################################### -include (CMake/fl_debug_var.cmake) -include (CMake/fl_debug_pkg.cmake) -include (CMake/fl_add_library.cmake) +include(CMake/fl_debug_var.cmake) +include(CMake/fl_debug_pkg.cmake) +include(CMake/fl_add_library.cmake) # right now we don't use compatibility functions -# include (CMake/compatibility.cmake) +# include(CMake/compatibility.cmake) -if (0) - fl_debug_var (FLTK_VERSION_MAJOR) - fl_debug_var (FLTK_VERSION_MINOR) - fl_debug_var (FLTK_VERSION_PATCH) - fl_debug_var (FLTK_VERSION) - fl_debug_var (CMAKE_VERSION) -endif () +if(0) + fl_debug_var(FLTK_VERSION_MAJOR) + fl_debug_var(FLTK_VERSION_MINOR) + fl_debug_var(FLTK_VERSION_PATCH) + fl_debug_var(FLTK_VERSION) + fl_debug_var(CMAKE_VERSION) +endif() ####################################################################### # basic setup ####################################################################### -include (CMake/setup.cmake) +include(CMake/setup.cmake) ####################################################################### # check for headers, libraries and functions ####################################################################### -include (CMake/resources.cmake) +include(CMake/resources.cmake) ####################################################################### # options ####################################################################### -include (CMake/options.cmake) +include(CMake/options.cmake) ####################################################################### # 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) - message ("") - 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 (MINGW) - fl_debug_var (CYGWIN) - fl_debug_var (MSVC) - fl_debug_var (UNIX) - fl_debug_var (APPLE) - fl_debug_var (CMAKE_BUILD_TYPE) - fl_debug_var (CMAKE_SIZEOF_VOID_P) - fl_debug_var (OPTION_OPTIM) - fl_debug_var (CMAKE_C_FLAGS) - fl_debug_var (CMAKE_CXX_FLAGS) - fl_debug_var (CMAKE_EXE_LINKER_FLAGS) - message (STATUS "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt: end of debug_build info.") -endif (debug_build) +if(debug_build) + message("") + 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(MINGW) + fl_debug_var(CYGWIN) + fl_debug_var(MSVC) + fl_debug_var(UNIX) + fl_debug_var(APPLE) + fl_debug_var(CMAKE_BUILD_TYPE) + fl_debug_var(CMAKE_SIZEOF_VOID_P) + fl_debug_var(FLTK_OPTION_OPTIM) + fl_debug_var(CMAKE_C_FLAGS) + fl_debug_var(CMAKE_CXX_FLAGS) + fl_debug_var(CMAKE_EXE_LINKER_FLAGS) + message(STATUS "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt: end of debug_build info.") +endif(debug_build) -unset (debug_build) +unset(debug_build) ####################################################################### # 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. ####################################################################### -if (FLTK_HAVE_CAIRO) - add_subdirectory (cairo) -endif () +if(FLTK_HAVE_CAIRO) + add_subdirectory(cairo) +endif() ####################################################################### # build the standard FLTK libraries @@ -115,17 +118,17 @@ add_subdirectory(src) # build fluid ####################################################################### -if (FLTK_BUILD_FLUID) - add_subdirectory (fluid) -endif (FLTK_BUILD_FLUID) +if(FLTK_BUILD_FLUID) + add_subdirectory(fluid) +endif(FLTK_BUILD_FLUID) ####################################################################### # build fltk-options ####################################################################### -if (FLTK_BUILD_FLTK_OPTIONS) - add_subdirectory (fltk-options) -endif (FLTK_BUILD_FLTK_OPTIONS) +if(FLTK_BUILD_FLTK_OPTIONS) + add_subdirectory(fltk-options) +endif(FLTK_BUILD_FLTK_OPTIONS) ####################################################################### # 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 ####################################################################### -include (CMake/variables.cmake) +include(CMake/variables.cmake) ####################################################################### # 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_BINARY_DIR}/FL/fl_config.h @ONLY @@ -152,184 +155,207 @@ configure_file ( # options to build test/demo and example programs ####################################################################### -if (FLTK_BUILD_TEST) - add_subdirectory (test) -endif (FLTK_BUILD_TEST) +if(FLTK_BUILD_TEST) + add_subdirectory(test) +endif(FLTK_BUILD_TEST) -if (FLTK_BUILD_EXAMPLES) - add_subdirectory (examples) -endif (FLTK_BUILD_EXAMPLES) +if(FLTK_BUILD_EXAMPLES) + add_subdirectory(examples) +endif(FLTK_BUILD_EXAMPLES) ####################################################################### # installation ####################################################################### -include (CMake/install.cmake) +include(CMake/install.cmake) ####################################################################### # Generate Library Export Headers *** EXPERIMENTAL *** 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 EXPORT_FILE_NAME FL/fltk_export.h STATIC_DEFINE FL_STATIC_LIB ) - if (NOT MSVC) + if(NOT MSVC) # Visual Studio builds only one shared lib (DLL) - generate_export_header (fltk_images_SHARED + generate_export_header(fltk_images_SHARED BASE_NAME fl_images EXPORT_FILE_NAME FL/fltk_images_export.h STATIC_DEFINE FL_STATIC_LIB ) - generate_export_header (fltk_forms_SHARED + generate_export_header(fltk_forms_SHARED BASE_NAME fl_forms EXPORT_FILE_NAME FL/fltk_forms_export.h STATIC_DEFINE FL_STATIC_LIB ) - generate_export_header (fltk_gl_SHARED + generate_export_header(fltk_gl_SHARED BASE_NAME fl_gl EXPORT_FILE_NAME FL/fltk_gl_export.h 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 ####################################################################### -include (FeatureSummary) +include(FeatureSummary) -message ("") -set (_descr "${PROJECT_NAME} ${FLTK_VERSION} generated by CMake ${CMAKE_VERSION}") -feature_summary (WHAT ALL DESCRIPTION "Configuration Summary for ${_descr} --\n") +message("") +set(_descr "${PROJECT_NAME} ${FLTK_VERSION} generated by CMake ${CMAKE_VERSION}") +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) - message (STATUS "Shared libraries will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib") -else () - message (STATUS "Shared libraries will not be built (set OPTION_BUILD_SHARED_LIBS=ON to build)") -endif () +if(FLTK_BUILD_SHARED_LIBS) + message(STATUS "Shared libraries will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib") +else() + message(STATUS "Shared libraries will not be built (set FLTK_BUILD_SHARED_LIBS=ON to build)") +endif() -if (FLTK_BUILD_FORMS) - message (STATUS "The forms library will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib") -else () - message (STATUS "The forms library will not be built (set FLTK_BUILD_FORMS=ON to build)") -endif () +if(FLTK_BUILD_FORMS) + message(STATUS "The forms library will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib") +else() + message(STATUS "The forms library will not be built (set FLTK_BUILD_FORMS=ON to build)") +endif() -if (FLTK_BUILD_FLUID) - message (STATUS "FLUID will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fluid") -else () - message (STATUS "FLUID will not be built (set FLTK_BUILD_FLUID=ON to build)") -endif () +if(FLTK_USE_GL) + message(STATUS "The OpenGL library will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib") +else() + message(STATUS "The OpenGL library will not be built (set FLTK_BUILD_GL=ON to build)") +endif() -if (FLTK_BUILD_FLTK_OPTIONS) - message (STATUS "fltk-options will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fltk-options") -else () - message (STATUS "fltk-options will not be built (set FLTK_BUILD_FLTK_OPTIONS=ON to build)") -endif () +if(FLTK_BUILD_FLUID) + message(STATUS "fluid will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fluid") +else() + message(STATUS "fluid will not be built (set FLTK_BUILD_FLUID=ON to build)") +endif() -if (FLTK_BUILD_TEST) - message (STATUS "Test programs will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/test") -else () - message (STATUS "Test programs will not be built (set FLTK_BUILD_TEST=ON to build)") -endif () +if(FLTK_BUILD_FLTK_OPTIONS) + message(STATUS "fltk-options will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fltk-options") +else() + message(STATUS "fltk-options will not be built (set FLTK_BUILD_FLTK_OPTIONS=ON to build)") +endif() -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(FLTK_BUILD_TEST) + message(STATUS "Test programs will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/test") +else() + message(STATUS "Test programs will not be built (set FLTK_BUILD_TEST=ON to build)") +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 "Build configuration : ") -else () - message (STATUS "Build configuration : ${CMAKE_BUILD_TYPE}") -endif () +message(STATUS "") -message (STATUS "") +if(CMAKE_BUILD_TYPE STREQUAL "") + message(STATUS "Build configuration : ") +else() + message(STATUS "Build configuration : ${CMAKE_BUILD_TYPE}") +endif() -if (FLTK_USE_BUILTIN_JPEG) - message (STATUS "Image Libraries : JPEG = Builtin") -else () - message (STATUS "Image Libraries : JPEG = System") -endif () +message(STATUS "") -if (FLTK_USE_BUILTIN_PNG) - message (STATUS " : PNG = Builtin") -else () - message (STATUS " : PNG = System") -endif () +if(FLTK_USE_BUNDLED_JPEG) + message(STATUS "Image Libraries : JPEG = Builtin") +else() + message(STATUS "Image Libraries : JPEG = System") +endif() -if (FLTK_USE_BUILTIN_ZLIB) - message (STATUS " : ZLIB = Builtin") -else () - message (STATUS " : ZLIB = System") -endif () +if(FLTK_USE_BUNDLED_PNG) + message(STATUS " : PNG = Builtin") +else() + message(STATUS " : PNG = System") +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) - 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(UNIX AND NOT (APPLE AND NOT FLTK_BACKEND_X11)) - if (FLTK_USE_CAIRO) - message (STATUS "All drawing uses Cairo : Yes") - else () - message (STATUS "All drawing uses Cairo : No") - endif () + if(FLTK_BACKEND_WAYLAND) + message(STATUS "Use Wayland : Yes (if available at run-time)") + if(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 (USE_PANGO) - message (STATUS "Use Pango : Yes") - else (USE_PANGO) - message (STATUS "Use Pango : No") - if (USE_XFT) - message (STATUS "Use Xft : Yes") - else () - message (STATUS "Use Xft : No") - endif (USE_XFT) - endif (USE_PANGO) + if(FLTK_USE_CAIRO) + message(STATUS "All drawing uses Cairo : Yes") + else() + message(STATUS "All drawing uses Cairo : No") + endif() -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) - 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 () +endif() -if (FLTK_USE_STD) - message (STATUS "Use std:: : Yes") -else () - message (STATUS "Use std:: : No") -endif () +if(FLTK_HAVE_CAIROEXT) + 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() -message ("") -message (STATUS "End of Configuration Summary --\n") +if(FLTK_USE_STD) + 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() diff --git a/FL/Fl.H b/FL/Fl.H index 3757b65be..95d08c9db 100644 --- a/FL/Fl.H +++ b/FL/Fl.H @@ -1473,8 +1473,8 @@ public: \endcode If you configure FLTK with \c '--enable-cairo' or CMake option - \c 'OPTION_CAIRO' (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_WINDOW' (i.e. without \c '--enable-cairoext' or CMake option + \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 overridden draw() method of derived classes by using \code diff --git a/FL/Fl_Cairo.H b/FL/Fl_Cairo.H index 03c3c1cfe..cf43de421 100644 --- a/FL/Fl_Cairo.H +++ b/FL/Fl_Cairo.H @@ -51,7 +51,7 @@ For internal use only. \note Only available when configure has the --enable-cairo or --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 { public: diff --git a/FL/Fl_Cairo_Window.H b/FL/Fl_Cairo_Window.H index 567fc228c..ebffb51ce 100644 --- a/FL/Fl_Cairo_Window.H +++ b/FL/Fl_Cairo_Window.H @@ -78,7 +78,7 @@ \see test/cairo_test.cxx \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, and thus at least override the draw() method to provide custom Cairo diff --git a/FL/Fl_Native_File_Chooser.H b/FL/Fl_Native_File_Chooser.H index 721d0c1f4..92e21a98e 100644 --- a/FL/Fl_Native_File_Chooser.H +++ b/FL/Fl_Native_File_Chooser.H @@ -1,8 +1,8 @@ // // FLTK native OS file chooser widget // -// Copyright 1998-2016 by Bill Spitzak and others. // Copyright 2004 Greg Ercolano. +// Copyright 2005-2024 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -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 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 - and if the library was not built with cmake -DOPTION_USE_KDIALOG=Off, the + and if the library was not built with cmake -D FLTK_USE_KDIALOG=OFF, the \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 not turned off, the GTK-styled dialog opens. Call fl_register_images() to add a "Preview" button to this dialog. diff --git a/FL/Fl_Printer.H b/FL/Fl_Printer.H index 4a3f9177b..7da0f1da5 100644 --- a/FL/Fl_Printer.H +++ b/FL/Fl_Printer.H @@ -75,7 +75,7 @@
  • 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.
  • Under the KDE desktop, Fl_Printer runs the kdialog 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.
  • 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. diff --git a/FL/Fl_Table.H b/FL/Fl_Table.H index 1adc29255..746b3a37d 100644 --- a/FL/Fl_Table.H +++ b/FL/Fl_Table.H @@ -24,7 +24,7 @@ // EXPERIMENTAL // 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 #if (FLTK_USE_STD) diff --git a/FL/x11.H b/FL/x11.H index a79cf38f8..c3473020b 100644 --- a/FL/x11.H +++ b/FL/x11.H @@ -38,7 +38,7 @@ extern Window fl_x11_xid(const Fl_Window *win); extern Fl_Window *fl_x11_find(Window xid); /** Returns the X11-specific currently active graphics context. */ 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(); #else // ! FL_DOXYGEN diff --git a/README.CMake.txt b/README.CMake.txt index 36276b1bd..f8768dc8b 100644 --- a/README.CMake.txt +++ b/README.CMake.txt @@ -6,21 +6,34 @@ README.CMake.txt - Building and using FLTK with CMake ========== 1 Introduction to CMake - 2 Using CMake to Build FLTK - 2.1 Prerequisites - 2.2 Options - 2.3 Building under Linux with Unix Makefiles - 2.4 Building under Windows with Visual Studio [SUGGESTED DOCS -erco] - 2.5 Building under Windows with MinGW using Makefiles - 2.6 Building under MacOS with Xcode - 2.7 Crosscompiling - 3 Using CMake with FLTK - 3.1 Library Names - 3.2 Building a Simple "Hello World" Program with FLTK - 3.3 Building a Program Using Fluid Files - 3.4 Building a Program Using CMake's FetchContent Module - 4 Document History + 2 Using CMake to Build FLTK + + 2.1 Prerequisites + 2.2 Options + 2.2.1 General CMake Options + 2.2.2 FLTK Specific Build Options + 2.2.3 Documentation Options + 2.2.4 Special Options + 2.3 Building under Linux with Unix Makefiles + 2.4 Building under Windows with Visual Studio and/or NMake + 2.4.1 Building under Windows with Visual Studio + 2.4.2 Building under Windows with NMake + 2.5 Building under Windows with MinGW using Makefiles + 2.6 Building under MacOS with Xcode + 2.7 Crosscompiling + + 3 Using CMake with FLTK + + 3.1 Library Names + 3.2 Library Aliases + 3.3 Exported and Imported Targets + 3.4 Building a Simple "Hello World" Program with FLTK + 3.5 Building a Program Using Fluid Files + 3.6 Building a Program Using CMake's FetchContent Module + + + 4 FindFLTK.cmake and find_package(FLTK) 1. Introduction to CMake =========================== @@ -28,30 +41,30 @@ README.CMake.txt - Building and using FLTK with CMake CMake was designed to let you create build files for a project once and then compile the project on multiple platforms. -Using it on any platform consists of the same steps. Create the -CMakeLists.txt build file(s). Run one of the CMake executables, picking -your source directory, build directory, and build target. The "cmake" +Using it on any platform consists of the same steps. Create the +CMakeLists.txt build file(s). Run one of the CMake executables, picking +your source directory, build directory, and build target. The "cmake" executable is a one-step process with everything specified on the command -line. The others let you select options interactively, then configure -and generate your platform-specific target. You then run the resulting +line. The others let you select options interactively, then configure +and generate your platform-specific target. You then run the resulting Makefile / project file / solution file as you normally would. -CMake can be run in up to three ways, depending on your platform. "cmake" -is the basic command line tool. "ccmake" is the curses based interactive -tool. "cmake-gui" is the gui-based interactive tool. Each of these will -take command line options in the form of -DOPTION=VALUE. ccmake and +CMake can be run in up to three ways, depending on your platform. "cmake" +is the basic command line tool. "ccmake" is the curses based interactive +tool. "cmake-gui" is the gui-based interactive tool. Each of these will +take command line options in the form of -DOPTION=VALUE. ccmake and cmake-gui will also let you change options interactively. -CMake not only supports, but works best with out-of-tree builds. This means +CMake not only supports, but works best with out-of-tree builds. This means that your build directory is not the same as your source directory or with a -complex project, not the same as your source root directory. Note that the +complex project, not the same as your source root directory. Note that the build directory is where, in this case, FLTK will be built, not its final -installation point. If you want to build for multiple targets, such as +installation point. If you want to build for multiple targets, such as VC++ and MinGW on Windows, or do some cross-compiling you must use out-of-tree -builds exclusively. In-tree builds will gum up the works by putting a +builds exclusively. In-tree builds will gum up the works by putting a CMakeCache.txt file in the source root. -More information on CMake can be found on its web site http://www.cmake.org. +More information on CMake can be found on its web site https://www.cmake.org. @@ -63,18 +76,19 @@ More information on CMake can be found on its web site http://www.cmake.org. -------------------- The prerequisites for building FLTK with CMake are staightforward: -CMake 3.2.3 or later and a recent FLTK 1.3 release, snapshot, or Git -download (working copy). Installation of CMake is covered on its web site. +CMake 3.15 or later and a recent FLTK release, snapshot, or Git download +(working copy). Installation of CMake is covered on its web site. This howto will cover building FLTK with the default options using CMake under Linux and MinGW with Unix Makefiles. Chapter 2.5 shows how to use a MinGW cross compiling toolchain to build a FLTK library for Windows -under Linux. Other platforms are just as easy to use. +under Linux. Other platforms are just as easy to use. 2.2 Options -------------- -Options can be specified to cmake with the -D flag: + +Options can be specified to CMake with the -D flag: cmake -D = @@ -82,8 +96,20 @@ Example: cmake -D CMAKE_BUILD_TYPE=Debug -All options have sensible defaults so you won't usually need to touch these. -There are only two CMake options that you may want to specify: +Notes: the space between '-D' and the option name can be omitted. +Option values must be quoted if they contain spaces. + +Other CMake tools are `ccmake` and `cmake-gui` but these are not +described here. + +All options have sensible defaults so you won't usually need to specify +them explicitly. + + + 2.2.1 General CMake Options +------------------------------ + +There are only three CMake options that you may want to specify: CMAKE_BUILD_TYPE This specifies what kind of build this is i.e. Release, Debug... @@ -91,7 +117,7 @@ CMAKE_BUILD_TYPE by CMake depending on this value. CMAKE_INSTALL_PREFIX - Where everything will go on install. Defaults are /usr/local for Unix + Where everything will go on install. Defaults are /usr/local for Unix and C:\Program Files\FLTK for Windows. CMAKE_OSX_ARCHITECTURES (macOS only, ignored on other platforms) @@ -100,168 +126,226 @@ CMAKE_OSX_ARCHITECTURES (macOS only, ignored on other platforms) will either build Intel (x86_64) or Apple Silicon aka M1 (arm64) apps. The default is to build for the host processor architecture. -The following are the FLTK specific options. Platform specific options -are ignored on other platforms. +Note: the CMake variable BUILD_SHARED_LIBS is ignored by FLTK. FLTK builds + static libs by default and can optionally build shared libs as well. + Please see FLTK_BUILD_SHARED_LIBS instead. -OPTION_OPTIM - default EMPTY - Extra optimization flags for the C and C++ compilers, for instance - "-Wall -Wno-deprecated-declarations". -OPTION_ARCHFLAGS - default EMPTY - Extra architecture flags. + 2.2.2 FLTK Specific Build Options +------------------------------------ -OPTION_APPLE_X11 - default OFF - In case you want to use X11 on macOS. - Use this only if you know what you do, and if you have installed X11. +Following are the FLTK specific options. Platform specific options are +ignored on other platforms. For convenience the list of options is ordered +alphabetically except "Documentation Options" and "Special Options" that +follow in their own sections below. -OPTION_USE_POLL - default OFF - Don't use this one, it is deprecated. -OPTION_BUILD_SHARED_LIBS - default OFF - Normally FLTK is built as static libraries which makes more portable - binaries. If you want to use shared libraries, this will build them too. +FLTK_ABI_VERSION - default EMPTY + Use a numeric value corresponding to the FLTK ABI version you want to + build in the form 1xxyy for FLTK 1.x.y (xx and yy with leading zeroes). + The default ABI version is 1xx00 (the stable ABI throughout all patch + releases of one minor FLTK version). The highest ABI version you may + choose is 1xxyy for FLTK 1.x.y (again with leading zeroes). + Please see README.abi-version.txt for more information about which + ABI version to select. -FLTK_BUILD_FLUID - default ON - Builds the Fast Light User-Interface Designer ("FLUID"). +FLTK_ARCHFLAGS - default EMPTY + Extra "architecture" flags used as C and C++ compiler flags. + These flags are also "exported" to fltk-config. -FLTK_BUILD_FLTK_OPTIONS - default ON - Builds the FLTK options editor ("fltk-options"). +FLTK_BACKEND_WAYLAND - default ON (only Unix/Linux) + Enable the Wayland backend for all window operations, Cairo for all + graphics and Pango for text drawing (Linux+FreeBSD only). Resulting FLTK + apps use Wayland when a Wayland compositor is available at runtime, + and use X11 for their window operations otherwise (unless FLTK_BACKEND_X11 + is OFF), but keep using Cairo and Pango - see README.Wayland.txt. + If FLTK_BACKEND_X11 has been turned OFF and there is no Wayland compositor + at runtime, then FLTK programs fail to start. -FLTK_BUILD_TEST - default ON - Builds the test and demo programs in the 'test' directory. +FLTK_BACKEND_X11 - default ON on Unix/Linux, OFF elsewhere (Windows, macOS). + Enable or disable the X11 backend on platforms that support it. + - Unix/Linux: enable or disable the X11 backend when building with + Wayland (FLTK_BACKEND_WAYLAND), otherwise this option must be ON. + - macOS: enable the X11 backend instead of standard system graphics. + This requires XQuartz or a similar X11 installation. This option is + tested only with XQuartz by the FLTK team. + Use this only if you know what you do and if you have installed X11. + - Windows/Cygwin: enable X11 backend for Cygwin platforms. This option + is currently (as of FLTK 1.4.0) not supported on Windows. + +Note: On platforms that support Wayland you may set FLTK_BACKEND_WAYLAND=ON + (this is the default) and FLTK_BACKEND_X11=OFF to build a Wayland-only + library or vice versa for an X11-only library. FLTK_BUILD_EXAMPLES - default OFF - Builds the example programs in the 'examples' directory. + Build the example programs in the 'examples' directory. -FLTK_MSVC_RUNTIME_DLL - default ON (only for Visual Studio and NMake). - Selects whether the build uses the MS runtime DLL or not. - Default is ON: either /MD or /MDd for Release or Debug, respectively. - Select OFF for either /MT or /MTd for Release or Debug, respectively. +FLTK_BUILD_FLTK_OPTIONS - default ON + Build the FLTK options editor ("fltk-options"). -OPTION_CAIRO - default OFF - Enables support of class Fl_Cairo_Window (all platforms, requires the - Cairo library) - see README.Cairo.txt. +FLTK_BUILD_FLUID - default ON + Build the Fast Light User-Interface Designer ("fluid"). -OPTION_CAIROEXT - default OFF - Enables extended libcairo support - see README.Cairo.txt. +FLTK_BUILD_FORMS - default ON + Build the (X)Forms compatibility library. This option is ON by default + for backwards compatibility but can safely be turned OFF if you don't + need (X)Forms compatibility. -OPTION_USE_GL - default ON - Enables OpenGL support. +FLTK_BUILD_GL - default ON + Build the OpenGL support library fltk_gl (fltk::gl) and enable OpenGL + support in user programs using fltk_gl. -OPTION_USE_THREADS - default ON - Enables multithreaded support. +FLTK_BUILD_SHARED_LIBS - default OFF + Normally FLTK is built as static libraries which makes more portable + binaries. If you want to use shared libraries, this will build them too. + You can use shared FLTK libs in your own CMake projects by appending + "-shared" to FLTK target names as described in section 3.1 and 3.2. -OPTION_LARGE_FILE - default ON - Enables large file (>2G) support. +FLTK_BUILD_TEST - default ON in top-level build, OFF in sub-build + Build the test and demo programs in the 'test' directory. The default + is ON if the FLTK build is in a top-level project so all test and demo + programs are built. If FLTK is built as a subproject only the Library + and the tools (fluid and fltk-config) are built by default. -OPTION_USE_SYSTEM_LIBJPEG - default ON (macOS: OFF) -OPTION_USE_SYSTEM_LIBPNG - default ON (macOS: OFF) -OPTION_USE_SYSTEM_ZLIB - default ON - FLTK has built in jpeg, zlib, and png libraries. These options let you - use system libraries instead, unless CMake can't find them. If you set - any of these options to OFF, then the built in library will be used. +FLTK_GRAPHICS_CAIRO - default OFF (Unix/Linux: X11 + Wayland only). + Make all drawing operations use the Cairo library (rather than Xlib), + producing antialiased graphics (X11 platform: implies FLTK_USE_PANGO). + When using Wayland this option is ignored (Wayland uses Cairo). -OPTION_USE_SVG - default ON - FLTK has a built-in SVG library and can create (write) SVG image files. - Turning this option off disables SVG (read and write) support. +FLTK_GRAPHICS_GDIPLUS - default ON (Windows only). + Make FLTK use GDI+ to draw oblique lines and curves resulting in + antialiased graphics. If this option is OFF standard GDI is used. -OPTION_USE_XINERAMA - default ON -OPTION_USE_XFT - default ON -OPTION_USE_XCURSOR - default ON -OPTION_USE_XRENDER - default ON - These are X11 extended libraries. These libs are used if found on the - build system unless the respective option is turned off. +FLTK_MSVC_RUNTIME_DLL - default ON (Windows only: Visual Studio and NMake). + Select whether the build uses the MS runtime DLL (ON) or not (OFF). + Default is ON: either /MD or /MDd for Release or Debug, respectively. + Select OFF for either /MT or /MTd for Release or Debug, respectively. -OPTION_USE_CAIRO - default OFF - Makes all drawing operations use the Cairo library (rather than Xlib) - producing antialiased graphics (X11 platform, implies OPTION_USE_PANGO). +FLTK_OPTION_CAIRO_EXT - default OFF + Enable extended libcairo support - see README.Cairo.txt. -OPTION_USE_PANGO - default OFF (see note below) - Enables use of the Pango library for drawing text. Pango supports all - unicode-defined scripts and gives FLTK limited support of right-to-left - scripts. This option makes sense only under X11 or Wayland, and also - requires Xft. - Note: Turned ON if Wayland or OPTION_USE_CAIRO is enabled. +FLTK_OPTION_CAIRO_WINDOW - default OFF + Enable support of class Fl_Cairo_Window (all platforms, requires the + Cairo library) - see README.Cairo.txt. -OPTION_USE_KDIALOG - default ON - Under the KDE desktop, allows class Fl_Native_File_Chooser to use the - kdialog utility program to construct its file dialog windows, when that - utility is available at run time on the system. This option makes sense - only under X11 or Wayland. +FLTK_OPTION_FILESYSTEM_SUPPORT - default ON -OPTION_USE_WAYLAND - default ON - Enables the use of Wayland for all window operations, of Cairo for all - graphics and of Pango for text drawing (Linux+FreeBSD only). Resulting FLTK - apps use Wayland when a Wayland compositor is available at run-time, - and use X11 for their window operations otherwise, but keep using - Cairo and Pango - see README.Wayland.txt. +FLTK_OPTION_LARGE_FILE - default ON + Enables large file (>2G) support. -OPTION_WAYLAND_ONLY - default OFF - In conjunction with OPTION_USE_WAYLAND, restricts FLTK to support the - Wayland backend only. +FLTK_OPTION_OPTIM - default EMPTY + Extra optimization flags for the C and C++ compilers, for instance + "-Wall -Wno-deprecated-declarations". -OPTION_ALLOW_GTK_PLUGIN - default ON - Allow to use libdecor's GTK plugin to draw window titlebars (Wayland only). - Otherwise, FLTK will not use GTK and apps will not need linking to GTK. +FLTK_OPTION_PRINT_SUPPORT - default ON + When turned off, the Fl_Printer class does nothing and the + Fl_PostScript_File_Device class cannot be used, but the FLTK library + is somewhat smaller. This option makes sense only on the Unix/Linux + platform or on macOS when FLTK_BACKEND_X11 is ON. -OPTION_ABI_VERSION - default EMPTY - Use a numeric value corresponding to the FLTK ABI version you want to - build in the form 1xxyy for FLTK 1.x.y (xx and yy with leading zeroes). - The default ABI version is 1xx00 (the stable ABI throughout all patch - releases of one minor FLTK version). The highest ABI version you may - choose is 1xxyy for FLTK 1.x.y (again with leading zeroes). - Please see README.abi-version.txt for more information about which - ABI version to select. +FLTK_OPTION_STD - default OFF + This option allows FLTK to use some specific features of modern C++ + like std::string in the public API of FLTK 1.4.x. Users turning this + option ON can benefit from some new functions and methods that return + std::string or use std::string as input parameters. + Note: This option will be removed in the next minor (1.5.0) or major + release which will use std::string and other modern C++ features. -OPTION_PRINT_SUPPORT - default ON - When turned off, the Fl_Printer class does nothing and the - Fl_PostScript_File_Device class cannot be used, but the FLTK library - is somewhat smaller. This option makes sense only on the Unix/Linux - platform or when OPTION_APPLE_X11 is ON. +FLTK_OPTION_SVG - default ON + FLTK has a built-in SVG library and can create (write) SVG image files. + Turning this option off disables SVG (read and write) support. -OPTION_USE_GDIPLUS - default ON - Makes FLTK use GDI+ to draw oblique lines and curves resulting in - antialiased graphics (Windows platform only). +FLTK_USE_KDIALOG - default ON + Under the KDE desktop, allows class Fl_Native_File_Chooser to use the + kdialog utility program to construct its file dialog windows, when that + utility is available at run time on the system. This option makes sense + only under X11 or Wayland. -OPTION_USE_STD - default OFF - This option allows FLTK to use some specific features of modern C++ - like std::string in the public API of FLTK 1.4.x. Users turning this - option ON can benefit from some new functions and methods that return - std::string or use std::string as input parameters. - Note: this option will probably be removed in the next minor (1.5.0) - or major (maybe 4.0.0) release which will default to use std::string - and more modern C++ features. +FLTK_USE_LIBDECOR_GTK - default ON (Wayland only). + Allow to use libdecor's GTK plugin to draw window titlebars. Otherwise + FLTK does not use GTK and apps will not need linking to GTK. This feature + is always 'ON' if FLTK_USE_SYSTEM_LIBDECOR is 'ON'. -OPTION_USE_SYSTEM_LIBDECOR - default ON - This option makes FLTK use package libdecor-0-dev to draw window titlebars - under Wayland. When OFF or when this package has a version < 0.2.0, FLTK - uses its bundled copy of libdecor to draw window titlebars. - As of november 2023, version 0.2.0 of package libdecor-0-dev is available - only in testing distributions. +FLTK_USE_PANGO - default OFF (see note below) + Enables use of the Pango library for drawing text. Pango supports all + unicode-defined scripts and gives FLTK limited support of right-to-left + scripts. This option makes sense only under X11 or Wayland, and also + requires Xft. + This option is ignored (always enabled) if Wayland or FLTK_GRAPHICS_CAIRO + is ON. -Documentation options: these options are only available if `doxygen' is - installed and found by CMake. PDF related options require also `latex'. +FLTK_USE_POLL - default OFF + Deprecated: don't turn this option ON. -OPTION_BUILD_HTML_DOCUMENTATION - default ON -OPTION_BUILD_PDF_DOCUMENTATION - default ON - These options can be used to switch HTML documentation generation with - doxygen on. If these are ON the build targets 'html', 'pdf', and 'docs' - are generated but must be built explicitly. Technically the build targets - are generated but excluded from 'ALL'. You can safely leave these two - options ON if you want to save build time because the docs are not - built automatically. +FLTK_USE_PTHREADS - default ON except on Windows. + Enables multithreaded support with pthreads if available. + This option is ignored (switched OFF internally) on Windows except + when using Cygwin. -OPTION_INCLUDE_DRIVER_DOCUMENTATION - default OFF - This option adds driver documentation to HTML and PDF docs (if ON). This - option is marked as "advanced" since it is only useful for FLTK developers - and advanced users. It is only used if at least one of the documentation - options above is ON as well. +FLTK_USE_SYSTEM_LIBDECOR - default ON (Wayland only) + This option makes FLTK use package libdecor-0-dev to draw window titlebars + under Wayland. When OFF or when this package has a version < 0.2.0, FLTK + uses its bundled copy of libdecor to draw window titlebars. + As of november 2023, version 0.2.0 of package libdecor-0-dev is available + only in testing distributions. -OPTION_INSTALL_HTML_DOCUMENTATION - default OFF -OPTION_INSTALL_PDF_DOCUMENTATION - default OFF - If these options are ON then the HTML and/or PDF docs are installed - when the 'install' target is executed, e.g. with `make install'. You - need to select above options OPTION_BUILD_*_DOCUMENTATION as well. +FLTK_USE_SYSTEM_LIBJPEG - default ON (macOS and Windows: OFF) +FLTK_USE_SYSTEM_LIBPNG - default ON (macOS and Windows: OFF) +FLTK_USE_SYSTEM_ZLIB - default ON (macOS and Windows: OFF) + FLTK has built in jpeg, zlib, and png libraries. These options let you + use system libraries instead, unless CMake can't find them. If you set + any of these options to OFF, then the built in library will be used. + The default is ON on Linux/Unix platforms but OFF on Windows and macOS + because of potential incompatibilities on Windows and macOS whereas + the system libraries can typically be used on Linux/Unix. + Note: if any one of libpng or zlib is not found on the system, both + libraries are built using the bundled ones and a warning is issued. + +FLTK_USE_XCURSOR - default ON +FLTK_USE_XFIXES - default ON +FLTK_USE_XFT - default ON +FLTK_USE_XINERAMA - default ON +FLTK_USE_XRENDER - default ON + These are X11 extended libraries. These libs are used if found on the + build system unless the respective option is turned off. + + + 2.2.3 Documentation Options +------------------------------ + + These options are only available if `doxygen' is installed and found. + PDF related options require also `latex'. + +FLTK_BUILD_HTML_DOCS - default ON +FLTK_BUILD_PDF_DOCS - default ON + These options can be used to enable HTML documentation generation with + doxygen. If these are ON the build targets 'html', 'pdf', and 'docs' + are generated but must be built explicitly. Technically the build targets + are generated but excluded from 'ALL'. + You can safely leave these two options ON if you want to save build time + because the docs are not built automatically. + +FLTK_INCLUDE_DRIVER_DOCS - default OFF + This option adds driver documentation to HTML and PDF docs (if ON). This + option is marked as "advanced" since it is only useful for FLTK developers + and advanced users. It is only used if at least one of the documentation + options above is ON as well. + +FLTK_INSTALL_HTML_DOCS - default OFF +FLTK_INSTALL_PDF_DOCS - default OFF + If these options are ON then the HTML and/or PDF docs are installed + when the 'install' target is executed, e.g. with `make install'. You + need to select above options FLTK_BUILD_*_DOCS as well. + + + 2.2.4 Special Options +------------------------ + +FLTK_INSTALL_LINKS - default OFF + Deprecated: install "compatibility" links to compensate for typos in + include statements (for case sensitive file systems only). + You should not use this option, please fix the sources instead for + better cross-platform compatibility. 2.3 Building under Linux with Unix Makefiles @@ -285,7 +369,7 @@ Some flags can be changed during the 'make' command, such as: make VERBOSE=on -..which builds in verbose mode, so you can see all the compile/link commands. +which builds in verbose mode, so you can see all the compile/link commands. Hint: if you intend to build several different versions of FLTK, e.g. a Debug and a Release version, or multiple libraries with different ABI versions or @@ -293,96 +377,117 @@ options, then use subdirectories in the build directory, like this: mkdir build cd build - mkdir Debug - cd Debug + mkdir debug + cd debug cmake -D 'CMAKE_BUILD_TYPE=Debug' ../.. make sudo make install (optional) - 2.4 Building under Windows with Visual Studio ------------------------------------------------- + 2.4 Building under Windows with Visual Studio and/or NMake +------------------------------------------------------------- -Building with CMake under Visual Studio requires the CMake generator with -the -G command line switch, or the generator can be selected interactively -in the GUI (cmake-gui). +Building with CMake under Visual Studio may require to specify the CMake +generator with the -G"Visual Studio ..." command line switch, or the +generator can be selected interactively in the GUI (cmake-gui). If you +are not sure which one to select use `cmake --help` which lists all +generators known to CMake on your system. - 2.4.1 Visual Studio 7 / .NET - ------------------------------ - 1) Open a "Visual Studio .NET command prompt" window, e.g. + 2.4.1 Building under Windows with Visual Studio +------------------------------------------------- - Start > All Programs > Microsoft Visual Studio .NET > - Visual Studio .NET Tools > Command Prompt +CMake often finds an installed Visual Studio generator and uses it w/o +using the commandline switch, particularly if you are using a special +"Visual Studio Command Prompt": - 2) In the DOS window created above, change the current directory - to where you've extracted an fltk distribution tar file (or - snapshot tar file), and run the following commands: + - Hit the "Windows" key - cd C:\fltk-1.4.x <-- change to your FLTK directory - mkdir build <-- create an empty directory - cd build - cmake -G "Visual Studio 7" -D CMAKE_BUILD_TYPE=Release .. + - Type "developer command ..." + ... until you see something like "Developer Command Prompt for VS xxxx" + (replace 'xxxx' with your installed Visual Studio version) - IMPORTANT: The trailing ".." on the cmake command must be specified - (it is NOT an ellipsis). ^^^^^^^^^^^^^^^^^ + - Activate the "app" to execute the command prompt (like an old "DOS" shell) - This will create the file FLTK.sln in the current 'build' directory. + - Inside this command prompt window, run your installed `cmake` (command + line) or `cmake-gui` (GUI) program. You may need to specify the full path + to this program. - 3) Open Visual Studio 7, and choose File -> Open -> Project, - and pick the "FLTK.sln" created by step #2 in the 'build' directory. + If you use `cmake-gui` you can select the source and the build folders in + the GUI, otherwise change directory to where you downloaded and installed + the FLTK sources and execute: - (Or, if only one version of the Visual Studio compiler is installed, - you can just run from DOS: .\FLTK.sln) + `cmake` -G "Visual Studio xxx..." -B build + cd build - 4) Make sure the pulldown menu has either "Release" or "Debug" selected - in the "Solution Configurations" pulldown menu. + This creates the Visual Studio project files (FLTK.sln and more) in the + 'build' directory. - 5) In the "Solution Explorer", right click on: + Open Visual Studio, choose File -> Open -> Project, and pick the "FLTK.sln" + created in the previous step. - Solution 'FLTK' (## projects) + (Or, if only one version of the Visual Studio compiler is installed, + you can just run from DOS: .\FLTK.sln) - ..and in the popup menu, choose "Build Solution" + Make sure the pulldown menu has either "Release" or "Debug" selected + in the "Solution Configurations" pulldown menu. - 5) That's it, that should build FLTK. + In the "Solution Explorer", right click on: - The test programs (*.exe) can be found in e.g. + Solution 'FLTK' (## projects) - Release: C:\fltk-1.4.x\build\bin\examples\release\*.exe - Debug: C:\fltk-1.4.x\build\bin\examples\debug\*.exe + ... and in the popup menu, choose "Build Solution" - ..and the FLTK include files (*.H & *.h) your own apps can - compile with can be found in: + or choose 'Build/Build Solution' or 'Build/Rebuild Solution' from the + menu at the top of the window. - Release & Debug: C:\fltk-1.4.x\build\FL - *and* [1] in: C:\fltk-1.4.x\FL + That's it, that should build FLTK. - ..and the FLTK library files (*.lib) which your own apps can - link with can be found in: + The test programs (*.exe) can be found relative to the 'build' folder in - Release: C:\fltk-1.4.x\build\lib\release\*.lib - Debug: C:\fltk-1.4.x\build\lib\debug\*.lib + build\bin\test\Release\*.exe + build\bin\test\Debug\*.exe - [1] If you want to build your own FLTK application directly using - the build directories (i.e. without "installation") you need - to include both the build tree (first) and then the FLTK source - tree in the compiler's header search list. + ... and the FLTK include files (*.H & *.h) your own apps can + compile with can be found in: - 2.4.2 Visual Studio 2019 / NMake - -------------------------------------- - This uses cmake to generate + build FLTK in Release mode using nmake, - using purely the command line (never need to open the Visual Studio IDE) - using Multithreaded (/MT): + build\FL - mkdir build-nmake - cd build-nmake - cmake -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=Release -D FLTK_MSVC_RUNTIME_DLL=off .. - nmake + *and* [1] in the source folder where you downloade FLTK, e.g. in + + C:\fltk-1.4.x\FL + + ... and the FLTK library files (*.lib) which your own apps can + link with can be found in: + + Release: build\lib\Release\*.lib + Debug: build\lib\Debug\*.lib + + [1] If you want to build your own FLTK application directly using + the build directories (i.e. without "installation") you need + to include both the build tree (first) and then the FLTK source + tree in the compiler's header search list. + + + 2.4.2 Building under Windows with NMake +----------------------------------------- + + This example uses cmake to generate + build FLTK in Release mode using nmake, + using purely the command line (never need to open the Visual Studio IDE) + using Multithreaded (/MT): + + mkdir build-nmake + cd build-nmake + cmake -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=Release -D FLTK_MSVC_RUNTIME_DLL=off .. + nmake + + which results in a colorful percentage output crawl similar to what we see + with unix 'make'. + + Instead of running `nmake` directly you can also use cmake to build: + + cmake --build . - ..which results in a colorful percentage output crawl similar to what - we see with unix 'make'. - -erco@seriss.com - Updated: Dec 8 2023 2.5 Building under Windows with MinGW using Makefiles -------------------------------------------------------- @@ -437,13 +542,6 @@ of the cmake related files are updated, Xcode will rerun cmake for you. 5a) To build the Release version of FLTK, use > cmake -G Xcode -D CMAKE_BUILD_TYPE=Release ../.. -5b) To create all included libraries instead of using those that come - with MacOS, use: - > cmake -G Xcode -D OPTION_USE_SYSTEM_LIBJPEG=Off \ - -D OPTION_USE_SYSTEM_ZLIB=Off \ - -D OPTION_USE_SYSTEM_LIBPNG=Off \ - ../.. - 6) Launch Xcode from the Finder or from the Terminal: > open ./FLTK.xcodeproj When Xcode starts, it asks if it should "Autocreate Schemes". Click on @@ -463,9 +561,9 @@ of the cmake related files are updated, Xcode will rerun cmake for you. --------------------- Once you have a crosscompiler going, to use CMake to build FLTK you need -two more things. You need a toolchain file which tells CMake where your -build tools are. The CMake website is a good source of information on -this file. Here's one for MinGW (64-bit) under Linux. +two more things. You need a toolchain file which tells CMake where your +build tools are. The CMake website is a good source of information on +this file. Here's one for MinGW (64-bit) under Linux. ---- # CMake Toolchain File for MinGW-w64 (64-bit) Cross Compilation @@ -499,8 +597,8 @@ set(CMAKE_EXE_LINKER_FLAGS_INIT "-static-libgcc -static-libstdc++") # end of toolchain file ---- -Not too tough. The other thing you need is a native installation of FLTK -on your build platform. This is to supply the fluid executable which will +Not too tough. The other thing you need is a native installation of FLTK +on your build platform. This is to supply the fluid executable which will compile the *.fl into C++ source and header files. So, again from the FLTK tree root. @@ -525,12 +623,12 @@ required. =========================== The CMake Export/Import facility can be thought of as an automated -fltk-config. For example, if you link your program to the FLTK -library, it will automatically link in all of its dependencies. This +fltk-config. For example, if you link your program to the FLTK +library, it will automatically link in all of its dependencies. This includes any special flags, i.e. on Linux it includes the -lpthread flag. This howto assumes that you have FLTK libraries which were built using CMake, -installed. Building them with CMake generates some CMake helper files which +installed. Building them with CMake generates some CMake helper files which are installed in standard locations, making FLTK easy to find and use. In the following examples we set the CMake cache variable 'FLTK_DIR' so @@ -549,69 +647,148 @@ Unix/Linux, for instance like this: -------------------- When you use the target_link_libraries() command, CMake uses its own internal -"target names" for libraries. The fltk library names are: +"target names" for libraries. The original fltk library names in the build +tree are: fltk fltk_forms fltk_images fltk_gl -and for the shared libraries (if built): - - fltk_SHARED fltk_forms_SHARED fltk_images_SHARED fltk_gl_SHARED - -The built-in libraries (if built): +The bundled image and zlib libraries (if built): fltk_jpeg fltk_png fltk_z +Append suffix "-shared" for shared libraries (Windows: DLL's). - 3.2 Building a Simple "Hello World" Program with FLTK +These library names are used to construct the filename on disk with system +specific prefixes and postfixes. For instance, on Linux/Unix 'fltk' is libfltk.a +and the shared library (fltk-shared) is libfltk.so.1.4.0 (in FLTK 1.4.0) with +additional system specific links. + +Note: since FLTK 1.4.0 the library fltk_cairo is no longer necessary and +should be removed from CMake files of user projects. fltk_cairo is now an +empty library solely for backwards compatibility and will be removed in the +future. + + + 3.2 Library Aliases +---------------------- + +Since FLTK 1.4.0 "aliases" for all libraries in the FLTK build tree are +created in the namespace "fltk::". These aliases should always be used by +consumer projects (projects that use FLTK) for several reasons which are +beyond the scope of this README file. The following table shows the FLTK +libraries and their aliases in the FLTK build tree. + + Library Name Alias Shared Library Alias Notes + -------------------------------------------------------------- + fltk fltk::fltk fltk::fltk-shared [1] + fltk_forms fltk::forms fltk::forms-shared [2] + fltk_gl fltk::gl fltk::gl-shared [2] + fltk_images fltk::images fltk::images-shared [2] + fltk_jpeg fltk::jpeg fltk::jpeg-shared [3] + fltk_png fltk::png fltk::png-shared [3] + fltk_z fltk::z fltk::z-shared [3] + + [1] The basic FLTK library. Use this if you don't need any of the other + libraries for your application. + [2] Use one or more of these libraries if you have specific needs, + e.g. if you need to read images (fltk::images), OpenGL (fltk::gl), + or (X)Forms compatibility (fltk::forms). If you use one of these + libraries in your CMakeLists.txt then fltk::fltk will be included + automatically. + [3] The bundled libraries are only built if requested and are usually + not needed in user projects. They are linked in with fltk::images + automatically if they were built with FLTK. + The only reason you may need them would be if you used libpng, + libjpeg, or zlib functions directly in your application and need + to use the bundled FLTK libs (e.g. on Windows). + + + 3.3 Exported and Imported Targets +------------------------------------ + +CMake terminology is to "export" and "import" library "targets". FLTK's +CMake files export targets and its CONFIG module FLTKConfig.cmake imports +targets so user projects can use them. Hence, if you use CMake's CONFIG +mode to find FLTK all library targets will be defined using the namespace +convention listed above in the "Alias" column. This is what user projects +are intended to use. + +In addition to the library targets FLTK defines the "imported target" +'fltk::fluid' which can be used to generate source (.cxx) and header (.h) +files from fluid (.fl) files. + +Another target fltk::fltk-config can be used to set (e.g.) system or user +specific FLTK options. This would usually be executed in the installation +process of a user project but should rarely be needed and is beyound the +scope of this documentation. + + + 3.4 Building a Simple "Hello World" Program with FLTK -------------------------------------------------------- -Here is a basic CMakeLists.txt file using FLTK. +Here is a basic CMakeLists.txt file using FLTK. It is important that +this file can only be used as simple as it is if you use find_package() +in `CONFIG` mode as shown below. This requires that the FLTK library +itself has been built with CMake. --- cmake_minimum_required(VERSION 3.15) project(hello) +# optional (see below): set(FLTK_DIR "/path/to/fltk" CACHE FILEPATH "FLTK installation or build directory") -find_package(FLTK REQUIRED CONFIG) +find_package(FLTK CONFIG REQUIRED) -add_executable(hello WIN32 MACOSX_BUNDLE hello.cxx) -if (APPLE) - target_link_libraries (hello PRIVATE "-framework cocoa") -endif (APPLE) - -target_include_directories (hello PRIVATE ${FLTK_INCLUDE_DIRS}) - -target_link_libraries (hello PRIVATE fltk) +add_executable (hello WIN32 MACOSX_BUNDLE hello.cxx) +target_link_libraries(hello PRIVATE fltk::fltk) --- -The set(FLTK_DIR ...) command is a superhint to the find_package command. -This is very useful if you don't install or have a non-standard install. +We recommend to use `cmake_minimum_required(VERSION 3.15)` or higher for +building projects that use FLTK. Lower CMake versions may work for user +projects but this is not tested by FLTK developers. + +The optional `set(FLTK_DIR ...)` command is a superhint to the find_package +command. This is very useful if you don't install or have a non-standard +install location. The path you give to it must be that of a directory that +contains the file FLTKConfig.cmake. + +You can omit this statement if CMake finds the required FLTK version +without it. This variable is stored in the CMake Cache so users can change +it with the ususal CMake GUI interfaces (ccmake, cmake-gui) or on the +CMake commandline (-D FLTK_DIR=...). + The find_package command tells CMake to find the package FLTK, REQUIRED -means that it is an error if it's not found. CONFIG tells it to search -only for the FLTKConfig file, not using the FindFLTK.cmake supplied with -CMake, which doesn't work with this version of FLTK. +means that it is an error if it's not found. CONFIG tells it to search +only for the FLTKConfig.cmake file, not using the FindFLTK.cmake "module" +supplied with CMake, which doesn't work with this version of FLTK. -The "WIN32 MACOSX_BUNDLE" in the add_executable tells this is a GUI app. -It is ignored on other platforms and should always be present with FLTK -GUI programs for better portability - unless you explicitly need to build -a "console program", e.g. on Windows. +"WIN32 MACOSX_BUNDLE" in the add_executable() command tells CMake that +this is a GUI app. It is ignored on other platforms than Windows or macOS, +respectively, and should always be present with FLTK GUI programs for +better portability - unless you explicitly need to build a "console program" +on Windows. -Once the package is found the CMake variable FLTK_INCLUDE_DIRS is defined -which can be used to add the FLTK include directories to the definitions -used to compile your program using the `target_include_directories()` command. +Once the package is found (in CONFIG mode, as described above) all built +FLTK libraries are "imported" as CMake "targets" or aliases and can be used +directly. These CMake library targets contain all necessary informations to +be used without having to know about additional include directories or +other library dependencies. This is what is called "Modern CMake". + +Older FLTK versions required to use the variables FLTK_INCLUDE_DIRS and +FLTK_LIBRARIES (among others). These variables and related commands are +no longer necessary if your project (CMakeLists.txt) uses CMake's +CONFIG mode as described in this file. The target_link_libraries() command is used to specify all necessary FLTK -libraries. Thus, you may have to add fltk_images, fltk_gl, etc… - -Note: the variable FLTK_USE_FILE used to include another file in -previous FLTK versions was deprecated since FLTK 1.3.4 and has been -removed in FLTK 1.4.0. +libraries. Thus you may use fltk::fltk, fltk::images, fltk::gl, fltk::forms, +or any combination. fltk::fltk is linked automatically if any of the other +libs is included. - 3.3 Building a Program Using Fluid Files + 3.5 Building a Program Using Fluid Files ------------------------------------------- CMake has a command named fltk_wrap_ui which helps deal with fluid *.fl @@ -619,6 +796,7 @@ files. Unfortunately it is broken in CMake 3.4.x but it seems to work in 3.5 and later CMake versions. We recommend to use add_custom_command() to achieve the same result in a more explicit and well-defined way. This is a more basic approach and should work for all CMake versions. +It is described below. Here is a sample CMakeLists.txt which compiles the CubeView example from a directory you've copied the test/Cube* files to. @@ -632,41 +810,40 @@ project(CubeView) set(FLTK_DIR "/path/to/fltk" CACHE FILEPATH "FLTK installation or build directory") -find_package(FLTK REQUIRED CONFIG) +find_package(FLTK CONFIG REQUIRED) # run fluid -c to generate CubeViewUI.cxx and CubeViewUI.h files add_custom_command( OUTPUT "CubeViewUI.cxx" "CubeViewUI.h" - COMMAND fluid -c ${CMAKE_CURRENT_SOURCE_DIR}/CubeViewUI.fl + COMMAND fltk::fluid -c ${CMAKE_CURRENT_SOURCE_DIR}/CubeViewUI.fl ) add_executable(CubeView WIN32 MACOSX_BUNDLE - CubeMain.cxx CubeView.cxx CubeViewUI.cxx) + CubeMain.cxx CubeView.cxx CubeViewUI.cxx) -target_include_directories (CubeView PRIVATE ${FLTK_INCLUDE_DIRS}) +target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -target_include_directories (CubeView PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_include_directories (CubeView PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) - -target_link_libraries (CubeView PRIVATE fltk fltk_gl) +target_link_libraries (CubeView PRIVATE fltk::gl) --- You can repeat the add_custom_command for each fluid file or if you -have a large number of them see the CMake/FLTK-Functions.cmake function -FLTK_RUN_FLUID for an example of how to run it in a loop. +have a large number of them see the fltk_run_fluid() function in +CMake/FLTK-Functions.cmake for an example of how to run it in a loop. The two lines - target_include_directories (CubeView PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_include_directories (CubeView PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) add the current build ("binary") and source directories as include directories. This is necessary for the compiler to find the local header files since the fluid-generated files (CubeViewUI.cxx and CubeViewUI.h) are created in the -current build directory. +current build directory and other header files may be in the source directory +(depending on your project). - 3.4 Building a Program Using CMake's FetchContent Module + 3.6 Building a Program Using CMake's FetchContent Module ----------------------------------------------------------- FLTK can be downloaded and built within a user project using CMake's @@ -680,41 +857,38 @@ project(hello) include(FetchContent) -set(FLTK_BUILD_TEST OFF CACHE BOOL "" FORCE) - FetchContent_Declare(FLTK - GIT_REPOSITORY https://github.com/fltk/fltk - GIT_SHALLOW TRUE + GIT_REPOSITORY https://github.com/fltk/fltk + GIT_TAG master + GIT_SHALLOW TRUE ) + +message(STATUS "Download and build FLTK if necessary, please wait...") FetchContent_MakeAvailable(FLTK) +message(STATUS "Download and build FLTK - done.") -add_executable(hello WIN32 MACOSX_BUNDLE hello.cxx) - -target_include_directories(hello PRIVATE ${fltk_BINARY_DIR} ${fltk_SOURCE_DIR}) - -# link as required: fltk fltk_gl fltk_images fltk_png fltk_jpeg fltk_z -target_link_libraries(hello PRIVATE fltk) - -if(APPLE) - target_link_libraries(hello PRIVATE "-framework Cocoa") # needed for Darwin -endif() - -if(WIN32) - target_link_libraries(hello PRIVATE gdiplus) -endif() +add_executable (hello WIN32 MACOSX_BUNDLE hello.cxx) +target_link_libraries(hello PRIVATE fltk::fltk) --- +This is as simple as it can be. The CMake FetchContent module is used to +download the FLTK sources from their Git repository and to build them. +Note that this will download and build the FLTK library during the CMake +configure phase which can take some time. Therefore the statement +`FetchContent_MakeAvailable()` is wrapped in `message(STATUS "...")` +commands to let the user know what's going on. - 4 Document History ---------------------- -Dec 20 2010 - matt: merged and restructured -May 15 2013 - erco: small formatting tweaks, added some examples -Feb 23 2014 - msurette: updated to reflect changes to the CMake files -Apr 07 2015 - AlbrechtS: update use example and more docs -Jan 31 2016 - msurette: custom command instead of fltk_wrap_ui -Nov 01 2016 - AlbrechtS: add MinGW build -Jul 05 2017 - matt: added instructions for macOS and Xcode -Dec 29 2018 - AlbrechtS: add documentation option descriptions -Apr 29 2021 - AlbrechtS: document macOS "universal apps" build setup -Nov 01 2023 - AlbrechtS: improve build instructions for user programs + 4 FindFLTK.cmake and find_package(FLTK) +========================================== + +The FindFLTK.cmake module provided by CMake which is also used in the +CMake command find_package(FLTK) does not yet support FLTK's new "Modern +CMake" features. + +Unfortunately this module has to be used if the FLTK library wasn't built +with CMake and thus CONFIG mode can't be used. In this case CMake falls back +to MODULE mode and find_package() uses this old CMake module. + +There are plans to provide a FindFLTK.cmake module with FLTK 1.4.0 but this +module is not yet written. Look here for further info if you need it... diff --git a/README.Cairo.txt b/README.Cairo.txt index 6d70e9213..0dc0b9ecc 100644 --- a/README.Cairo.txt +++ b/README.Cairo.txt @@ -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 2 CAIRO SUPPORT FOR FLTK - 2.1 Configuration - 2.2 Currently supported features - 2.3 Future considerations + 2.1 Supported Features (Fl_Cairo_Window) 3 PLATFORM SPECIFIC NOTES 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.3 Install CMake and Build with CMake - 4 DOCUMENT HISTORY - - INTRODUCTION -============== + 1 INTRODUCTION +================ Cairo is a software library used to provide a vector graphics-based, 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. - CAIRO SUPPORT FOR FLTK -======================== + 2 CAIRO SUPPORT FOR FLTK +========================== -It is now possible to integrate Cairo rendering in your FLTK application -more easily and transparently. -Since FLTK 1.3 we provide minimum support for Cairo; no "total" Cairo -rendering layer support is achieved. +Since FLTK 1.3 we provide minimum support for Cairo. User programs can +use the class Fl_Cairo_Window which sets up a Cairo context so the user +progam can call Cairo drawing calls in their own drawing callback. + + 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 -option --enable-cairo is not added to the configure command or the CMake -variable OPTION_CAIRO:BOOL=ON is set. + CMake option name: FLTK_GRAPHICS_CAIRO + Configure option : --enable-usecairo + +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 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. 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 complete and automatic synchronization of OS dependent graphical context 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. 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 - been used as a testcase during the multiplatform tests. +(4) A new Cairo demo that is available in the test subdirectory. For more details, please have a look to the doxygen documentation, in the Modules section. - PLATFORM SPECIFIC NOTES -========================= + 3 PLATFORM SPECIFIC NOTES +=========================== The following are notes about building FLTK with Cairo support on the various supported operating systems. @@ -107,7 +122,7 @@ on the various supported operating systems. sudo apt install libcairo2-dev Then build fltk using the Cairo support option using: - cmake -G"Unix Makefiles" -DOPTION_CAIRO:BOOL=ON -S -B + cmake -G "Unix Makefiles" -D FLTK_OPTION_CAIRO_WINDOW:BOOL=ON -S -B cd make @@ -156,9 +171,7 @@ on the various supported operating systems. Note 1: CMake builds *require* the use of 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 - build FLTK w/o having to install and use pkg-config. This will be done if - possible (but not guaranteed). + as well. 3.2 Windows @@ -241,17 +254,7 @@ on the various supported operating systems. e.g. 'build' or another folder anywhere else) and click "configure". 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 - to select OPTION_CAIRO (ON) to build with basic Cairo support. Finally - click "generate" to create the build files. + to select FLTK_OPTION_CAIRO_WINDOW (ON) to build with basic Cairo support. + Finally click "generate" to create the build files. 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. diff --git a/README.Wayland.txt b/README.Wayland.txt index 7dd952690..f01147f5d 100644 --- a/README.Wayland.txt +++ b/README.Wayland.txt @@ -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, the default building procedure produces a X11-based library. -Use -DOPTION_USE_WAYLAND=OFF with CMake or "configure --disable-wayland" to build -FLTK for the X11 library when the default would build for Wayland. +Use "-D FLTK_OPTION_USE_WAYLAND=OFF" with CMake or "configure --disable-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 cross-compiling for systems that lack X11 headers and libraries. diff --git a/README.abi-version.txt b/README.abi-version.txt index 7ccda33c7..b87578725 100644 --- a/README.abi-version.txt +++ b/README.abi-version.txt @@ -72,13 +72,13 @@ the version number. ABI version, use ccmake, cmake-gui, or run cmake with the following command: - cmake -D OPTION_ABI_VERSION:STRING=10401 /path/to/fltk + cmake -D FLTK_ABI_VERSION:STRING=10401 /path/to/fltk Then execute 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. 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]. - Use CMake option OPTION_ABI_VERSION:STRING=10401 with the command line - or set OPTION_ABI_VERSION with one of the CMake GUI programs. + Use CMake option FLTK_ABI_VERSION:STRING=10401 with the command line + 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 will run the build with the defined ABI version. diff --git a/README.macOS.md b/README.macOS.md index ade1ba8e1..9287bfebf 100644 --- a/README.macOS.md +++ b/README.macOS.md @@ -134,9 +134,9 @@ 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 -done, the upper list field in _CMake_ will show CMAKE, FLTK, and OPTION. Open the OPTION -field and find the entries OPTION_USE_SYSTEM_LIBJPEG and OPTION_USE_SYSTEM_LIBPNG, -and disable both for maximum compatibility with other macOS installation. +done, the upper list field in _CMake_ will show CMAKE and FLTK. Open the FLTK field and +adjust options if you like. Note that the bundled image libraries are built by default. +Further options are available under the CMAKE field. Finally, click _Generate_ to generate the _Xcode_ IDE file. @@ -246,12 +246,12 @@ Now configure your FLTK installation: ```bash cmake -G "Unix Makefiles" \ - -D OPTION_USE_SYSTEM_LIBJPEG=Off \ - -D OPTION_USE_SYSTEM_ZLIB=Off \ - -D OPTION_USE_SYSTEM_LIBPNG=Off \ + -D CMAKE_BUILD_TYPE=Debug \ ../.. ``` +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. 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 _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 `~/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 - Mar 01 2021 - Albrecht: minor updates, macOS Big Sur and Apple Silicon M1 (ARM) - Feb 23 2022 - Manolo: install autoconf without brew - diff --git a/cairo/CMakeLists.txt b/cairo/CMakeLists.txt index f031d674f..1e1c1a02b 100644 --- a/cairo/CMakeLists.txt +++ b/cairo/CMakeLists.txt @@ -25,15 +25,19 @@ # 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}") - target_link_libraries (fltk_cairo_SHARED fltk_SHARED) + fl_add_library(fltk_cairo SHARED "${cairo_SRCS}") + 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) diff --git a/documentation/CMakeLists.txt b/documentation/CMakeLists.txt index 5cfcb0de6..23a6f65bf 100644 --- a/documentation/CMakeLists.txt +++ b/documentation/CMakeLists.txt @@ -14,37 +14,37 @@ # https://www.fltk.org/bugs.php # -set (DOCS) -set (GENERATE_DOCS FALSE) -set (GIT_REVISION "") -set (YEAR "") -set (CURRENT_DATE "") +set(DOCS) +set(GENERATE_DOCS FALSE) +set(GIT_REVISION "") +set(YEAR "") +set(CURRENT_DATE "") -if (OPTION_BUILD_HTML_DOCUMENTATION OR OPTION_BUILD_PDF_DOCUMENTATION) - set (GENERATE_DOCS TRUE) -endif () +if(FLTK_BUILD_HTML_DOCS OR FLTK_BUILD_PDF_DOCS) + set(GENERATE_DOCS TRUE) +endif() -if (OPTION_INCLUDE_DRIVER_DOCUMENTATION) - set (DRIVER_DOCS "DriverDev") -else () - set (DRIVER_DOCS "") -endif () +if(FLTK_INCLUDE_DRIVER_DOCS) + set(DRIVER_DOCS "DriverDev") +else() + set(DRIVER_DOCS "") +endif() #------------------------------------------------ # generate files used for both HTML and PDF docs #------------------------------------------------ -if (GENERATE_DOCS) +if(GENERATE_DOCS) # create required variables - execute_process (COMMAND date "+%Y" + execute_process(COMMAND date "+%Y" OUTPUT_VARIABLE YEAR OUTPUT_STRIP_TRAILING_WHITESPACE ) # 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_STRIP_TRAILING_WHITESPACE ) @@ -56,16 +56,17 @@ if (GENERATE_DOCS) # In the future tarball/zip generation should create a file # that contains the git revision. - execute_process (COMMAND - git --git-dir=${FLTK_SOURCE_DIR}/.git rev-parse --short=10 HEAD + execute_process(COMMAND + git rev-parse --short=10 HEAD OUTPUT_VARIABLE GIT_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY ${FLTK_SOURCE_DIR} ERROR_QUIET ) # set to "'unkown'" if git is not available - if (GIT_REVISION STREQUAL "") - set (GIT_REVISION "'unkown'") + if(GIT_REVISION STREQUAL "") + set(GIT_REVISION "'unkown'") endif() # 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 # variable DOXYGEN_VERSION_SHORT with DOXYGEN_VERSION below. - if (DOXYGEN_FOUND) + if(DOXYGEN_FOUND) # strip trailing git revision if doxygen was built from source - string (REGEX REPLACE " .*$" "" DOXYGEN_VERSION_SHORT ${DOXYGEN_VERSION}) - endif (DOXYGEN_FOUND) + string(REGEX REPLACE " .*$" "" DOXYGEN_VERSION_SHORT ${DOXYGEN_VERSION}) + endif(DOXYGEN_FOUND) # configure copyright.dox (includes current year) - configure_file ( + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/copyright.dox.in ${CMAKE_CURRENT_BINARY_DIR}/copyright.dox @ONLY ) # configure generated.dox (includes date and versions) - configure_file ( + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/generated.dox.in ${CMAKE_CURRENT_BINARY_DIR}/generated.dox @ONLY ) - if (0) # debug - fl_debug_var (YEAR) - fl_debug_var (CURRENT_DATE) - fl_debug_var (GIT_REVISION) - fl_debug_var (DOXYGEN_FOUND) - fl_debug_var (DOXYGEN_EXECUTABLE) - fl_debug_var (DOXYGEN_VERSION) - fl_debug_var (DOXYGEN_VERSION_SHORT) - endif () + if(0) # debug + fl_debug_var(YEAR) + fl_debug_var(CURRENT_DATE) + fl_debug_var(GIT_REVISION) + fl_debug_var(DOXYGEN_FOUND) + fl_debug_var(DOXYGEN_EXECUTABLE) + fl_debug_var(DOXYGEN_VERSION) + fl_debug_var(DOXYGEN_VERSION_SHORT) + endif() -endif (GENERATE_DOCS) +endif(GENERATE_DOCS) #-------------------------- # 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" - set (GENERATE_HTML YES) - set (GENERATE_LATEX NO) - set (LATEX_HEADER "") - set (DOXYFILE "Doxyfile") - set (LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}_error.log") + set(GENERATE_HTML YES) + set(GENERATE_LATEX NO) + set(LATEX_HEADER "") + set(DOXYFILE "Doxyfile") + set(LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}_error.log") # configure Doxygen input file for HTML docs (Doxyfile.in) - configure_file ( + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}.in @ONLY @@ -132,7 +133,7 @@ if (OPTION_BUILD_HTML_DOCUMENTATION) # convert Doxyfile to used doxygen version - add_custom_command ( + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/convert_doxyfile @@ -146,34 +147,34 @@ if (OPTION_BUILD_HTML_DOCUMENTATION) # generate HTML documentation - add_custom_target (html + add_custom_target(html COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating HTML documentation" VERBATIM ) -endif (OPTION_BUILD_HTML_DOCUMENTATION) +endif(FLTK_BUILD_HTML_DOCS) #-------------------------- # 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" - set (GENERATE_HTML NO) - set (GENERATE_LATEX YES) - set (LATEX_HEADER "${CMAKE_CURRENT_BINARY_DIR}/fltk-book.tex") - set (DOXYFILE "Doxybook") - set (LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}_error.log") + set(GENERATE_HTML NO) + set(GENERATE_LATEX YES) + set(LATEX_HEADER "${CMAKE_CURRENT_BINARY_DIR}/fltk-book.tex") + set(DOXYFILE "Doxybook") + set(LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}_error.log") # configure Doxygen input file for PDF docs (Doxybook.in) - configure_file ( + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}.in @ONLY @@ -181,7 +182,7 @@ if (OPTION_BUILD_PDF_DOCUMENTATION) # convert Doxybook to current doxygen version - add_custom_command ( + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/convert_doxyfile @@ -195,7 +196,7 @@ if (OPTION_BUILD_PDF_DOCUMENTATION) # generate LaTeX title fltk-title.tex - configure_file ( + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/src/fltk-title.tex.in ${CMAKE_CURRENT_BINARY_DIR}/fltk-title.tex @ONLY @@ -203,7 +204,7 @@ if (OPTION_BUILD_PDF_DOCUMENTATION) # generate fltk.pdf - add_custom_command ( + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fltk.pdf COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/make_header ${DOXYGEN_EXECUTABLE} @@ -220,40 +221,40 @@ if (OPTION_BUILD_PDF_DOCUMENTATION) # add target 'pdf' - add_custom_target (pdf + add_custom_target(pdf DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fltk.pdf ) -endif (OPTION_BUILD_PDF_DOCUMENTATION) +endif(FLTK_BUILD_PDF_DOCS) #---------------------------------- # add target 'docs' for all docs #---------------------------------- -if (DOCS) +if(DOCS) - add_custom_target (docs + add_custom_target(docs DEPENDS ${DOCS} ) -endif (DOCS) +endif(DOCS) #---------------------------------- # 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 ) -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/ ) -endif (OPTION_INSTALL_PDF_DOCUMENTATION AND OPTION_BUILD_PDF_DOCUMENTATION) +endif(FLTK_INSTALL_PDF_DOCS AND FLTK_BUILD_PDF_DOCS) diff --git a/documentation/Makefile b/documentation/Makefile index c5450f08c..0b176246b 100644 --- a/documentation/Makefile +++ b/documentation/Makefile @@ -140,7 +140,7 @@ uninstall-linux uninstall-osx: # 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, -# 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 # replace the two lines below containing "@DRIVER_DOCS@" to read: # -e's, @DRIVER_DOCS@, DriverDev,' \ diff --git a/documentation/README.txt b/documentation/README.txt index 848ec66f1..bcd9459b9 100644 --- a/documentation/README.txt +++ b/documentation/README.txt @@ -106,15 +106,15 @@ required software packages (doxygen, LaTeX) installed. You can always leave them ON because the documentation is not built automatically (it is excluded from the default target "ALL"). - - OPTION_BUILD_HTML_DOCUMENTATION:BOOL=ON target: html - - OPTION_BUILD_PDF_DOCUMENTATION:BOOL=ON target: pdf + - FLTK_BUILD_HTML_DOCS:BOOL=ON target: html + - FLTK_BUILD_PDF_DOCS:BOOL=ON target: pdf The following two options default to OFF and can be switched ON. They are only used when installing the software ('make install') and the corresponding build options are ON. - - OPTION_INSTALL_HTML_DOCUMENTATION:BOOL=OFF - - OPTION_INSTALL_PDF_DOCUMENTATION:BOOL=OFF + - FLTK_INSTALL_HTML_DOCS:BOOL=OFF + - FLTK_INSTALL_PDF_DOCS:BOOL=OFF 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' diff --git a/documentation/src/drawing.dox b/documentation/src/drawing.dox index e70f12e76..3a2ad42dd 100644 --- a/documentation/src/drawing.dox +++ b/documentation/src/drawing.dox @@ -863,7 +863,7 @@ requires 4 bytes to store a Unicode character. FLTK can draw accurately any Unicode-supported script for which the system 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). Plain text drawing starting at a user-given coordinate diff --git a/documentation/src/migration_1_4.dox b/documentation/src/migration_1_4.dox index 1061a5759..acbe75f93 100644 --- a/documentation/src/migration_1_4.dox +++ b/documentation/src/migration_1_4.dox @@ -180,6 +180,129 @@ Code example in header file: 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
    diff --git a/documentation/src/wayland.dox b/documentation/src/wayland.dox index 9df242e08..4836f9c1f 100644 --- a/documentation/src/wayland.dox +++ b/documentation/src/wayland.dox @@ -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 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 cmake -DOPTION_WAYLAND_ONLY=on or with +This is achieved building FLTK with cmake -DFLTK_BACKEND_X11=OFF or with configure --disable-x11. In that case, FL/fl_config.h does not define \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. When these packages are not available or are at an earlier version, FLTK uses the bundled 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. 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 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, 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. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8912cffdf..d5c5a6d94 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,7 @@ # # 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 # 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/FLTK-Functions.cmake) +include(../CMake/fl_create_example.cmake) +include(../CMake/FLTK-Functions.cmake) -set (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../bin/examples) -file (MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../bin/examples) +file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) ################################################################################ @@ -30,7 +30,7 @@ file (MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) # simple examples w/o extra libs ############################################################ -set (SIMPLE_SOURCES +set(SIMPLE_SOURCES browser-simple callbacks chart-simple @@ -75,7 +75,7 @@ set (SIMPLE_SOURCES # simple FLUID examples w/o extra libs ############################################################ -set (FLUID_SOURCES +set(FLUID_SOURCES fluid-callback ) @@ -83,7 +83,7 @@ set (FLUID_SOURCES # examples requiring fltk_images ############################################################ -set (IMAGE_SOURCES +set(IMAGE_SOURCES animgifimage animgifimage-play animgifimage-resize @@ -95,7 +95,7 @@ set (IMAGE_SOURCES # examples requiring cairo ############################################################ -set (CAIRO_SOURCES +set(CAIRO_SOURCES cairo-draw-x ) @@ -103,7 +103,7 @@ set (CAIRO_SOURCES # examples requiring OpenGL + libGLEW ############################################################ -set (OPENGL_SOURCES +set(OPENGL_SOURCES OpenGL3-glut-test OpenGL3test ) @@ -112,42 +112,42 @@ set (OPENGL_SOURCES # create simple example programs ############################################################ -foreach (src ${SIMPLE_SOURCES}) - CREATE_EXAMPLE (${src} ${src}.cxx fltk) -endforeach (src) +foreach(src ${SIMPLE_SOURCES}) + fl_create_example(${src} ${src}.cxx fltk) +endforeach(src) ############################################################ # create FLUID example programs ############################################################ -foreach (src ${FLUID_SOURCES}) - CREATE_EXAMPLE (${src} ${src}.fl fltk) -endforeach (src) +foreach(src ${FLUID_SOURCES}) + fl_create_example(${src} ${src}.fl fltk) +endforeach(src) ############################################################ # create example programs with fltk_images library ############################################################ -foreach (src ${IMAGE_SOURCES}) - CREATE_EXAMPLE (${src} ${src}.cxx "fltk_images;fltk") -endforeach (src) +foreach(src ${IMAGE_SOURCES}) + fl_create_example(${src} ${src}.cxx "fltk_images;fltk") +endforeach(src) ############################################################ # create example programs requiring cairo ############################################################ -if (FLTK_HAVE_CAIRO) - set (cairo_libs "fltk;cairo") - if (TARGET fltk_cairo) - set (cairo_libs fltk_cairo ${cairo_libs}) - endif () -else () +if(FLTK_HAVE_CAIRO) + set(cairo_libs "fltk;cairo") + if(TARGET fltk_cairo) + set(cairo_libs fltk_cairo ${cairo_libs}) + endif() +else() set(cairo_libs "fltk") -endif () +endif() -foreach (src ${CAIRO_SOURCES}) - CREATE_EXAMPLE (${src} ${src}.cxx "${cairo_libs}") -endforeach (src) +foreach(src ${CAIRO_SOURCES}) + fl_create_example(${src} ${src}.cxx "${cairo_libs}") +endforeach(src) ############################################################ # create example programs with OpenGL + libGLEW @@ -155,25 +155,25 @@ endforeach (src) # Note: macOS does not need libGLEW -if (APPLE AND (NOT OPTION_APPLE_X11)) - if (NOT LIB_GLEW) - set (LIB_GLEW TRUE) - endif () - set (REQUIRED_LIBS fltk_gl fltk ${OPENGL_LIBRARIES}) -else () - set (REQUIRED_LIBS fltk_gl fltk ${LIB_GLEW} ${OPENGL_LIBRARIES}) -endif () +if(APPLE AND NOT FLTK_BACKEND_X11) + if(NOT LIB_GLEW) + set(LIB_GLEW TRUE) + endif() + set(REQUIRED_LIBS fltk_gl fltk ${OPENGL_LIBRARIES}) +else() + set(REQUIRED_LIBS fltk_gl fltk ${LIB_GLEW} ${OPENGL_LIBRARIES}) +endif() -if (OPENGL_FOUND AND LIB_GLEW) - foreach (src ${OPENGL_SOURCES}) - CREATE_EXAMPLE (${src} ${src}.cxx "${REQUIRED_LIBS}") - endforeach (src) -else () - message (STATUS +if(OPENGL_FOUND AND LIB_GLEW) + foreach(src ${OPENGL_SOURCES}) + fl_create_example(${src} ${src}.cxx "${REQUIRED_LIBS}") + endforeach(src) +else() + message(STATUS "OpenGL or libGLEW not present: OpenGL example programs will not be built.") - fl_debug_var (OPENGL_FOUND) - fl_debug_var (LIB_GLEW) - message ("") -endif (OPENGL_FOUND AND LIB_GLEW) + fl_debug_var(OPENGL_FOUND) + fl_debug_var(LIB_GLEW) + message("") +endif(OPENGL_FOUND AND LIB_GLEW) -unset (REQUIRED_LIBS) +unset(REQUIRED_LIBS) diff --git a/examples/cairo-draw-x.cxx b/examples/cairo-draw-x.cxx index a11e2db0c..a265dc360 100644 --- a/examples/cairo-draw-x.cxx +++ b/examples/cairo-draw-x.cxx @@ -59,7 +59,7 @@ 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("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; } #endif // (FLTK_HAVE_CAIRO) diff --git a/examples/howto-simple-svg.cxx b/examples/howto-simple-svg.cxx index c3875e469..1b922f9f2 100644 --- a/examples/howto-simple-svg.cxx +++ b/examples/howto-simple-svg.cxx @@ -55,7 +55,7 @@ const char *svg_logo = int main(int argc, char **argv) { #ifndef FLTK_USE_SVG 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."); return(1); #else diff --git a/fltk-options/CMakeLists.txt b/fltk-options/CMakeLists.txt index 0d12e95f4..5ce9e40fb 100644 --- a/fltk-options/CMakeLists.txt +++ b/fltk-options/CMakeLists.txt @@ -1,7 +1,7 @@ # # 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 # the file "COPYING" which should have been included with this file. If this @@ -14,71 +14,59 @@ # https://www.fltk.org/bugs.php # -set (CPPFILES - fltk-options.cxx -) +# Targets that will be built: fltk-options and fltk-options-cmd (Windows) +set(TARGETS fltk-options) -set (HEADERFILES -) - -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)) +if(APPLE AND NOT FLTK_BACKEND_X11) # macOS - set (ICON_NAME fltk-options.icns) - set (ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icons/${ICON_NAME}") - add_executable (fltk-options MACOSX_BUNDLE ${CPPFILES} ${HEADERFILES} ${ICON_PATH}) + set(ICON_NAME fltk-options.icns) + set(ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icons/${ICON_NAME}") + add_executable(fltk-options MACOSX_BUNDLE fltk-options.cxx ${ICON_PATH}) # create macOS bundle wrapper script - set (WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/fltk-options") - add_custom_command ( + set(WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/fltk-options") + add_custom_command( TARGET fltk-options POST_BUILD COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/../CMake/macOS-bundle-wrapper.in ${WRAPPER} COMMAND chmod u+x,g+x,o+x ${WRAPPER} BYPRODUCTS ${WRAPPER} VERBATIM ) - unset (WRAPPER) + unset(WRAPPER) -else () +else() - # option WIN32 builds a Windows GUI program, ignored on other platforms - add_executable (fltk-options WIN32 ${CPPFILES} ${HEADERFILES}) + # Option WIN32 builds a Windows GUI program, ignored on other platforms + add_executable(fltk-options WIN32 fltk-options.cxx) -endif () +endif() -# we must link fltk-optons with cairo if option CAIRO is enabled -if (FLTK_HAVE_CAIRO) - target_link_directories (fltk-options PRIVATE ${PKG_CAIRO_LIBRARY_DIRS}) -endif (FLTK_HAVE_CAIRO) +target_link_libraries(fltk-options PRIVATE fltk::fltk) -if (USE_GDIPLUS) # can only be true on Windows - 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. +# Add the console app (Windows only) # This is done for all Windows targets, even if cross-compiling. -if (WIN32) - list (APPEND FLTK_OPTIONS_TARGETS fltk-options-cmd) - add_executable (fltk-options-cmd ${CPPFILES} ${HEADERFILES}) - target_link_libraries (fltk-options-cmd ${FLTK_OPTIONS_LIBS}) - if (FLTK_HAVE_CAIRO) - target_link_directories (fltk-options-cmd PRIVATE ${PKG_CAIRO_LIBRARY_DIRS}) - endif (FLTK_HAVE_CAIRO) -endif () +if(WIN32) + list(APPEND TARGETS fltk-options-cmd) + add_executable(fltk-options-cmd fltk-options.cxx) + target_link_libraries(fltk-options-cmd PRIVATE fltk::fltk) +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 # 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. # 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_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 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 XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.fltk-options") # 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 (TARGETS fltk-options DESTINATION "/Applications") + # install(TARGETS fltk-options DESTINATION "/Applications") # install command line tool - install (PROGRAMS $ DESTINATION ${FLTK_BINDIR}) + install(PROGRAMS $ DESTINATION ${FLTK_BINDIR}) else() # install fltk-options GUI and optional commandline tool 'fltk-options-cmd' # (only on Windows) - install (TARGETS ${FLTK_OPTIONS_TARGETS} + install(TARGETS ${TARGETS} EXPORT FLTK-Targets RUNTIME DESTINATION ${FLTK_BINDIR} LIBRARY 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) - install (FILES fltk-options.desktop +if(UNIX) + install(FILES fltk-options.desktop DESTINATION ${FLTK_DATADIR}/applications ) - # Install mime-type file (x-fltk-options.desktop method is deprecated) - install (FILES fltk-options.xml + # Install mime-type file(x-fltk-options.desktop method is deprecated) + install(FILES fltk-options.xml DESTINATION ${FLTK_DATADIR}/mime/packages ) # Install desktop icons - foreach (icon 32 48 64 128) - install (FILES icons/fltk-options-${icon}.png + foreach(icon 32 48 64 128) + install(FILES icons/fltk-options-${icon}.png DESTINATION ${FLTK_DATADIR}/icons/hicolor/${icon}x${icon}/apps RENAME fltk-options.png ) endforeach() -endif (UNIX) +endif(UNIX) diff --git a/fluid/CMakeLists.txt b/fluid/CMakeLists.txt index 46bf237e0..28b5db745 100644 --- a/fluid/CMakeLists.txt +++ b/fluid/CMakeLists.txt @@ -1,7 +1,7 @@ # # 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 # the file "COPYING" which should have been included with this file. If this @@ -14,9 +14,14 @@ # 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 StyleParse.cxx Fd_Snap_Action.cxx @@ -50,7 +55,7 @@ set (CPPFILES # List header files in Apple's Xcode IDE -set (HEADERFILES +set(HEADERFILES CodeEditor.h Fd_Snap_Action.h Fl_Function_Type.h @@ -71,6 +76,7 @@ set (HEADERFILES custom_widgets.h factory.h file.h + fluid.h function_panel.h mergeback.h print_panel.h @@ -85,19 +91,19 @@ set (HEADERFILES # Add ExternalCodeEditor: platform specific files -if (WIN32) - list (APPEND CPPFILES ExternalCodeEditor_WIN32.cxx) - list (APPEND HEADERFILES ExternalCodeEditor_WIN32.h) -else () - list (APPEND CPPFILES ExternalCodeEditor_UNIX.cxx) - list (APPEND HEADERFILES ExternalCodeEditor_UNIX.h) -endif (WIN32) +if(WIN32) + list(APPEND CPPFILES ExternalCodeEditor_WIN32.cxx) + list(APPEND HEADERFILES ExternalCodeEditor_WIN32.h) +else() + list(APPEND CPPFILES ExternalCodeEditor_UNIX.cxx) + list(APPEND HEADERFILES ExternalCodeEditor_UNIX.h) +endif(WIN32) source_group("Header Files" FILES ${HEADERFILES}) # make a group in the IDE for easy access to documentation files -set ( USER_DOC_FILES +set(USER_DOC_FILES Doxyfile documentation/src/index.dox documentation/src/page_introduction.dox @@ -119,7 +125,7 @@ set ( USER_DOC_FILES ) source_group("Documentation: User" FILES ${USER_DOC_FILES}) -set ( DEV_DOC_FILES +set(DEV_DOC_FILES Doxyfile-dev documentation/src-dev/index.dox documentation/src-dev/page_introduction.dox @@ -127,93 +133,61 @@ set ( DEV_DOC_FILES source_group("Documentation: Developer" FILES ${DEV_DOC_FILES}) # Build a local object library to avoid compiling all source files -# for all fluid targets (fluid, fluid-cmd, fluid-shared). This -# library includes everything except the main program (fluid.cxx). +# multiple times for all fluid targets on Windows (fluid + fluid-cmd). -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 -set (FLUID_LIBS fluid-lib fltk fltk_images) # libraries used to link fluid executables - -if (APPLE AND (NOT OPTION_APPLE_X11)) +if(APPLE AND NOT FLTK_BACKEND_X11) # macOS - set (ICON_NAME fluid.icns) - set (ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icons/${ICON_NAME}") - add_executable (fluid MACOSX_BUNDLE fluid.cxx fluid.h ${ICON_PATH}) + set(ICON_NAME fluid.icns) + set(ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/icons/${ICON_NAME}") + add_executable(fluid MACOSX_BUNDLE fluid.cxx ${ICON_PATH}) # create macOS bundle wrapper script - set (WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/fluid") - add_custom_command ( + set(WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/fluid") + add_custom_command( TARGET fluid POST_BUILD COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/../CMake/macOS-bundle-wrapper.in ${WRAPPER} COMMAND chmod u+x,g+x,o+x ${WRAPPER} BYPRODUCTS ${WRAPPER} VERBATIM ) - unset (WRAPPER) + unset(WRAPPER) -else () +else() # 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 -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) +target_link_libraries(fluid PRIVATE fluid-lib) -if (USE_GDIPLUS) # can only be true 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. +# Build the console app on Windows # This is done for all Windows targets, even if cross-compiling. -if (WIN32) - list (APPEND FLUID_TARGETS fluid-cmd) - add_executable (fluid-cmd fluid.cxx fluid.h) - target_link_libraries (fluid-cmd ${FLUID_LIBS}) +if(WIN32) + list(APPEND TARGETS fluid-cmd) + add_executable(fluid-cmd fluid.cxx) + 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) - target_include_directories (fluid-cmd PRIVATE ${PKG_CAIRO_INCLUDE_DIRS}) - if (PKG_CAIRO_LIBRARY_DIRS) - target_link_directories (fluid-cmd PRIVATE ${PKG_CAIRO_LIBRARY_DIRS}) - endif () - endif (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 () +foreach(tgt ${TARGETS}) + add_executable(fltk::${tgt} ALIAS ${tgt}) +endforeach() # 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 # 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. # create bundle - 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 XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.fluid") + 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 XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.fltk.fluid") # 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 (TARGETS fluid DESTINATION "/Applications") + # install(TARGETS fluid DESTINATION "/Applications") # install command line tool - install (PROGRAMS $ DESTINATION ${FLTK_BINDIR}) + install(PROGRAMS $ DESTINATION ${FLTK_BINDIR}) else() # install Fluid GUI and optional commandline tool 'fluid-cmd' (only on Windows) - install (TARGETS ${FLUID_TARGETS} + install(TARGETS ${TARGETS} EXPORT FLTK-Targets RUNTIME DESTINATION ${FLTK_BINDIR} LIBRARY DESTINATION ${FLTK_LIBDIR} ARCHIVE DESTINATION ${FLTK_LIBDIR} ) -endif (APPLE AND (NOT OPTION_APPLE_X11)) +endif(APPLE AND NOT FLTK_BACKEND_X11) # Install desktop files -if (UNIX) - install (FILES fluid.desktop +if(UNIX) + install(FILES fluid.desktop DESTINATION ${FLTK_DATADIR}/applications ) - # Install mime-type file (x-fluid.desktop method is deprecated) - install (FILES fluid.xml + # Install mime-type file(x-fluid.desktop method is deprecated) + install(FILES fluid.xml DESTINATION ${FLTK_DATADIR}/mime/packages ) # Install desktop icons - foreach (icon 32 48 64 128) - install (FILES icons/fluid-${icon}.png + foreach(icon 32 48 64 128) + install(FILES icons/fluid-${icon}.png DESTINATION ${FLTK_DATADIR}/icons/hicolor/${icon}x${icon}/apps RENAME fluid.png ) endforeach() -endif (UNIX) +endif(UNIX) diff --git a/jpeg/CMakeLists.txt b/jpeg/CMakeLists.txt index f65f71636..c1ec4fae8 100644 --- a/jpeg/CMakeLists.txt +++ b/jpeg/CMakeLists.txt @@ -1,7 +1,7 @@ # # 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 # 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. # 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 -set (common_SRCS - jaricom.c jcomapi.c jutils.c jerror.c jmemmgr.c +set(common_SRCS + jaricom.c jcomapi.c jutils.c jerror.c jmemmgr.c ) # compression library object files -set (compression_SRCS - 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 - jcsample.c jchuff.c jcdctmgr.c jfdctfst.c jfdctflt.c - jfdctint.c +set(compression_SRCS + 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 + jcsample.c jchuff.c jcdctmgr.c jfdctfst.c jfdctflt.c + jfdctint.c ) # decompression library object files -set (decompression_SRCS - jdapimin.c jdapistd.c jdarith.c jdtrans.c jdatasrc.c jdmaster.c - jdinput.c jdmarker.c jdhuff.c jdmainct.c jdcoefct.c - jdpostct.c jddctmgr.c jidctfst.c jidctflt.c jidctint.c - jdsample.c jdcolor.c jquant1.c jquant2.c jdmerge.c +set(decompression_SRCS + jdapimin.c jdapistd.c jdarith.c jdtrans.c jdatasrc.c jdmaster.c + jdinput.c jdmarker.c jdhuff.c jdmainct.c jdcoefct.c + jdpostct.c jddctmgr.c jidctfst.c jidctflt.c jidctint.c + jdsample.c jdcolor.c jquant1.c jquant2.c jdmerge.c ) -list (APPEND BUILD_SRCS "${systemdependent_SRCS};${common_SRCS}") -list (APPEND BUILD_SRCS "${compression_SRCS};${decompression_SRCS}") +list(APPEND BUILD_SRCS "${systemdependent_SRCS};${common_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 + $ + $ +) -set (msvc_warnings /wd4267) +# Suppress Visual Studio compiler warnings + +set(msvc_warnings /wd4267) ####################################################################### # 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_compile_options (fltk_jpeg PRIVATE ${msvc_warnings}) -endif (MSVC) +target_include_directories(${target} PUBLIC ${_include_dirs}) + +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) ####################################################################### -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) - target_compile_options (fltk_jpeg_SHARED PRIVATE ${msvc_warnings}) - endif (MSVC) + fl_add_library(fltk_jpeg SHARED "${BUILD_SRCS}") + set(target fltk_jpeg-shared) -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 (FILES jconfig.h jerror.h jmorecfg.h jpeglib.h - fltk_jpeg_prefix.h - DESTINATION ${FLTK_INCLUDEDIR}/FL/images +install(FILES + jconfig.h jerror.h jmorecfg.h jpeglib.h fltk_jpeg_prefix.h + DESTINATION + ${FLTK_INCLUDEDIR}/FL/images ) diff --git a/libdecor/build/fl_libdecor.c b/libdecor/build/fl_libdecor.c index 7a327f151..978b63d48 100644 --- a/libdecor/build/fl_libdecor.c +++ b/libdecor/build/fl_libdecor.c @@ -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 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. 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= - 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) diff --git a/png/CMakeLists.txt b/png/CMakeLists.txt index c61b1a544..e873e9be0 100644 --- a/png/CMakeLists.txt +++ b/png/CMakeLists.txt @@ -1,7 +1,7 @@ # # 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 # the file "COPYING" which should have been included with this file. If this @@ -15,7 +15,7 @@ # # source files for png -set (PNG_SRCS +set(PNG_SRCS png.c pngerror.c pngget.c @@ -36,8 +36,8 @@ set (PNG_SRCS ####################################################################### # 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, -# hence we MUST also link against the bundled ZLIB (see below). -# There's no need to check which ZLIB version to use in this context. +# hence we also link against the bundled ZLIB. Therefore there's +# 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. # This includes all non-macOS platforms. -if (CMAKE_OSX_ARCHITECTURES) - string (REGEX MATCH "arm64" is_arm "${CMAKE_OSX_ARCHITECTURES}") -else () - set (is_arm TRUE) -endif () +if(CMAKE_OSX_ARCHITECTURES) + string(REGEX MATCH "arm64" is_arm "${CMAKE_OSX_ARCHITECTURES}") +else() + set(is_arm TRUE) +endif() -if (is_arm) - LIST (APPEND PNG_SRCS - arm/arm_init.c - arm/filter_neon_intrinsics.c - arm/palette_neon_intrinsics.c +if(is_arm) + list(APPEND PNG_SRCS + arm/arm_init.c + arm/filter_neon_intrinsics.c + arm/palette_neon_intrinsics.c ) -endif () +endif() -unset (is_arm) +unset(is_arm) ####################################################################### -# Build some files on ppc64 -# We compile these files whatever the architecture resulting in void code -# on non-ppc64 architectures. +# Build some files on ppc64. +# We compile these files whatever the architecture resulting in +# void code on non-ppc64 architectures. ####################################################################### -LIST (APPEND PNG_SRCS - powerpc/powerpc_init.c - powerpc/filter_vsx_intrinsics.c +list(APPEND PNG_SRCS + powerpc/powerpc_init.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 the static library ####################################################################### -FL_ADD_LIBRARY (fltk_png STATIC "${PNG_SRCS}") -target_link_libraries (fltk_png PUBLIC fltk_z) +fl_add_library(fltk_png STATIC "${PNG_SRCS}") +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) ####################################################################### -if (OPTION_BUILD_SHARED_LIBS) +if(FLTK_BUILD_SHARED_LIBS) - FL_ADD_LIBRARY (fltk_png SHARED "${PNG_SRCS}") - target_link_libraries (fltk_png_SHARED PUBLIC fltk_z_SHARED) + # ensure to export all symbols for Windows DLL's + 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 (FILES png.h pngconf.h pnglibconf.h pngprefix.h - DESTINATION ${FLTK_INCLUDEDIR}/FL/images +install(FILES png.h pngconf.h pnglibconf.h pngprefix.h + DESTINATION ${FLTK_INCLUDEDIR}/FL/images ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 80d829ce7..757fcac91 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,7 +14,21 @@ # https://www.fltk.org/bugs.php # -set (CPPFILES +# Local macro to check existence of a required file with warning message +# +# In: FILENAME (string): File to search +# Out: WARN (string): *Name* of a variable that is set to true if NOT found +# +# Set variable ${WARN} to FALSE before calling this macro + +macro(fl_check_required_file WARN FILENAME) + if(NOT EXISTS ${FILENAME}) + message("*** Required file not found: ${FILENAME} ***") + set(${WARN} TRUE) + endif() +endmacro(fl_check_required_file WARN FILENAME) + +set(CPPFILES Fl.cxx Fl_Adjuster.cxx Fl_Bitmap.cxx @@ -173,41 +187,40 @@ set (CPPFILES screen_xywh.cxx ) -if (FLTK_HAVE_CAIRO) # OPTION_CAIRO or OPTION_CAIROEXT - list (APPEND CPPFILES Fl_Cairo.cxx) -endif () +if(FLTK_HAVE_CAIRO) # FLTK_OPTION_CAIRO_WINDOW or FLTK_OPTION_CAIRO_EXT + list(APPEND CPPFILES Fl_Cairo.cxx) +endif() # find all header files in source directory -file (GLOB +file(GLOB HEADER_FILES "../FL/*.[hH]" ) # add generated header files in build directory -list (APPEND HEADER_FILES +list(APPEND HEADER_FILES ${CMAKE_CURRENT_BINARY_DIR}/../FL/fl_config.h ${CMAKE_CURRENT_BINARY_DIR}/../config.h ) -set (GL_HEADER_FILES) # FIXME: not (yet?) defined +set(GL_HEADER_FILES) # FIXME: not (yet?) defined -if (FLTK_USE_X11 AND NOT OPTION_PRINT_SUPPORT) - set (PSFILES - ) -else () - set (PSFILES +if(FLTK_USE_X11 AND NOT FLTK_OPTION_PRINT_SUPPORT) + set(PSFILES) +else() + set(PSFILES drivers/PostScript/Fl_PostScript.cxx drivers/PostScript/Fl_PostScript_image.cxx ) -endif (FLTK_USE_X11 AND NOT OPTION_PRINT_SUPPORT) +endif(FLTK_USE_X11 AND NOT FLTK_OPTION_PRINT_SUPPORT) -set (DRIVER_FILES) +set(DRIVER_FILES) -if (FLTK_USE_X11 AND NOT OPTION_USE_WAYLAND) +if(FLTK_USE_X11 AND NOT FLTK_BACKEND_WAYLAND) # X11 (including APPLE with X11) - set (DRIVER_FILES + set(DRIVER_FILES drivers/Posix/Fl_Posix_Printer_Driver.cxx drivers/X11/Fl_X11_Screen_Driver.cxx drivers/X11/Fl_X11_Window_Driver.cxx @@ -224,30 +237,31 @@ if (FLTK_USE_X11 AND NOT OPTION_USE_WAYLAND) Fl_get_key.cxx ) - if (OPTION_USE_KDIALOG) - set (DRIVER_FILES ${DRIVER_FILES} Fl_Native_File_Chooser_Kdialog.cxx + if(FLTK_USE_KDIALOG) + list(APPEND DRIVER_FILES + Fl_Native_File_Chooser_Kdialog.cxx Fl_Native_File_Chooser_Zenity.cxx) - endif (OPTION_USE_KDIALOG) + endif(FLTK_USE_KDIALOG) - if (FLTK_USE_CAIRO) - set (DRIVER_FILES ${DRIVER_FILES} + if(FLTK_USE_CAIRO) + list(APPEND DRIVER_FILES drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.cxx ) - else () - if (USE_XFT) - set (DRIVER_FILES ${DRIVER_FILES} + else() + if(USE_XFT) + list(APPEND DRIVER_FILES drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx ) - if (USE_PANGO) - set (DRIVER_FILES ${DRIVER_FILES} drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx) - endif (USE_PANGO) - else () - set (DRIVER_FILES ${DRIVER_FILES} + if(USE_PANGO) + list(APPEND DRIVER_FILES drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx) + endif(USE_PANGO) + else() + list(APPEND DRIVER_FILES drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx ) - endif (USE_XFT) - set (DRIVER_FILES ${DRIVER_FILES} + endif(USE_XFT) + list(APPEND DRIVER_FILES drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx @@ -256,9 +270,9 @@ if (FLTK_USE_X11 AND NOT OPTION_USE_WAYLAND) drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx ) - endif (FLTK_USE_CAIRO) + endif(FLTK_USE_CAIRO) - set (DRIVER_HEADER_FILES + set(DRIVER_HEADER_FILES drivers/Posix/Fl_Posix_System_Driver.H drivers/X11/Fl_X11_Screen_Driver.H drivers/X11/Fl_X11_Window_Driver.H @@ -268,20 +282,20 @@ if (FLTK_USE_X11 AND NOT OPTION_USE_WAYLAND) drivers/Xlib/Fl_Xlib_Image_Surface_Driver.H drivers/Unix/Fl_Unix_System_Driver.H ) - if (FLTK_USE_CAIRO) - set (DRIVER_HEADER_FILES ${DRIVER_HEADER_FILES} + if(FLTK_USE_CAIRO) + set(DRIVER_HEADER_FILES ${DRIVER_HEADER_FILES} drivers/Cairo/Fl_Cairo_Graphics_Driver.H drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.H ) - elseif (USE_PANGO) - set (DRIVER_HEADER_FILES ${DRIVER_HEADER_FILES} + elseif(USE_PANGO) + set(DRIVER_HEADER_FILES ${DRIVER_HEADER_FILES} drivers/Cairo/Fl_Cairo_Graphics_Driver.H ) - endif (FLTK_USE_CAIRO) + endif(FLTK_USE_CAIRO) -elseif (OPTION_USE_WAYLAND) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${CMAKE_CURRENT_BINARY_DIR}") - set (DRIVER_FILES +elseif(FLTK_BACKEND_WAYLAND) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${CMAKE_CURRENT_BINARY_DIR}") + set(DRIVER_FILES drivers/Posix/Fl_Posix_System_Driver.cxx drivers/Posix/Fl_Posix_Printer_Driver.cxx drivers/Unix/Fl_Unix_Screen_Driver.cxx @@ -296,24 +310,28 @@ elseif (OPTION_USE_WAYLAND) drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx Fl_Native_File_Chooser_FLTK.cxx Fl_Native_File_Chooser_GTK.cxx + ) + + if(FLTK_USE_KDIALOG) + list(APPEND DRIVER_FILES + Fl_Native_File_Chooser_Kdialog.cxx + Fl_Native_File_Chooser_Zenity.cxx) + endif(FLTK_USE_KDIALOG) + + if(FLTK_USE_X11) + list(APPEND DRIVER_FILES + drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.cxx + drivers/X11/Fl_X11_Screen_Driver.cxx + drivers/X11/Fl_X11_Window_Driver.cxx + drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx + drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx + Fl_x.cxx + fl_dnd_x.cxx + Fl_get_key.cxx ) - if (OPTION_USE_KDIALOG) - set (DRIVER_FILES ${DRIVER_FILES} Fl_Native_File_Chooser_Kdialog.cxx - Fl_Native_File_Chooser_Zenity.cxx) - endif (OPTION_USE_KDIALOG) - if (FLTK_USE_X11) - list (APPEND DRIVER_FILES - drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.cxx - drivers/X11/Fl_X11_Screen_Driver.cxx - drivers/X11/Fl_X11_Window_Driver.cxx - drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx - drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx - Fl_x.cxx - fl_dnd_x.cxx - Fl_get_key.cxx - ) - endif (FLTK_USE_X11) - set (DRIVER_HEADER_FILES + endif(FLTK_USE_X11) + + set(DRIVER_HEADER_FILES drivers/Posix/Fl_Posix_System_Driver.H drivers/Wayland/Fl_Wayland_Screen_Driver.H drivers/Wayland/Fl_Wayland_Window_Driver.H @@ -325,11 +343,11 @@ elseif (OPTION_USE_WAYLAND) drivers/Unix/Fl_Unix_System_Driver.H ) -elseif (APPLE) +elseif(APPLE) # Apple Quartz - set (DRIVER_FILES + set(DRIVER_FILES drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx drivers/Quartz/Fl_Quartz_Graphics_Driver_color.cxx drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx @@ -347,7 +365,7 @@ elseif (APPLE) Fl_get_key_mac.cxx drivers/Darwin/fl_macOS_platform_init.cxx ) - set (DRIVER_HEADER_FILES + set(DRIVER_HEADER_FILES drivers/Posix/Fl_Posix_System_Driver.H drivers/Darwin/Fl_Darwin_System_Driver.H drivers/Cocoa/Fl_Cocoa_Screen_Driver.H @@ -359,11 +377,11 @@ elseif (APPLE) drivers/Quartz/Fl_Quartz_Image_Surface_Driver.H ) -else () +else() # Windows (GDI) - set (DRIVER_FILES + set(DRIVER_FILES drivers/WinAPI/Fl_WinAPI_System_Driver.cxx drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx @@ -384,7 +402,7 @@ else () Fl_get_key_win32.cxx drivers/WinAPI/fl_WinAPI_platform_init.cxx ) - set (DRIVER_HEADER_FILES + set(DRIVER_HEADER_FILES drivers/WinAPI/Fl_WinAPI_System_Driver.H drivers/WinAPI/Fl_WinAPI_Screen_Driver.H drivers/WinAPI/Fl_WinAPI_Window_Driver.H @@ -394,19 +412,19 @@ else () drivers/GDI/Fl_GDI_Image_Surface_Driver.H ) -endif (FLTK_USE_X11 AND NOT OPTION_USE_WAYLAND) +endif(FLTK_USE_X11 AND NOT FLTK_BACKEND_WAYLAND) source_group("Header Files" FILES ${HEADER_FILES}) source_group("Driver Source Files" FILES ${DRIVER_FILES}) source_group("Driver Header Files" FILES ${DRIVER_HEADER_FILES}) -set (CPPFILES +set(CPPFILES ${CPPFILES} ${DRIVER_FILES} ) -if (FLTK_BUILD_FORMS) - set (FORMS_FILES +if(FLTK_BUILD_FORMS) + set(FORMS_FILES forms_compatibility.cxx forms_bitmap.cxx forms_free.cxx @@ -414,11 +432,11 @@ if (FLTK_BUILD_FORMS) forms_pixmap.cxx forms_timer.cxx ) -else () - set (FORMS_FILES "") -endif () +else() + set(FORMS_FILES "") +endif() -set (GLCPPFILES +set(GLCPPFILES Fl_Gl_Choice.cxx Fl_Gl_Device_Plugin.cxx Fl_Gl_Overlay.cxx @@ -433,7 +451,7 @@ set (GLCPPFILES glut_font.cxx ) -set (GL_DRIVER_FILES +set(GL_DRIVER_FILES drivers/OpenGL/Fl_OpenGL_Display_Device.cxx # the following file doesn't contribute any code: # drivers/OpenGL/Fl_OpenGL_Graphics_Driver.cxx @@ -444,25 +462,25 @@ set (GL_DRIVER_FILES drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx ) -if (OPTION_USE_WAYLAND) - set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx) - set (GL_DRIVER_HEADER_FILES drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H) - if (FLTK_USE_X11) - list (APPEND GL_DRIVER_FILES drivers/X11/Fl_X11_Gl_Window_Driver.cxx) - list (APPEND GL_DRIVER_HEADER_FILES drivers/X11/Fl_X11_Gl_Window_Driver.H) - endif (FLTK_USE_X11) -elseif (FLTK_USE_X11) - set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/X11/Fl_X11_Gl_Window_Driver.cxx) - set (GL_DRIVER_HEADER_FILES drivers/X11/Fl_X11_Gl_Window_Driver.H) -elseif (APPLE) - set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.mm) - set (GL_DRIVER_HEADER_FILES drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.H) -elseif (WIN32) - set (GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx) - set (GL_DRIVER_HEADER_FILES drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H) -endif (OPTION_USE_WAYLAND) +if(FLTK_BACKEND_WAYLAND) + set(GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx) + set(GL_DRIVER_HEADER_FILES drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H) + if(FLTK_USE_X11) + list(APPEND GL_DRIVER_FILES drivers/X11/Fl_X11_Gl_Window_Driver.cxx) + list(APPEND GL_DRIVER_HEADER_FILES drivers/X11/Fl_X11_Gl_Window_Driver.H) + endif(FLTK_USE_X11) +elseif(FLTK_USE_X11) + set(GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/X11/Fl_X11_Gl_Window_Driver.cxx) + set(GL_DRIVER_HEADER_FILES drivers/X11/Fl_X11_Gl_Window_Driver.H) +elseif(APPLE) + set(GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.mm) + set(GL_DRIVER_HEADER_FILES drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.H) +elseif(WIN32) + set(GL_DRIVER_FILES ${GL_DRIVER_FILES} drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx) + set(GL_DRIVER_HEADER_FILES drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H) +endif(FLTK_BACKEND_WAYLAND) -set (GL_DRIVER_HEADER_FILES ${GL_DRIVER_FILES} +set(GL_DRIVER_HEADER_FILES ${GL_DRIVER_FILES} drivers/OpenGL/Fl_OpenGL_Display_Device.H drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H ) @@ -470,12 +488,12 @@ set (GL_DRIVER_HEADER_FILES ${GL_DRIVER_FILES} source_group("Driver Header Files" FILES ${GL_DRIVER_HEADER_FILES}) source_group("Driver Source Files" FILES ${GL_DRIVER_FILES}) -set (GLCPPFILES +set(GLCPPFILES ${GLCPPFILES} ${GL_DRIVER_FILES} ) -set (IMGCPPFILES +set(IMGCPPFILES fl_images_core.cxx fl_write_png.cxx Fl_BMP_Image.cxx @@ -492,7 +510,7 @@ set (IMGCPPFILES drivers/SVG/Fl_SVG_File_Surface.cxx ) -set (CFILES +set(CFILES flstring.c numericsort.c vsnprintf.c @@ -501,301 +519,306 @@ set (CFILES xutf8/case.c ) -if (FLTK_USE_X11) - list (APPEND CFILES +if(FLTK_USE_X11) + list(APPEND CFILES xutf8/keysym2Ucs.c scandir_posix.c ) - if (NOT USE_XFT) - list (APPEND CFILES + if(NOT USE_XFT) + list(APPEND CFILES xutf8/utf8Utils.c xutf8/utf8Wrap.c # xutf8/utf8Input.c # not used ) - endif (NOT USE_XFT) -endif (FLTK_USE_X11) + endif(NOT USE_XFT) +endif(FLTK_USE_X11) -if (OPTION_USE_WAYLAND) +if(FLTK_BACKEND_WAYLAND) pkg_check_modules(DBUS dbus-1) - set (IDIRS "${CMAKE_CURRENT_BINARY_DIR}") - set (CDEFS "_GNU_SOURCE;HAVE_MEMFD_CREATE;HAVE_MKOSTEMP;HAVE_POSIX_FALLOCATE") - set (COPTS "-fPIC") - if (DBUS_FOUND) - set (CDEFS "${CDEFS};HAS_DBUS") - set (IDIRS "${IDIRS};${DBUS_INCLUDE_DIRS}") - endif (DBUS_FOUND) - if (OPTION_USE_SYSTEM_LIBDECOR) - set (CDEFS "${CDEFS};USE_SYSTEM_LIBDECOR;LIBDECOR_PLUGIN_DIR=${LIBDECOR_PLUGIN_DIR}") - if (GTK_FOUND) - set (CDEFS "${CDEFS};HAVE_GTK") - endif (GTK_FOUND) + set(IDIRS "${CMAKE_CURRENT_BINARY_DIR}") + set(CDEFS "_GNU_SOURCE;HAVE_MEMFD_CREATE;HAVE_MKOSTEMP;HAVE_POSIX_FALLOCATE") + set(COPTS "-fPIC") + if(DBUS_FOUND) + set(CDEFS "${CDEFS};HAS_DBUS") + set(IDIRS "${IDIRS};${DBUS_INCLUDE_DIRS}") + endif(DBUS_FOUND) + if(USE_SYSTEM_LIBDECOR) + set(CDEFS "${CDEFS};USE_SYSTEM_LIBDECOR;LIBDECOR_PLUGIN_DIR=${LIBDECOR_PLUGIN_DIR}") + if(GTK_FOUND) + set(CDEFS "${CDEFS};HAVE_GTK") + endif(GTK_FOUND) set_source_files_properties( - ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/fl_libdecor-plugins.c - ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src/os-compatibility.c - ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src/cursor-settings.c + ${FLTK_SOURCE_DIR}/libdecor/build/fl_libdecor-plugins.c + ${FLTK_SOURCE_DIR}/libdecor/src/os-compatibility.c + ${FLTK_SOURCE_DIR}/libdecor/src/cursor-settings.c PROPERTIES COMPILE_DEFINITIONS "${CDEFS}" INCLUDE_DIRECTORIES "${IDIRS}" COMPILE_OPTIONS "${COPTS}" ) else() - set (IDIRS "${IDIRS};${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src" - "${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src/plugins") - set (CDEFS "${CDEFS};USE_SYSTEM_LIBDECOR=0;LIBDECOR_PLUGIN_API_VERSION=1" + set(IDIRS "${IDIRS};${FLTK_SOURCE_DIR}/libdecor/src" + "${FLTK_SOURCE_DIR}/libdecor/src/plugins") + set(CDEFS "${CDEFS};USE_SYSTEM_LIBDECOR=0;LIBDECOR_PLUGIN_API_VERSION=1" "LIBDECOR_PLUGIN_DIR=\"\"") - if (GTK_FOUND AND OPTION_ALLOW_GTK_PLUGIN) - set (CDEFS "${CDEFS};HAVE_GTK") - endif (GTK_FOUND AND OPTION_ALLOW_GTK_PLUGIN) + if(GTK_FOUND AND FLTK_USE_LIBDECOR_GTK) + set(CDEFS "${CDEFS};HAVE_GTK") + endif(GTK_FOUND AND FLTK_USE_LIBDECOR_GTK) set_source_files_properties( - ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/fl_libdecor.c - ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/fl_libdecor-plugins.c - ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src/os-compatibility.c - ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/src/cursor-settings.c + ${FLTK_SOURCE_DIR}/libdecor/build/fl_libdecor.c + ${FLTK_SOURCE_DIR}/libdecor/build/fl_libdecor-plugins.c + ${FLTK_SOURCE_DIR}/libdecor/src/os-compatibility.c + ${FLTK_SOURCE_DIR}/libdecor/src/cursor-settings.c PROPERTIES COMPILE_DEFINITIONS "${CDEFS}" INCLUDE_DIRECTORIES "${IDIRS}" COMPILE_OPTIONS "${COPTS}" ) - endif (OPTION_USE_SYSTEM_LIBDECOR) + endif(USE_SYSTEM_LIBDECOR) - list (APPEND CFILES + list(APPEND CFILES scandir_posix.c ../libdecor/src/cursor-settings.c ../libdecor/src/os-compatibility.c ../libdecor/build/fl_libdecor-plugins.c + ) + if(FLTK_USE_X11) + list(APPEND CFILES xutf8/keysym2Ucs.c) + endif(FLTK_USE_X11) + if(NOT USE_SYSTEM_LIBDECOR) + list(APPEND CFILES + ../libdecor/build/fl_libdecor.c + ../libdecor/src/plugins/common/libdecor-cairo-blur.c ) - if (FLTK_USE_X11) - list (APPEND CFILES xutf8/keysym2Ucs.c) - endif (FLTK_USE_X11) - if (NOT OPTION_USE_SYSTEM_LIBDECOR) - list (APPEND CFILES - ../libdecor/build/fl_libdecor.c - ../libdecor/src/plugins/common/libdecor-cairo-blur.c - ) - endif (NOT OPTION_USE_SYSTEM_LIBDECOR) -endif (OPTION_USE_WAYLAND) + endif(NOT USE_SYSTEM_LIBDECOR) +endif(FLTK_BACKEND_WAYLAND) -if (WIN32) - list (APPEND CFILES +if(WIN32) + list(APPEND CFILES scandir_win32.c ) -endif (WIN32) +endif(WIN32) -if (APPLE AND (NOT OPTION_APPLE_X11)) - set (MMFILES +if(APPLE AND NOT FLTK_BACKEND_X11) + set(MMFILES Fl_cocoa.mm drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm Fl_Native_File_Chooser_MAC.mm Fl_MacOS_Sys_Menu_Bar.mm ) else() - set (MMFILES - ) -endif (APPLE AND (NOT OPTION_APPLE_X11)) + set(MMFILES) +endif() ####################################################################### # prepare source files for shared and static FLTK libraries -set (SHARED_FILES ${CPPFILES} ${MMFILES} ${CFILES} ${PSFILES}) -list (APPEND SHARED_FILES ${HEADER_FILES} ${DRIVER_HEADER_FILES}) +set(SHARED_FILES ${CPPFILES} ${MMFILES} ${CFILES} ${PSFILES}) +list(APPEND SHARED_FILES ${HEADER_FILES} ${DRIVER_HEADER_FILES}) -set (STATIC_FILES ${SHARED_FILES}) +set(STATIC_FILES ${SHARED_FILES}) # Visual Studio (MSVC) is known to need WinMain() and maybe BORLAND # needs it as well, hence we include it on all Windows platforms. # The GNU compilers (MinGW, MSYS2, Cygwin) disable compilation inside # the source file which is what we finally want and need. -if (WIN32) - list (APPEND STATIC_FILES fl_call_main.c) -endif () +if(WIN32) + list(APPEND STATIC_FILES fl_call_main.c) +endif() ####################################################################### # prepare optional libs for shared and static FLTK libraries -set (OPTIONAL_LIBS) +set(OPTIONAL_LIBS) -if (LIB_dl) - list (APPEND OPTIONAL_LIBS ${LIB_dl}) -endif (LIB_dl) +if(LIB_dl) + list(APPEND OPTIONAL_LIBS ${LIB_dl}) +endif(LIB_dl) -if (USE_THREADS) - list (APPEND OPTIONAL_LIBS ${CMAKE_THREAD_LIBS_INIT}) -endif (USE_THREADS) +if(USE_THREADS) + list(APPEND OPTIONAL_LIBS ${CMAKE_THREAD_LIBS_INIT}) +endif(USE_THREADS) -if (FLTK_USE_X11) - list (APPEND OPTIONAL_LIBS ${X11_LIBRARIES}) -endif (FLTK_USE_X11) +if(FLTK_USE_X11) + list(APPEND OPTIONAL_LIBS ${X11_LIBRARIES}) +endif(FLTK_USE_X11) -if (WIN32) - list (APPEND OPTIONAL_LIBS comctl32 ws2_32) - if (USE_GDIPLUS) - list (APPEND OPTIONAL_LIBS gdiplus) - endif () -endif (WIN32) +if(WIN32) + list(APPEND OPTIONAL_LIBS comctl32 ws2_32) + if(USE_GDIPLUS) + list(APPEND OPTIONAL_LIBS gdiplus) + endif() +endif(WIN32) -if (HAVE_XINERAMA) - list (APPEND OPTIONAL_LIBS ${X11_Xinerama_LIB}) -endif (HAVE_XINERAMA) +if(HAVE_XINERAMA) + list(APPEND OPTIONAL_LIBS ${X11_Xinerama_LIB}) +endif(HAVE_XINERAMA) -if (HAVE_XFIXES) - list (APPEND OPTIONAL_LIBS ${X11_Xfixes_LIB}) -endif (HAVE_XFIXES) +if(HAVE_XFIXES) + list(APPEND OPTIONAL_LIBS ${X11_Xfixes_LIB}) +endif(HAVE_XFIXES) -if (HAVE_XCURSOR) - list (APPEND OPTIONAL_LIBS ${X11_Xcursor_LIB}) -endif (HAVE_XCURSOR) +if(HAVE_XCURSOR) + list(APPEND OPTIONAL_LIBS ${X11_Xcursor_LIB}) +endif(HAVE_XCURSOR) -if (HAVE_XRENDER) - list (APPEND OPTIONAL_LIBS ${X11_Xrender_LIB}) -endif (HAVE_XRENDER) +if(HAVE_XRENDER) + list(APPEND OPTIONAL_LIBS ${X11_Xrender_LIB}) +endif(HAVE_XRENDER) -if (FLTK_HAVE_CAIRO) # OPTION_CAIRO or OPTION_CAIROEXT - list (APPEND OPTIONAL_LIBS ${PKG_CAIRO_LIBRARIES}) -endif() +### if(FLTK_HAVE_CAIRO) # FLTK_OPTION_CAIRO_WINDOW or FLTK_OPTION_CAIRO_EXT or Wayland +### list(APPEND OPTIONAL_LIBS ${PKG_CAIRO_LIBRARIES}) +### endif() -if (USE_PANGO) +if(USE_PANGO) ### FIXME ### This needs to use the PKG_* variables directly - list (APPEND OPTIONAL_LIBS ${HAVE_LIB_PANGO} ${HAVE_LIB_PANGOCAIRO}) - list (APPEND OPTIONAL_LIBS ${HAVE_LIB_CAIRO} ${HAVE_LIB_GOBJECT}) - if (USE_PANGOXFT) - list (APPEND OPTIONAL_LIBS ${HAVE_LIB_PANGOXFT}) - endif (USE_PANGOXFT) -endif (USE_PANGO) + list(APPEND OPTIONAL_LIBS ${HAVE_LIB_PANGO} ${HAVE_LIB_PANGOCAIRO}) + list(APPEND OPTIONAL_LIBS ${HAVE_LIB_CAIRO} ${HAVE_LIB_GOBJECT}) + if(USE_PANGOXFT) + list(APPEND OPTIONAL_LIBS ${HAVE_LIB_PANGOXFT}) + endif(USE_PANGOXFT) +endif(USE_PANGO) -if (USE_XFT) - list (APPEND OPTIONAL_LIBS ${X11_Xft_LIB}) - if (LIB_fontconfig) - list (APPEND OPTIONAL_LIBS ${LIB_fontconfig}) - endif (LIB_fontconfig) -endif (USE_XFT) +if(USE_XFT) + list(APPEND OPTIONAL_LIBS ${X11_Xft_LIB}) + if(LIB_fontconfig) + list(APPEND OPTIONAL_LIBS ${LIB_fontconfig}) + endif(LIB_fontconfig) +endif(USE_XFT) -if (UNIX AND OPTION_USE_WAYLAND) +if(UNIX AND FLTK_BACKEND_WAYLAND) pkg_get_variable(PROTOCOLS wayland-protocols pkgdatadir) # replace "//" with "/" - string (REPLACE "//" "/" PROTOCOLS ${PROTOCOLS}) - if (NOT(EXISTS ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml)) - message(WARNING "Install necessary file ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml") - endif () - if (NOT(EXISTS ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml)) - message(WARNING - "Install necessary file ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml") - endif () - if (NOT(EXISTS ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml)) - message(WARNING - "Install necessary file ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml") - endif () - if (NOT((EXISTS ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml) AND - (EXISTS ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml) AND - (EXISTS ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml))) - message(FATAL_ERROR "*** Terminating: one or more required file(s) missing.") - endif () + string(REPLACE "//" "/" PROTOCOLS ${PROTOCOLS}) + + # The following variable is used for finding required files and to terminate + # the build if one or more files are not found. For user convenience + # the build is terminated after *all* files have been checked. + set(STOP_REQUIRED FALSE) + + set(INFILE ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml) + fl_check_required_file(STOP_REQUIRED ${INFILE}) add_custom_command( OUTPUT xdg-shell-protocol.c xdg-shell-client-protocol.h - COMMAND wayland-scanner private-code ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml xdg-shell-protocol.c - COMMAND wayland-scanner client-header ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml xdg-shell-client-protocol.h - DEPENDS ${PROTOCOLS}/stable/xdg-shell/xdg-shell.xml + COMMAND wayland-scanner private-code ${INFILE} xdg-shell-protocol.c + COMMAND wayland-scanner client-header ${INFILE} xdg-shell-client-protocol.h + DEPENDS ${INFILE} VERBATIM ) - list (APPEND STATIC_FILES "xdg-shell-protocol.c") - list (APPEND SHARED_FILES "xdg-shell-protocol.c") - if (NOT OPTION_USE_SYSTEM_LIBDECOR) + list(APPEND STATIC_FILES "xdg-shell-protocol.c") + list(APPEND SHARED_FILES "xdg-shell-protocol.c") + + if(NOT USE_SYSTEM_LIBDECOR) + set(INFILE ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml) + fl_check_required_file(STOP_REQUIRED ${INFILE}) add_custom_command( OUTPUT xdg-decoration-protocol.c xdg-decoration-client-protocol.h - COMMAND wayland-scanner private-code ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml xdg-decoration-protocol.c - COMMAND wayland-scanner client-header ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml xdg-decoration-client-protocol.h - DEPENDS ${PROTOCOLS}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml + COMMAND wayland-scanner private-code ${INFILE} xdg-decoration-protocol.c + COMMAND wayland-scanner client-header ${INFILE} xdg-decoration-client-protocol.h + DEPENDS ${INFILE} VERBATIM ) - list (APPEND STATIC_FILES "xdg-decoration-protocol.c") - list (APPEND SHARED_FILES "xdg-decoration-protocol.c") - endif (NOT OPTION_USE_SYSTEM_LIBDECOR) + list(APPEND STATIC_FILES "xdg-decoration-protocol.c") + list(APPEND SHARED_FILES "xdg-decoration-protocol.c") + endif(NOT USE_SYSTEM_LIBDECOR) + + set(INFILE ${FLTK_SOURCE_DIR}/libdecor/build/gtk-shell.xml) add_custom_command( - OUTPUT gtk-shell-protocol.c gtk-shell-client-protocol.h - COMMAND wayland-scanner private-code ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/gtk-shell.xml gtk-shell-protocol.c - COMMAND wayland-scanner client-header ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/gtk-shell.xml gtk-shell-client-protocol.h - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../libdecor/build/gtk-shell.xml - VERBATIM - ) - list (APPEND STATIC_FILES "gtk-shell-protocol.c") - list (APPEND SHARED_FILES "gtk-shell-protocol.c") - add_custom_command( - OUTPUT text-input-protocol.c text-input-client-protocol.h - COMMAND wayland-scanner private-code ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml text-input-protocol.c - COMMAND wayland-scanner client-header ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml text-input-client-protocol.h - DEPENDS ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml + OUTPUT gtk-shell-protocol.c gtk-shell-client-protocol.h + COMMAND wayland-scanner private-code ${INFILE} gtk-shell-protocol.c + COMMAND wayland-scanner client-header ${INFILE} gtk-shell-client-protocol.h + DEPENDS ${INFILE} VERBATIM ) - list (APPEND STATIC_FILES "text-input-protocol.c") - list (APPEND SHARED_FILES "text-input-protocol.c") + list(APPEND STATIC_FILES "gtk-shell-protocol.c") + list(APPEND SHARED_FILES "gtk-shell-protocol.c") - if (OPTION_USE_GL) - list (APPEND OPTIONAL_LIBS "-lwayland-egl -lEGL") - endif (OPTION_USE_GL) - if (OPTION_USE_SYSTEM_LIBDECOR) - list (APPEND OPTIONAL_LIBS "-ldecor-0") - elseif (GTK_FOUND AND OPTION_ALLOW_GTK_PLUGIN) - list (APPEND OPTIONAL_LIBS ${GTK_LDFLAGS} ) - endif (OPTION_USE_SYSTEM_LIBDECOR) - list (APPEND OPTIONAL_LIBS "-lwayland-cursor -lwayland-client -lxkbcommon -ldl") - if (DBUS_FOUND) - list (APPEND OPTIONAL_LIBS "${DBUS_LDFLAGS}") - endif (DBUS_FOUND) - if (NOT OPTION_WAYLAND_ONLY) - list (APPEND OPTIONAL_LIBS "-lXcursor -lXrender -lXinerama -lXfixes -lXft -lXext -lX11") - endif (NOT OPTION_WAYLAND_ONLY) - if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux" AND NOT OPTION_BUILD_SHARED_LIBS) - list (APPEND OPTIONAL_LIBS "-no-pie") - endif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux" AND NOT OPTION_BUILD_SHARED_LIBS) -endif (UNIX AND OPTION_USE_WAYLAND) + set(INFILE ${PROTOCOLS}/unstable/text-input/text-input-unstable-v3.xml) + fl_check_required_file(STOP_REQUIRED ${INFILE}) + add_custom_command( + OUTPUT text-input-protocol.c text-input-client-protocol.h + COMMAND wayland-scanner private-code ${INFILE} text-input-protocol.c + COMMAND wayland-scanner client-header ${INFILE} text-input-client-protocol.h + DEPENDS ${INFILE} + VERBATIM + ) + list(APPEND STATIC_FILES "text-input-protocol.c") + list(APPEND SHARED_FILES "text-input-protocol.c") + + if(STOP_REQUIRED) + message(FATAL_ERROR "*** Terminating: one or more required file(s) were not found. ***") + endif() + + if(FLTK_USE_GL) + list(APPEND OPTIONAL_LIBS "-lwayland-egl -lEGL") + endif(FLTK_USE_GL) + if(USE_SYSTEM_LIBDECOR) + list(APPEND OPTIONAL_LIBS "-ldecor-0") + elseif(GTK_FOUND AND FLTK_USE_LIBDECOR_GTK) + list(APPEND OPTIONAL_LIBS ${GTK_LDFLAGS} ) + endif(USE_SYSTEM_LIBDECOR) + list(APPEND OPTIONAL_LIBS "-lwayland-cursor -lwayland-client -lxkbcommon -ldl") + if(DBUS_FOUND) + list(APPEND OPTIONAL_LIBS "${DBUS_LDFLAGS}") + endif(DBUS_FOUND) + if(NOT FLTK_BACKEND_WAYLAND_ONLY) + list(APPEND OPTIONAL_LIBS "-lXcursor -lXrender -lXinerama -lXfixes -lXft -lXext -lX11") + endif(NOT FLTK_BACKEND_WAYLAND_ONLY) + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND NOT FLTK_BUILD_SHARED_LIBS) + list(APPEND OPTIONAL_LIBS "-no-pie") + endif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND NOT FLTK_BUILD_SHARED_LIBS) +endif(UNIX AND FLTK_BACKEND_WAYLAND) ####################################################################### -FL_ADD_LIBRARY (fltk STATIC "${STATIC_FILES}") -target_link_libraries (fltk ${OPTIONAL_LIBS}) +fl_add_library(fltk STATIC "${STATIC_FILES}") +target_link_libraries(fltk PUBLIC ${OPTIONAL_LIBS}) -if (FLTK_HAVE_CAIRO) - target_link_directories (fltk PUBLIC ${PKG_CAIRO_LIBRARY_DIRS}) +### if(FLTK_HAVE_CAIRO OR FLTK_USE_CAIRO) +### target_link_directories(fltk PUBLIC ${PKG_CAIRO_LIBRARY_DIRS}) +### endif() + +####################################################################### + +if(FLTK_BUILD_FORMS) + fl_add_library(fltk_forms STATIC "${FORMS_FILES}") + target_link_libraries(fltk_forms PUBLIC fltk::fltk) endif() ####################################################################### -if (FLTK_BUILD_FORMS) - FL_ADD_LIBRARY (fltk_forms STATIC "${FORMS_FILES}") - target_link_libraries (fltk_forms fltk) -endif () +if(0) + message(STATUS "---------------------- fltk_images -----------------------") + fl_debug_var(FLTK_JPEG_LIBRARIES) + fl_debug_var(FLTK_PNG_LIBRARIES) + fl_debug_var(FLTK_ZLIB_LIBRARIES) + fl_debug_var(FLTK_IMAGE_LIBRARIES) + message(STATUS "---------------------- fltk_images -----------------------") +endif() + +fl_add_library(fltk_images STATIC "${IMGCPPFILES}") +target_link_libraries(fltk_images PUBLIC fltk::fltk) +target_link_libraries(fltk_images PRIVATE ${FLTK_IMAGE_LIBRARIES}) + +### target_link_libraries(fltk_images PUBLIC ${FLTK_JPEG_LIBRARIES}) +### target_link_libraries(fltk_images PUBLIC ${FLTK_PNG_LIBRARIES}) +### target_link_libraries(fltk_images PUBLIC ${FLTK_IMAGE_LIBRARIES}) + +if(FLTK_USE_BUNDLED_JPEG) + target_include_directories(fltk_images PUBLIC + $ + $) +endif() ####################################################################### -FL_ADD_LIBRARY (fltk_images STATIC "${IMGCPPFILES}") -target_link_libraries (fltk_images fltk) - -if (FLTK_USE_BUILTIN_JPEG) - target_link_libraries (fltk_images fltk_jpeg) -else() - target_link_libraries (fltk_images ${FLTK_JPEG_LIBRARIES}) -endif () - -if (FLTK_USE_BUILTIN_ZLIB) - target_link_libraries (fltk_images fltk_z) -else() - target_link_libraries (fltk_images ${FLTK_ZLIB_LIBRARIES}) -endif () - -if (FLTK_USE_BUILTIN_PNG) - target_link_libraries (fltk_images fltk_png) -else() - target_link_libraries (fltk_images ${FLTK_PNG_LIBRARIES}) -endif () - -####################################################################### - -if (OPENGL_FOUND) - FL_ADD_LIBRARY (fltk_gl STATIC "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}") - target_link_libraries (fltk_gl fltk ${OPENGL_LIBRARIES}) -endif (OPENGL_FOUND) +if(FLTK_USE_GL) + fl_add_library(fltk_gl STATIC "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}") + target_link_libraries(fltk_gl PUBLIC ${OPENGL_LIBRARIES} fltk::fltk) +endif(FLTK_USE_GL) ####################################################################### # Build shared libraries (optional) @@ -803,92 +826,108 @@ endif (OPENGL_FOUND) # Shared libraries, part 1: everything except Visual Studio (MSVC) ####################################################################### -if (OPTION_BUILD_SHARED_LIBS AND NOT MSVC) +### fl_debug_var(OPTIONAL_LIBS) - FL_ADD_LIBRARY (fltk SHARED "${SHARED_FILES}") - target_link_libraries (fltk_SHARED ${OPTIONAL_LIBS} ${PKG_CAIRO_LIBRARIES}) - target_link_directories (fltk_SHARED PUBLIC ${PKG_CAIRO_LIBRARY_DIRS}) +if(FLTK_BUILD_SHARED_LIBS AND NOT MSVC) + + fl_add_library(fltk SHARED "${SHARED_FILES}") + target_link_libraries(fltk-shared PUBLIC ${OPTIONAL_LIBS}) + + ### if(FLTK_HAVE_CAIRO OR FLTK_USE_CAIRO) + ### target_link_directories(fltk-shared PUBLIC ${PKG_CAIRO_LIBRARY_DIRS}) + ### endif() ################################################################### - if (FLTK_BUILD_FORMS) - FL_ADD_LIBRARY (fltk_forms SHARED "${FORMS_FILES}") - target_link_libraries (fltk_forms_SHARED fltk_SHARED) - endif () + if(FLTK_BUILD_FORMS) + fl_add_library(fltk_forms SHARED "${FORMS_FILES}") + target_link_libraries(fltk_forms-shared PUBLIC fltk::fltk-shared) + endif() ################################################################### - FL_ADD_LIBRARY (fltk_images SHARED "${IMGCPPFILES}") - target_link_libraries (fltk_images_SHARED fltk_SHARED) + ### fl_debug_var(fltk_images) + ### fl_debug_var(FLTK_JPEG_LIBRARIES) + ### fl_debug_var(FLTK_PNG_LIBRARIES) + ### fl_debug_var(FLTK_ZLIB_LIBRARIES) + ### fl_debug_var(FLTK_IMAGE_LIBRARIES) - if (FLTK_USE_BUILTIN_JPEG) - target_link_libraries (fltk_images_SHARED fltk_jpeg_SHARED) - else() - target_link_libraries (fltk_images_SHARED ${FLTK_JPEG_LIBRARIES}) - endif () + fl_add_library(fltk_images SHARED "${IMGCPPFILES}") + target_link_libraries(fltk_images-shared PUBLIC fltk::fltk-shared) - if (FLTK_USE_BUILTIN_PNG) - target_link_libraries (fltk_images_SHARED fltk_png_SHARED) - else() - target_link_libraries (fltk_images_SHARED ${FLTK_PNG_LIBRARIES}) - endif () + target_link_libraries(fltk_images PUBLIC ${FLTK_JPEG_LIBRARIES}) + target_link_libraries(fltk_images PUBLIC ${FLTK_PNG_LIBRARIES}) + target_link_libraries(fltk_images PUBLIC ${FLTK_IMAGE_LIBRARIES}) - if (FLTK_USE_BUILTIN_ZLIB) - target_link_libraries (fltk_images_SHARED fltk_z_SHARED) + if(FLTK_USE_BUNDLED_JPEG) + ## include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + target_include_directories(fltk_images-shared PUBLIC + $ + # $ + ) + endif() + + if(FLTK_USE_BUNDLED_JPEG) + target_link_libraries(fltk_images-shared PUBLIC fltk::jpeg-shared) else() - target_link_libraries (fltk_images_SHARED ${FLTK_ZLIB_LIBRARIES}) - endif () + target_link_libraries(fltk_images-shared PUBLIC ${JPEG_LIBRARIES}) + endif() + + if(FLTK_USE_BUNDLED_PNG) + target_link_libraries(fltk_images-shared PUBLIC fltk::png-shared) + else() + target_link_libraries(fltk_images-shared PUBLIC ${PNG_LIBRARIES}) + endif() ################################################################### - if (OPENGL_FOUND) - FL_ADD_LIBRARY (fltk_gl SHARED "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}") - target_link_libraries (fltk_gl_SHARED fltk_SHARED ${OPENGL_LIBRARIES}) - endif (OPENGL_FOUND) + if(FLTK_USE_GL) + fl_add_library(fltk_gl SHARED "${GLCPPFILES};${GL_HEADER_FILES};${GL_DRIVER_HEADER_FILES}") + target_link_libraries(fltk_gl-shared PUBLIC ${OPENGL_LIBRARIES} fltk::fltk-shared) + endif(FLTK_USE_GL) -endif (OPTION_BUILD_SHARED_LIBS AND NOT MSVC) +endif(FLTK_BUILD_SHARED_LIBS AND NOT MSVC) ####################################################################### # Shared libraries, part 2: Visual Studio (MSVC) ####################################################################### -# Note to devs: As of June 2020 we can't build separate shared libs (DLL's) -# under Windows with Visual Studio (MSVC) but we can build one big DLL -# that comprises all FLTK and optional PNG, JPEG, and ZLIB libs. +# Note to devs: As of June 2020 we can't build separate shared libs +# (DLL's) under Windows with Visual Studio (MSVC) but we can build one +# big DLL that comprises all FLTK and optional PNG, JPEG, and ZLIB libs. +# The reason is the common DLL linkage (FL_EXPORT) for all libs. This +# might be changed in the future but it would require a lot of work. # AlbrechtS -if (OPTION_BUILD_SHARED_LIBS AND MSVC) +if(FLTK_BUILD_SHARED_LIBS AND MSVC) - set (SOURCES ${SHARED_FILES} ${FORMS_FILES} ${IMGCPPFILES}) - if (OPENGL_FOUND) - list (APPEND SOURCES ${GLCPPFILES} ${GL_HEADER_FILES} ${GL_DRIVER_HEADER_FILES}) - endif (OPENGL_FOUND) + set(SOURCES ${SHARED_FILES} ${FORMS_FILES} ${IMGCPPFILES}) + if(OPENGL_FOUND) + list(APPEND SOURCES ${GLCPPFILES} ${GL_HEADER_FILES} ${GL_DRIVER_HEADER_FILES}) + endif(OPENGL_FOUND) - FL_ADD_LIBRARY (fltk SHARED "${SOURCES}") - target_link_libraries (fltk_SHARED ${OPTIONAL_LIBS}) + fl_add_library(fltk SHARED "${SOURCES}") + target_link_libraries(fltk-shared PUBLIC ${OPTIONAL_LIBS}) - if (FLTK_USE_BUILTIN_JPEG) - target_link_libraries (fltk_SHARED fltk_jpeg) + if(FLTK_USE_BUNDLED_JPEG) + target_link_libraries(fltk-shared PUBLIC fltk::jpeg-shared) else() - target_link_libraries (fltk_SHARED ${FLTK_JPEG_LIBRARIES}) - endif () + target_link_libraries(fltk-shared PUBLIC ${FLTK_JPEG_LIBRARIES}) + endif() - if (FLTK_USE_BUILTIN_PNG) - target_link_libraries (fltk_SHARED fltk_png) + if(FLTK_USE_BUNDLED_PNG) + target_link_libraries(fltk-shared PUBLIC fltk::png-shared) else() - target_link_libraries (fltk_SHARED ${FLTK_PNG_LIBRARIES}) - endif () + target_link_libraries(fltk-shared PUBLIC ${FLTK_PNG_LIBRARIES}) + endif() - if (FLTK_USE_BUILTIN_ZLIB) - target_link_libraries (fltk_SHARED fltk_z) - else() - target_link_libraries (fltk_SHARED ${FLTK_ZLIB_LIBRARIES}) - endif () + if(OPENGL_FOUND) + target_link_libraries(fltk-shared PUBLIC ${OPENGL_LIBRARIES}) + endif(OPENGL_FOUND) - if (OPENGL_FOUND) - target_link_libraries (fltk_SHARED ${OPENGL_LIBRARIES}) - endif (OPENGL_FOUND) - -endif (OPTION_BUILD_SHARED_LIBS AND MSVC) +endif(FLTK_BUILD_SHARED_LIBS AND MSVC) ####################################################################### + +set(FLTK_LIBRARIES ${FLTK_LIBRARIES} PARENT_SCOPE) +set(FLTK_LIBRARIES_SHARED ${FLTK_LIBRARIES_SHARED} PARENT_SCOPE) diff --git a/src/Fl_Cairo.cxx b/src/Fl_Cairo.cxx index 598c8747e..4116bb1ac 100644 --- a/src/Fl_Cairo.cxx +++ b/src/Fl_Cairo.cxx @@ -1,7 +1,7 @@ // // 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 // the file "COPYING" which should have been included with this file. If this @@ -14,13 +14,14 @@ // 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 -// - 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_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 // includes @@ -69,7 +70,7 @@ void Fl_Cairo_State::autolink(bool b) { autolink_ = b; #else 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" "Quitting now."); #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 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. */ 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. - \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. */ cairo_t *Fl::cairo_make_current(void *gc, int W, int H) { diff --git a/src/Fl_Message.cxx b/src/Fl_Message.cxx index a198d5e73..bd11a18f8 100644 --- a/src/Fl_Message.cxx +++ b/src/Fl_Message.cxx @@ -40,7 +40,7 @@ backwards compatibility with FLTK 1.3.x and earlier. \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 diff --git a/src/Fl_Table.cxx b/src/Fl_Table.cxx index 05d96a60f..c145d9010 100644 --- a/src/Fl_Table.cxx +++ b/src/Fl_Table.cxx @@ -22,7 +22,7 @@ // EXPERIMENTAL // 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 // already in FLTK 1.4.x diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7fea98adc..7f6f6a8bc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,7 @@ # # 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 # the file "COPYING" which should have been included with this file. If this @@ -15,45 +15,39 @@ # ####################################################################### -include (../CMake/FLTK-Functions.cmake) -include (../CMake/fl_create_example.cmake) +include(../CMake/FLTK-Functions.cmake) +include(../CMake/fl_create_example.cmake) -set (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../bin/test) -set (TESTFILE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../data) +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../bin/test) +set(TESTFILE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../data) # create data and binary directory to copy scripts and data files -file (MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_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} -) +file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +file(MAKE_DIRECTORY ${TESTFILE_PATH}) ####################################################################### # 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. # These test programs will be built with image and GL libraries. # Leave the variable 'extra_tests' empty to disable extra test programs. -set (extra_tests) +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 @@ -63,119 +57,119 @@ set (extra_tests) # Note: use "${GLDEMO_LIBS}" for their library parameter # or "${GLDEMO_SHARED}" to build with shared FLTK libraries -if (OPENGL_FOUND) - set (GLDEMO_LIBS fltk_gl fltk ${OPENGL_LIBRARIES}) - if (MSVC) - set (GLDEMO_SHARED fltk_SHARED ${OPENGL_LIBRARIES}) - else () - set (GLDEMO_SHARED fltk_gl_SHARED fltk_SHARED ${OPENGL_LIBRARIES}) - endif () -else () - set (GLDEMO_LIBS fltk) - set (GLDEMO_SHARED fltk_SHARED) - endif () +if(OPENGL_FOUND) + set(GLDEMO_LIBS fltk::gl) + if(MSVC) + set(GLDEMO_SHARED fltk::fltk-shared) + else() + set(GLDEMO_SHARED fltk::gl-shared) + endif() +else() + set(GLDEMO_LIBS fltk::fltk) + set(GLDEMO_SHARED fltk::fltk-shared) +endif() # Similar approach for the 'forms' demo (shared lib not supported) -if (FLTK_BUILD_FORMS) - set (FORMS_LIBS fltk_forms) # implies 'fltk' as well -else () - set (FORMS_LIBS fltk) -endif () +if(FLTK_BUILD_FORMS) + set(FORMS_LIBS fltk::forms) +else() + set(FORMS_LIBS fltk::fltk) +endif() ####################################################################### -CREATE_EXAMPLE (adjuster adjuster.cxx fltk) -CREATE_EXAMPLE (arc arc.cxx fltk) -CREATE_EXAMPLE (animated animated.cxx fltk) -CREATE_EXAMPLE (ask ask.cxx fltk) -CREATE_EXAMPLE (bitmap bitmap.cxx fltk) -CREATE_EXAMPLE (blocks "blocks.cxx;blocks.plist;blocks.icns" "fltk;${AUDIOLIBS}") -CREATE_EXAMPLE (boxtype boxtype.cxx fltk) -CREATE_EXAMPLE (browser browser.cxx fltk) -CREATE_EXAMPLE (button button.cxx fltk) -CREATE_EXAMPLE (buttons buttons.cxx fltk) -CREATE_EXAMPLE (checkers "checkers.cxx;checkers_pieces.fl;checkers.icns" "fltk_images;fltk") -CREATE_EXAMPLE (clipboard clipboard.cxx "fltk_images;fltk") -CREATE_EXAMPLE (clock clock.cxx fltk) -CREATE_EXAMPLE (colbrowser colbrowser.cxx fltk) -CREATE_EXAMPLE (color_chooser color_chooser.cxx fltk) -CREATE_EXAMPLE (contrast contrast.cxx fltk) -CREATE_EXAMPLE (coordinates coordinates.cxx fltk) -CREATE_EXAMPLE (cursor cursor.cxx fltk) -CREATE_EXAMPLE (curve curve.cxx fltk) -CREATE_EXAMPLE (demo demo.cxx fltk) -CREATE_EXAMPLE (device device.cxx "fltk_images;fltk") -CREATE_EXAMPLE (doublebuffer doublebuffer.cxx fltk) -CREATE_EXAMPLE (editor "editor.cxx;editor.plist" fltk) -CREATE_EXAMPLE (fast_slow fast_slow.fl fltk) -CREATE_EXAMPLE (file_chooser file_chooser.cxx "fltk_images;fltk") -CREATE_EXAMPLE (flex_demo flex_demo.cxx fltk) -CREATE_EXAMPLE (flex_login flex_login.cxx fltk) -CREATE_EXAMPLE (fltk-versions fltk-versions.cxx fltk) -CREATE_EXAMPLE (fonts fonts.cxx fltk) -CREATE_EXAMPLE (forms forms.cxx "${FORMS_LIBS}") -CREATE_EXAMPLE (fullscreen fullscreen.cxx "${GLDEMO_LIBS}") -CREATE_EXAMPLE (grid_alignment grid_alignment.cxx fltk) -CREATE_EXAMPLE (grid_buttons grid_buttons.cxx fltk) -CREATE_EXAMPLE (grid_dialog grid_dialog.cxx fltk) -CREATE_EXAMPLE (grid_login grid_login.cxx fltk) -CREATE_EXAMPLE (handle_events handle_events.cxx "${GLDEMO_LIBS}") -CREATE_EXAMPLE (hello hello.cxx fltk) -CREATE_EXAMPLE (help_dialog help_dialog.cxx "fltk_images;fltk") -CREATE_EXAMPLE (icon icon.cxx fltk) -CREATE_EXAMPLE (iconize iconize.cxx fltk) -CREATE_EXAMPLE (image image.cxx fltk) -CREATE_EXAMPLE (inactive inactive.fl fltk) -CREATE_EXAMPLE (input input.cxx fltk) -CREATE_EXAMPLE (input_choice input_choice.cxx fltk) -CREATE_EXAMPLE (keyboard "keyboard.cxx;keyboard_ui.fl" fltk) -CREATE_EXAMPLE (label label.cxx fltk) -CREATE_EXAMPLE (line_style line_style.cxx fltk) -CREATE_EXAMPLE (list_visuals list_visuals.cxx fltk) -CREATE_EXAMPLE (mandelbrot "mandelbrot_ui.fl;mandelbrot.cxx" fltk) -CREATE_EXAMPLE (menubar menubar.cxx fltk) -CREATE_EXAMPLE (message message.cxx fltk) -CREATE_EXAMPLE (minimum minimum.cxx fltk) -CREATE_EXAMPLE (native-filechooser native-filechooser.cxx "fltk_images;fltk") -CREATE_EXAMPLE (navigation navigation.cxx fltk) -CREATE_EXAMPLE (output output.cxx fltk) -CREATE_EXAMPLE (overlay overlay.cxx fltk) -CREATE_EXAMPLE (pack pack.cxx fltk) -CREATE_EXAMPLE (pixmap pixmap.cxx "fltk_images;fltk") -CREATE_EXAMPLE (pixmap_browser pixmap_browser.cxx "fltk_images;fltk") -CREATE_EXAMPLE (preferences preferences.fl fltk) -CREATE_EXAMPLE (offscreen offscreen.cxx fltk) -CREATE_EXAMPLE (radio radio.fl fltk) -CREATE_EXAMPLE (resize resize.fl fltk) -CREATE_EXAMPLE (resizebox resizebox.cxx fltk) -CREATE_EXAMPLE (resize-example1 "resize-example1.cxx;resize-arrows.cxx" fltk) -CREATE_EXAMPLE (resize-example2 "resize-example2.cxx;resize-arrows.cxx" fltk) -CREATE_EXAMPLE (resize-example3a "resize-example3a.cxx;resize-arrows.cxx" fltk) -CREATE_EXAMPLE (resize-example3b "resize-example3b.cxx;resize-arrows.cxx" fltk) -CREATE_EXAMPLE (resize-example3c "resize-example3c.cxx;resize-arrows.cxx" fltk) -CREATE_EXAMPLE (resize-example4a "resize-example4a.cxx;resize-arrows.cxx" fltk) -CREATE_EXAMPLE (resize-example4b "resize-example4b.cxx;resize-arrows.cxx" fltk) -CREATE_EXAMPLE (resize-example5a "resize-example5a.cxx;resize-arrows.cxx" fltk) -CREATE_EXAMPLE (resize-example5b "resize-example5b.cxx;resize-arrows.cxx" fltk) -CREATE_EXAMPLE (resize-example5c "resize-example5c.cxx;resize-arrows.cxx" fltk) -CREATE_EXAMPLE (rotated_text rotated_text.cxx fltk) -CREATE_EXAMPLE (scroll scroll.cxx fltk) -CREATE_EXAMPLE (subwindow subwindow.cxx fltk) -CREATE_EXAMPLE (sudoku "sudoku.cxx;sudoku.plist;sudoku.icns;sudoku.rc" "fltk_images;fltk;${AUDIOLIBS}") -CREATE_EXAMPLE (symbols symbols.cxx fltk) -CREATE_EXAMPLE (tabs tabs.fl fltk) -CREATE_EXAMPLE (table table.cxx fltk) -CREATE_EXAMPLE (terminal terminal.fl fltk) -CREATE_EXAMPLE (threads threads.cxx fltk) -CREATE_EXAMPLE (tile tile.cxx fltk) -CREATE_EXAMPLE (tiled_image tiled_image.cxx fltk) -CREATE_EXAMPLE (tree tree.fl fltk) -CREATE_EXAMPLE (twowin twowin.cxx fltk) -CREATE_EXAMPLE (utf8 utf8.cxx fltk) -CREATE_EXAMPLE (valuators valuators.fl fltk) -CREATE_EXAMPLE (windowfocus windowfocus.cxx fltk) -CREATE_EXAMPLE (wizard wizard.cxx fltk) +fl_create_example(adjuster adjuster.cxx fltk::fltk) +fl_create_example(arc arc.cxx fltk::fltk) +fl_create_example(animated animated.cxx fltk::fltk) +fl_create_example(ask ask.cxx fltk::fltk) +fl_create_example(bitmap bitmap.cxx fltk::fltk) +fl_create_example(blocks "blocks.cxx;blocks.plist;blocks.icns" "fltk::fltk;${AUDIOLIBS}") +fl_create_example(boxtype boxtype.cxx fltk::fltk) +fl_create_example(browser browser.cxx fltk::fltk) +fl_create_example(button button.cxx fltk::fltk) +fl_create_example(buttons buttons.cxx fltk::fltk) +fl_create_example(checkers "checkers.cxx;checkers_pieces.fl;checkers.icns" fltk::images) +fl_create_example(clipboard clipboard.cxx fltk::images) +fl_create_example(clock clock.cxx fltk::fltk) +fl_create_example(colbrowser colbrowser.cxx fltk::fltk) +fl_create_example(color_chooser color_chooser.cxx fltk::fltk) +fl_create_example(contrast contrast.cxx fltk::fltk) +fl_create_example(coordinates coordinates.cxx fltk::fltk) +fl_create_example(cursor cursor.cxx fltk::fltk) +fl_create_example(curve curve.cxx fltk::fltk) +fl_create_example(demo demo.cxx fltk::fltk) +fl_create_example(device device.cxx fltk::images) +fl_create_example(doublebuffer doublebuffer.cxx fltk::fltk) +fl_create_example(editor "editor.cxx;editor.plist" fltk::fltk) +fl_create_example(fast_slow fast_slow.fl fltk::fltk) +fl_create_example(file_chooser file_chooser.cxx fltk::images) +fl_create_example(flex_demo flex_demo.cxx fltk::fltk) +fl_create_example(flex_login flex_login.cxx fltk::fltk) +fl_create_example(fltk-versions fltk-versions.cxx fltk::fltk) +fl_create_example(fonts fonts.cxx fltk::fltk) +fl_create_example(forms forms.cxx "${FORMS_LIBS}") +fl_create_example(fullscreen fullscreen.cxx "${GLDEMO_LIBS}") +fl_create_example(grid_alignment grid_alignment.cxx fltk::fltk) +fl_create_example(grid_buttons grid_buttons.cxx fltk::fltk) +fl_create_example(grid_dialog grid_dialog.cxx fltk::fltk) +fl_create_example(grid_login grid_login.cxx fltk::fltk) +fl_create_example(handle_events handle_events.cxx "${GLDEMO_LIBS}") +fl_create_example(hello hello.cxx fltk::fltk) +fl_create_example(help_dialog help_dialog.cxx fltk::images) +fl_create_example(icon icon.cxx fltk::fltk) +fl_create_example(iconize iconize.cxx fltk::fltk) +fl_create_example(image image.cxx fltk::fltk) +fl_create_example(inactive inactive.fl fltk::fltk) +fl_create_example(input input.cxx fltk::fltk) +fl_create_example(input_choice input_choice.cxx fltk::fltk) +fl_create_example(keyboard "keyboard.cxx;keyboard_ui.fl" fltk::fltk) +fl_create_example(label label.cxx fltk::fltk) +fl_create_example(line_style line_style.cxx fltk::fltk) +fl_create_example(list_visuals list_visuals.cxx fltk::fltk) +fl_create_example(mandelbrot "mandelbrot_ui.fl;mandelbrot.cxx" fltk::fltk) +fl_create_example(menubar menubar.cxx fltk::fltk) +fl_create_example(message message.cxx fltk::fltk) +fl_create_example(minimum minimum.cxx fltk::fltk) +fl_create_example(native-filechooser native-filechooser.cxx fltk::images) +fl_create_example(navigation navigation.cxx fltk::fltk) +fl_create_example(output output.cxx fltk::fltk) +fl_create_example(overlay overlay.cxx fltk::fltk) +fl_create_example(pack pack.cxx fltk::fltk) +fl_create_example(pixmap pixmap.cxx fltk::images) +fl_create_example(pixmap_browser pixmap_browser.cxx fltk::images) +fl_create_example(preferences preferences.fl fltk::fltk) +fl_create_example(offscreen offscreen.cxx fltk::fltk) +fl_create_example(radio radio.fl fltk::fltk) +fl_create_example(resize resize.fl fltk::fltk) +fl_create_example(resizebox resizebox.cxx fltk::fltk) +fl_create_example(resize-example1 "resize-example1.cxx;resize-arrows.cxx" fltk::fltk) +fl_create_example(resize-example2 "resize-example2.cxx;resize-arrows.cxx" fltk::fltk) +fl_create_example(resize-example3a "resize-example3a.cxx;resize-arrows.cxx" fltk::fltk) +fl_create_example(resize-example3b "resize-example3b.cxx;resize-arrows.cxx" fltk::fltk) +fl_create_example(resize-example3c "resize-example3c.cxx;resize-arrows.cxx" fltk::fltk) +fl_create_example(resize-example4a "resize-example4a.cxx;resize-arrows.cxx" fltk::fltk) +fl_create_example(resize-example4b "resize-example4b.cxx;resize-arrows.cxx" fltk::fltk) +fl_create_example(resize-example5a "resize-example5a.cxx;resize-arrows.cxx" fltk::fltk) +fl_create_example(resize-example5b "resize-example5b.cxx;resize-arrows.cxx" fltk::fltk) +fl_create_example(resize-example5c "resize-example5c.cxx;resize-arrows.cxx" fltk::fltk) +fl_create_example(rotated_text rotated_text.cxx fltk::fltk) +fl_create_example(scroll scroll.cxx fltk::fltk) +fl_create_example(subwindow subwindow.cxx fltk::fltk) +fl_create_example(sudoku "sudoku.cxx;sudoku.plist;sudoku.icns;sudoku.rc" "fltk::images;${AUDIOLIBS}") +fl_create_example(symbols symbols.cxx fltk::fltk) +fl_create_example(tabs tabs.fl fltk::fltk) +fl_create_example(table table.cxx fltk::fltk) +fl_create_example(terminal terminal.fl fltk::fltk) +fl_create_example(threads threads.cxx fltk::fltk) +fl_create_example(tile tile.cxx fltk::fltk) +fl_create_example(tiled_image tiled_image.cxx fltk::fltk) +fl_create_example(tree tree.fl fltk::fltk) +fl_create_example(twowin twowin.cxx fltk::fltk) +fl_create_example(utf8 utf8.cxx fltk::fltk) +fl_create_example(valuators valuators.fl fltk::fltk) +fl_create_example(windowfocus windowfocus.cxx fltk::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" @@ -197,43 +191,43 @@ SET (UNITTEST_SRCS unittest_schemes.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) -if (extra_tests) - foreach (name ${extra_tests}) - create_example (${name} ${name}.cxx "fltk_images;${GLDEMO_LIBS}") - endforeach () -endif () +if(extra_tests) + foreach(name ${extra_tests}) + fl_create_example(${name} ${name}.cxx "fltk::images;${GLDEMO_LIBS}") + endforeach() +endif() # OpenGL demos. These programs can't be built w/o OpenGL -if (OPENGL_FOUND) - CREATE_EXAMPLE (CubeView "CubeMain.cxx;CubeView.cxx;CubeViewUI.fl" "${GLDEMO_LIBS}") - CREATE_EXAMPLE (cube cube.cxx "${GLDEMO_LIBS}") - CREATE_EXAMPLE (fractals "fractals.cxx;fracviewer.cxx" "${GLDEMO_LIBS}") - CREATE_EXAMPLE (glut_test glut_test.cxx "${GLDEMO_LIBS}") - CREATE_EXAMPLE (glpuzzle glpuzzle.cxx "${GLDEMO_LIBS}") - CREATE_EXAMPLE (gl_overlay gl_overlay.cxx "${GLDEMO_LIBS}") - CREATE_EXAMPLE (shape shape.cxx "${GLDEMO_LIBS}") -endif (OPENGL_FOUND) +if(OPENGL_FOUND) + fl_create_example(CubeView "CubeMain.cxx;CubeView.cxx;CubeViewUI.fl" "${GLDEMO_LIBS}") + fl_create_example(cube cube.cxx "${GLDEMO_LIBS}") + fl_create_example(fractals "fractals.cxx;fracviewer.cxx" "${GLDEMO_LIBS}") + fl_create_example(glut_test glut_test.cxx "${GLDEMO_LIBS}") + fl_create_example(glpuzzle glpuzzle.cxx "${GLDEMO_LIBS}") + fl_create_example(gl_overlay gl_overlay.cxx "${GLDEMO_LIBS}") + fl_create_example(shape shape.cxx "${GLDEMO_LIBS}") +endif(OPENGL_FOUND) # Cairo demo - must also be built w/o Cairo (displays a message box) -if (FLTK_HAVE_CAIRO) - CREATE_EXAMPLE (cairo_test cairo_test.cxx "fltk;cairo") -else () - CREATE_EXAMPLE (cairo_test cairo_test.cxx fltk) -endif (FLTK_HAVE_CAIRO) +# ### if(FLTK_HAVE_CAIRO) +# ### fl_create_example(cairo_test cairo_test.cxx "fltk;cairo") +# ### else() + fl_create_example(cairo_test cairo_test.cxx fltk::fltk) +# ### endif(FLTK_HAVE_CAIRO) # *** EXPERIMENTAL *** # Build some of the demo programs linked against the shared FLTK lib(s). # This is currently pretty complicated and should be improved. # 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 # 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) # 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") - CREATE_EXAMPLE (pixmap_browser-shared pixmap_browser.cxx "fltk_SHARED;CALL_MAIN") - CREATE_EXAMPLE (unittests-shared "${UNITTEST_SRCS}" "${GLDEMO_SHARED};CALL_MAIN") - list (APPEND SHARED_TARGETS hello pixmap_browser unittests) + fl_create_example(hello-shared hello.cxx "CALL_MAIN;fltk::fltk-shared") + fl_create_example(pixmap_browser-shared pixmap_browser.cxx "CALL_MAIN;fltk::fltk-shared") + fl_create_example(unittests-shared "${UNITTEST_SRCS}" "CALL_MAIN;${GLDEMO_SHARED}") - if (OPENGL_FOUND) - CREATE_EXAMPLE (glpuzzle-shared glpuzzle.cxx "fltk_SHARED;CALL_MAIN;${OPENGL_LIBRARIES}") - CREATE_EXAMPLE (shape-shared shape.cxx "fltk_SHARED;CALL_MAIN;${OPENGL_LIBRARIES}") - list (APPEND SHARED_TARGETS glpuzzle shape) - endif (OPENGL_FOUND) + list(APPEND SHARED_TARGETS hello pixmap_browser unittests) + + if(OPENGL_FOUND) + fl_create_example(glpuzzle-shared glpuzzle.cxx "CALL_MAIN;${GLDEMO_SHARED}") + 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 - foreach (tgt ${SHARED_TARGETS}) + foreach(tgt ${SHARED_TARGETS}) target_compile_definitions (${tgt}-shared PRIVATE "FL_DLL") - endforeach () + endforeach() - else () # not MSVC + else() # not MSVC - CREATE_EXAMPLE (hello-shared hello.cxx fltk_SHARED) - CREATE_EXAMPLE (pixmap_browser-shared pixmap_browser.cxx "fltk_images_SHARED") - CREATE_EXAMPLE (unittests-shared "${UNITTEST_SRCS}" "${GLDEMO_SHARED}") + fl_create_example(hello-shared hello.cxx fltk::fltk-shared) + fl_create_example(pixmap_browser-shared pixmap_browser.cxx "fltk::images-shared") + fl_create_example(unittests-shared "${UNITTEST_SRCS}" "${GLDEMO_SHARED}") - if (OPENGL_FOUND) - CREATE_EXAMPLE (glpuzzle-shared glpuzzle.cxx "${GLDEMO_SHARED}") - CREATE_EXAMPLE (shape-shared shape.cxx "${GLDEMO_SHARED}") - endif (OPENGL_FOUND) + if(OPENGL_FOUND) + fl_create_example(glpuzzle-shared glpuzzle.cxx "${GLDEMO_SHARED}") + fl_create_example(shape-shared shape.cxx "${GLDEMO_SHARED}") + endif(OPENGL_FOUND) - if (FLTK_HAVE_CAIRO) - CREATE_EXAMPLE (cairo_test-shared cairo_test.cxx "fltk_SHARED;cairo") - else () - CREATE_EXAMPLE (cairo_test-shared cairo_test.cxx "fltk_SHARED") - endif () + fl_create_example(cairo_test-shared cairo_test.cxx "fltk::fltk-shared") - 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 @@ -296,7 +287,7 @@ endif (OPTION_BUILD_SHARED_LIBS) # copy the required test files -file (COPY +file(COPY demo.menu rgb.txt browser.cxx editor.cxx valuators.fl help_dialog.html DESTINATION ${TESTFILE_PATH} @@ -304,7 +295,7 @@ file (COPY # copy the image directory for help_dialog.html -file (COPY +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/images DESTINATION ${TESTFILE_PATH} ) diff --git a/test/cairo_test.cxx b/test/cairo_test.cxx index ae3d9d736..545e636a2 100644 --- a/test/cairo_test.cxx +++ b/test/cairo_test.cxx @@ -27,7 +27,7 @@ #define DEF_WIDTH 0.03 // 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 // is drawn with Cairo. @@ -39,7 +39,7 @@ // or // 3) showing how to use "cairo extended use". // 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. // If Fl::cairo_autolink_context(true); is called at the beginning // 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( "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; } #endif // (FLTK_HAVE_CAIRO) diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt index 4596a538d..241804a3e 100644 --- a/zlib/CMakeLists.txt +++ b/zlib/CMakeLists.txt @@ -1,7 +1,7 @@ # # 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 # the file "COPYING" which should have been included with this file. If this @@ -16,58 +16,64 @@ # source files for zlib -set (ZLIB_SRCS - adler32.c - compress.c - crc32.c - deflate.c - gzclose.c - gzlib.c - gzread.c - gzwrite.c - inflate.c - infback.c - inftrees.c - inffast.c - trees.c - uncompr.c - zutil.c +set(ZLIB_SRCS + adler32.c + compress.c + crc32.c + deflate.c + gzclose.c + gzlib.c + gzread.c + gzwrite.c + inflate.c + infback.c + inftrees.c + inffast.c + trees.c + uncompr.c + zutil.c ) ####################################################################### # Suppress some Visual Studio compiler warnings -set (msvc_warnings /wd4267 /wd4996) +set(msvc_warnings /wd4267 /wd4996) ####################################################################### # Build the static library ####################################################################### -FL_ADD_LIBRARY (fltk_z STATIC "${ZLIB_SRCS}") +fl_add_library(fltk_z STATIC "${ZLIB_SRCS}") -if (MSVC) - target_compile_options (fltk_z PRIVATE ${msvc_warnings}) -endif (MSVC) +if(MSVC) + target_compile_options(fltk_z PRIVATE ${msvc_warnings}) +endif(MSVC) ####################################################################### # 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) - target_compile_options (fltk_z_SHARED PRIVATE ${msvc_warnings}) - endif (MSVC) + fl_add_library(fltk_z SHARED "${ZLIB_SRCS}") -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 (FILES zconf.h zlib.h zutil.h - DESTINATION ${FLTK_INCLUDEDIR}/FL/images +install(FILES zconf.h zlib.h zutil.h + DESTINATION ${FLTK_INCLUDEDIR}/FL/images )