Introduce "Modern CMake" in FLTK
This is a big commit and there are too many changes to list them all. The main changes are: - rename all CMake build options to 'FLTK_*' - export library targets with namespace (prefix) 'fltk::' - standardize shared library target names with suffix '-shared' - set public build properties on libraries for consumers - document library names and aliases in README.CMake.txt - document changes in "Migrating Code from FLTK 1.3 to 1.4" - partial backwards compatibility for old user projects Included but not directly related changes: - fix Windows (Visual Studio) DLL build - add CMake function fl_debug_target() to show target properties - don't build test programs if FLTK is a subproject - internal: reformat CMake code: remove space before '(' Thanks to Matthias and Manolo for their help, testing, and feeback.
This commit is contained in:
parent
1cf6fdfa85
commit
fd5cd80935
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@ -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
|
||||
|
@ -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
|
||||
|
26
CHANGES.txt
26
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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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}'")
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/..>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
### FIXME: why does the simplified else() block not work?
|
||||
### Needs investigation, using 'if(1)' for now...
|
||||
|
||||
if(1)
|
||||
|
||||
foreach(dir ${FLTK_BUILD_INCLUDE_DIRECTORIES})
|
||||
target_include_directories(${TARGET_NAME} PRIVATE
|
||||
$<BUILD_INTERFACE:${dir}>
|
||||
)
|
||||
endforeach()
|
||||
|
||||
else()
|
||||
|
||||
### This generates a wrong string in property INTERFACE_INCLUDE_DIRECTORIES:
|
||||
### ... $<INSTALL_INTERFACE:include>;/git/fltk/modern-cmake/src/$<BUILD_INTERFACE:/usr/include/freetype2; ...
|
||||
### ... --- OK ---------------------^^^^^^^ WRONG ^^^^^^^^^^^^^^-------- would be OK -------------------- ...
|
||||
### End of string: ';/usr/include/libpng16' (WRONG: missing '>')
|
||||
### I don't see anything wrong with this statement though but
|
||||
### maybe I'm missing something. Albrecht, Jan 22 2024
|
||||
|
||||
target_include_directories(${TARGET_NAME} PRIVATE
|
||||
$<BUILD_INTERFACE:${FLTK_BUILD_INCLUDE_DIRECTORIES}>
|
||||
)
|
||||
fl_debug_target(${TARGET_NAME})
|
||||
|
||||
endif()
|
||||
|
||||
target_link_directories(${TARGET_NAME} PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../lib>
|
||||
$<INSTALL_INTERFACE:lib>
|
||||
)
|
||||
|
||||
if(APPLE AND NOT FLTK_BACKEND_X11)
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC "-framework Cocoa")
|
||||
endif()
|
||||
|
||||
# we must link fltk with cairo if Cairo or Wayland is enabled (or both)
|
||||
if(FLTK_HAVE_CAIRO OR FLTK_USE_CAIRO)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${PKG_CAIRO_INCLUDE_DIRS})
|
||||
target_link_directories(${TARGET_NAME} PUBLIC ${PKG_CAIRO_LIBRARY_DIRS})
|
||||
endif()
|
||||
|
||||
endif(LIBNAME STREQUAL "fltk")
|
||||
|
||||
# Set additional target properties for static libraries
|
||||
|
||||
if(LIBTYPE STREQUAL "STATIC")
|
||||
set_target_properties(${TARGET_NAME}
|
||||
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)
|
||||
|
@ -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 (< |