summaryrefslogtreecommitdiff
path: root/CMake
diff options
context:
space:
mode:
Diffstat (limited to 'CMake')
-rw-r--r--CMake/export.cmake29
-rw-r--r--CMake/gen_config.cmake109
-rw-r--r--CMake/options.cmake10
3 files changed, 116 insertions, 32 deletions
diff --git a/CMake/export.cmake b/CMake/export.cmake
index 642be6762..407b24933 100644
--- a/CMake/export.cmake
+++ b/CMake/export.cmake
@@ -1,9 +1,9 @@
#
-# Export CMake file to build the FLTK project using CMake (www.cmake.org)
+# Export CMake file to build the FLTK project using CMake
#
# Originally written by Michael Surette
#
-# Copyright 1998-2024 by Bill Spitzak and others.
+# 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
@@ -136,31 +136,6 @@ else(CMAKE_VERSION VERSION_LESS 3.19)
WORLD_READ WORLD_EXECUTE)
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_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 config.h.in)
-set(CONFIG_H config.h)
-
-# generate config.h
-
-configure_file(
- "${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_H_IN}"
- "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_H}"
- @ONLY
-)
-
if(FLTK_INSTALL_LINKS)
# Set PREFIX_INCLUDE to the proper value.
if(IS_ABSOLUTE ${FLTK_INCLUDEDIR})
diff --git a/CMake/gen_config.cmake b/CMake/gen_config.cmake
new file mode 100644
index 000000000..719b804d2
--- /dev/null
+++ b/CMake/gen_config.cmake
@@ -0,0 +1,109 @@
+#
+# Generate version numbers and configure header files
+#
+# 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
+#
+
+#######################################################################
+# Calculate limits and check FL_ABI_VERSION syntax
+#######################################################################
+
+# Initialize FL_ABI_VERSION
+set(FL_ABI_VERSION "${FLTK_ABI_VERSION}")
+
+# These are the limits (min/max) FL_ABI_VERSION is allowed to have
+math(EXPR abi_version_min "${FLTK_VERSION_MAJOR} * 10000 + ${FLTK_VERSION_MINOR} * 100")
+math(EXPR abi_version_max "${abi_version_min} + ${FLTK_VERSION_PATCH} + 1")
+
+if(FL_ABI_VERSION STREQUAL "")
+
+ # no version set, silently use default
+ set(FL_ABI_VERSION "${abi_version_min}")
+
+else()
+
+ # check syntax of reuested ABI version (five digits)
+
+ string(REGEX MATCH "[1-9][0-9][0-9][0-9][0-9]" reg_match "${FL_ABI_VERSION}")
+ if(NOT reg_match STREQUAL "${FL_ABI_VERSION}")
+ message(STATUS "FLTK_ABI_VERSION \"${FLTK_ABI_VERSION}\" is invalid. Using default = ${abi_version_min}")
+ set(FL_ABI_VERSION "${abi_version_min}")
+ endif()
+
+ # check minor version (first three numbers must match)
+
+ string(SUBSTRING "${abi_version_min}" 0 3 abi_version_minor)
+ string(SUBSTRING "${FL_ABI_VERSION}" 0 3 abi_version_temp)
+
+ if(NOT abi_version_temp STREQUAL ${abi_version_minor})
+ set(FL_ABI_VERSION "${abi_version_min}")
+ message(STATUS "FLTK_ABI_VERSION \"${FLTK_ABI_VERSION}\" doesn't match minor version. Using default = ${abi_version_min}")
+ set(FL_ABI_VERSION "${abi_version_min}")
+ endif()
+
+endif()
+
+if(FL_ABI_VERSION STRLESS ${abi_version_min})
+ # should never happen
+ set(FL_ABI_VERSION "${abi_version_min}")
+elseif(FL_ABI_VERSION STRGREATER ${abi_version_max})
+ # accept w/o warning
+ set(FL_ABI_VERSION "${abi_version_max}")
+endif()
+
+# reset all temporary variables
+
+unset(abi_version_min)
+unset(abi_version_max)
+unset(abi_version_minor)
+unset(abi_version_temp)
+unset(reg_match)
+
+#######################################################################
+# configure the header file "FL/fl_config.h" in the build tree
+#######################################################################
+
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/fl_config.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/FL/fl_config.h
+ @ONLY
+)
+
+#######################################################################
+# generate the header file "config.h" in the build tree
+#######################################################################
+
+# 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_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 config.h.in)
+set(CONFIG_H config.h)
+
+# generate the header file
+
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_H_IN}"
+ "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_H}"
+ @ONLY
+)
diff --git a/CMake/options.cmake b/CMake/options.cmake
index 8411b92ec..3ff6d06f5 100644
--- a/CMake/options.cmake
+++ b/CMake/options.cmake
@@ -75,9 +75,9 @@ add_definitions(${FLTK_ARCHFLAGS})
#######################################################################
set(FLTK_ABI_VERSION ""
CACHE STRING
- "FLTK ABI Version FL_ABI_VERSION: 1xxyy for 1.x.y (xx,yy with leading zero)"
+ "FLTK ABI Version FL_ABI_VERSION: 1xxyy for 1.x.y (xx,yy with leading zeroes)"
)
-set(FL_ABI_VERSION ${FLTK_ABI_VERSION})
+# see also CMake/gen_config.cmake
#######################################################################
# Select MSVC (Visual Studio) Runtime: DLL (/MDx) or static (/MTx)
@@ -201,8 +201,8 @@ if(FLTK_USE_BUNDLED_PNG)
# 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.x (may be changed in 1.5.0)
+ # Note: config.h is generated by CMake (or configure in 1.4), hence
+ # we support it in 1.4.x, but this may be changed in 1.5.0. (?)
set(HAVE_PNG_H 1)
set(HAVE_PNG_GET_VALID 1)
@@ -439,7 +439,7 @@ option(FLTK_BUILD_SHARED_LIBS
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_FORMS "Build forms compatibility library" OFF)
option(FLTK_BUILD_FLUID "Build FLUID" ON)
option(FLTK_BUILD_FLTK_OPTIONS "Build fltk-options" ON)
option(FLTK_BUILD_EXAMPLES "Build example programs" OFF)