Files
fltk/CMake/export.cmake
Albrecht Schlosser 53491f2ca0 Remove hardcoded version numbers: part 1
The goal is to change the version number for a new release only in
CMakeLists.txt. This is the first step.

Details:

- CMake/gen_config.cmake: this new file is included to generate the
  header files config.h (private, root directory), and FL/fl_config.h
  (public, can be installed). This file implements also ABI version
  checks (removed from FL/Enumerations.H and with more checks).
  Warnings are issued if the chosen ABI version is invalid.
- CMake/export.cmake: code to generate 'config.h' was moved to
  CMake/gen_config.cmake.
- CMake/options.cmake: set default of FLTK_BUILD_FORMS=OFF + comments
- CMakeLists.txt: move generation of FL/fl_config.h to gen_config.cmake,
  add API and ABI versions to CMake summary,
- FL/Enumerations.H: remove most of the version number details which
  are now included in FL/fl_config.h. This needed also some doxygen
  related changes.
- README.CMake.txt: improve docs of FL_ABI_VERSION and some more.
  Reflect the new default of CMake option FLTK_BUILD_FORMS (OFF).
- documentation/Doxyfile.in: add FL/fl_config.h to file list. This
  file is created in the build tree (and may be "installed").
- fl_config.h.in: add version number details that have been moved here
  from Enumerations.H (used to generate FL/fl_config.h).
2025-05-06 19:25:53 +02:00

151 lines
4.7 KiB
CMake

#
# Export CMake file to build the FLTK project using CMake
#
# Originally written by Michael Surette
#
# Copyright 1998-2025 by Bill Spitzak and others.
#
# This library is free software. Distribution and use rights are outlined in
# the file "COPYING" which should have been included with this file. If this
# file is missing or damaged, see the license at:
#
# https://www.fltk.org/COPYING.php
#
# Please see the following page on how to report bugs and issues:
#
# https://www.fltk.org/bugs.php
#
#######################################################################
# final config and export
#######################################################################
# 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 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
)
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()
# set fltk-options export names (built or not, Windows)
if(FLTK_BUILD_FLTK_OPTIONS)
set(FLTK_OPTIONS_EXPORT fltk-options)
if(WIN32)
list(APPEND FLTK_OPTIONS_EXPORT fltk-options-cmd)
endif()
else()
set(FLTK_OPTIONS_EXPORT)
endif()
# generate FLTK-Targets.cmake for build directory use
set(export_targets
${FLTK_LIBRARIES}
${FLTK_LIBRARIES_SHARED}
${FLUID_EXPORT}
${FLTK_OPTIONS_EXPORT}
)
export(TARGETS
${export_targets}
FILE
${CMAKE_CURRENT_BINARY_DIR}/FLTK-Targets.cmake
NAMESPACE
fltk::)
# generate FLTK-Functions.cmake for build directory use
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 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
${CMAKE_CURRENT_BINARY_DIR}/FLTKConfig.cmake
@ONLY
)
# 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(LIBNAME "${libdir}/libfltk.a")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/fltk-config.in"
"${CMAKE_CURRENT_BINARY_DIR}/fltk-config"
@ONLY
)
# 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)
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"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
endif(CMAKE_VERSION VERSION_LESS 3.19)
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})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/install-symlinks.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/install-symlinks.cmake"
@ONLY)
endif(FLTK_INSTALL_LINKS)