Add CMake compatibility functions and macros
CMake/compatibility.cmake: define functions and macros to be used if a particular CMake functionality requires a higher CMake version than FLTK's minimum CMake version, see 'cmake_minimum_required(...)' in the root CMakeLists.txt. Note: target_link_directories() is available since CMake 3.13
This commit is contained in:
parent
ded0253bb7
commit
410a01c6db
74
CMake/compatibility.cmake
Normal file
74
CMake/compatibility.cmake
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#
|
||||||
|
# CMake compatibility functions and macros for the Fast Light Tool Kit (FLTK)
|
||||||
|
#
|
||||||
|
# Copyright 1998-2021 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
|
||||||
|
#
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# The functions (and macros) in this file are defined to simplify CMake
|
||||||
|
# code that uses features not available in all supported CMake versions.
|
||||||
|
# Functions should be preferred (rather than macros) because functions
|
||||||
|
# have their own variable scope.
|
||||||
|
#
|
||||||
|
# The function must apply a workaround for older versions or not add code
|
||||||
|
# at all if there is no suitable workaround.
|
||||||
|
#
|
||||||
|
# The functions included here may be removed (with according changes of the
|
||||||
|
# calling code) or the workaround code may be removed from the implementation
|
||||||
|
# after cmake_minimum_required() has been raised to a version number greater
|
||||||
|
# than or equal to the required version.
|
||||||
|
#
|
||||||
|
# Current cmake_minimum_required() version: see <fltk-root>/CMakeLists.txt
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# function fl_target_link_directories - add link directories to target
|
||||||
|
#
|
||||||
|
# Requires CMake version: 3.13
|
||||||
|
# https://cmake.org/cmake/help/latest/command/target_link_directories.html
|
||||||
|
#
|
||||||
|
# Input:
|
||||||
|
#
|
||||||
|
# - TARGET: target to add link directories to, e.g. fluid
|
||||||
|
#
|
||||||
|
# - SCOPE: one of <INTERFACE|PUBLIC|PRIVATE> (see CMake docs)
|
||||||
|
#
|
||||||
|
# - DIRS: quoted list of link directories (separated by ';')
|
||||||
|
#
|
||||||
|
# The 'DIRS' argument takes a standard CMake list of directories, i.e. the
|
||||||
|
# individual members must be separated by ';'. The list may be empty ("").
|
||||||
|
# If more than one directory is to be added or if the list of directories
|
||||||
|
# can be empty it *must* be quoted. This function may be called more than
|
||||||
|
# once. Each invocation adds zero, one, or more directories.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
function (fl_target_link_directories TARGET SCOPE DIRS)
|
||||||
|
|
||||||
|
if (CMAKE_VERSION VERSION_LESS "3.13")
|
||||||
|
link_directories (${DIRS})
|
||||||
|
else ()
|
||||||
|
target_link_directories (${TARGET} ${SCOPE} ${DIRS})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
endfunction () # fl_target_link_directories()
|
@ -117,15 +117,12 @@ macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
|
|||||||
target_link_libraries (${TARGET_NAME} ${LIBRARIES})
|
target_link_libraries (${TARGET_NAME} ${LIBRARIES})
|
||||||
|
|
||||||
if (FLTK_HAVE_CAIRO)
|
if (FLTK_HAVE_CAIRO)
|
||||||
if (CMAKE_VERSION VERSION_LESS "3.13")
|
fl_target_link_directories (${TARGET_NAME} PRIVATE "${PKG_CAIRO_LIBRARY_DIRS}")
|
||||||
link_directories (${PKG_CAIRO_LIBRARY_DIRS})
|
endif ()
|
||||||
else()
|
|
||||||
target_link_directories (${TARGET_NAME} PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
|
|
||||||
endif()
|
|
||||||
endif (FLTK_HAVE_CAIRO)
|
|
||||||
if (USE_GDIPLUS) # can only be true on Windows
|
if (USE_GDIPLUS) # can only be true on Windows
|
||||||
target_link_libraries (${TARGET_NAME} gdiplus)
|
target_link_libraries (${TARGET_NAME} gdiplus)
|
||||||
endif (USE_GDIPLUS)
|
endif ()
|
||||||
|
|
||||||
if (MAC_BUNDLE)
|
if (MAC_BUNDLE)
|
||||||
if (PLIST)
|
if (PLIST)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#
|
#
|
||||||
# Main CMakeLists.txt to build the FLTK project using CMake (www.cmake.org)
|
# Main CMakeLists.txt to build the FLTK project using CMake (www.cmake.org)
|
||||||
# Written by Michael Surette
|
# Originally written by Michael Surette
|
||||||
#
|
#
|
||||||
# Copyright 1998-2020 by Bill Spitzak and others.
|
# Copyright 1998-2021 by Bill Spitzak and others.
|
||||||
#
|
#
|
||||||
# This library is free software. Distribution and use rights are outlined in
|
# This library is free software. Distribution and use rights are outlined in
|
||||||
# the file "COPYING" which should have been included with this file. If this
|
# the file "COPYING" which should have been included with this file. If this
|
||||||
@ -50,18 +50,20 @@ set (OpenGL_GL_PREFERENCE LEGACY)
|
|||||||
project (FLTK VERSION 1.4.0)
|
project (FLTK VERSION 1.4.0)
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# include macro definitions of generally used macros
|
# include macro and function definitions for general usage
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
include (CMake/fl_debug_var.cmake)
|
include (CMake/fl_debug_var.cmake)
|
||||||
include (CMake/fl_add_library.cmake)
|
include (CMake/fl_add_library.cmake)
|
||||||
|
include (CMake/compatibility.cmake)
|
||||||
|
|
||||||
if (false)
|
if (0)
|
||||||
fl_debug_var (FLTK_VERSION_MAJOR)
|
fl_debug_var (FLTK_VERSION_MAJOR)
|
||||||
fl_debug_var (FLTK_VERSION_MINOR)
|
fl_debug_var (FLTK_VERSION_MINOR)
|
||||||
fl_debug_var (FLTK_VERSION_PATCH)
|
fl_debug_var (FLTK_VERSION_PATCH)
|
||||||
fl_debug_var (FLTK_VERSION)
|
fl_debug_var (FLTK_VERSION)
|
||||||
endif (false)
|
fl_debug_var (CMAKE_VERSION)
|
||||||
|
endif ()
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# basic setup
|
# basic setup
|
||||||
|
@ -15,12 +15,7 @@ if (OPTION_BUILD_SHARED_LIBS)
|
|||||||
|
|
||||||
FL_ADD_LIBRARY (fltk_cairo SHARED "${cairo_SRCS}")
|
FL_ADD_LIBRARY (fltk_cairo SHARED "${cairo_SRCS}")
|
||||||
target_link_libraries (fltk_cairo_SHARED fltk_SHARED ${PKG_CAIRO_LIBRARIES})
|
target_link_libraries (fltk_cairo_SHARED fltk_SHARED ${PKG_CAIRO_LIBRARIES})
|
||||||
|
fl_target_link_directories (fltk_cairo_SHARED PRIVATE "${PKG_CAIRO_LIBRARY_DIRS}")
|
||||||
if (CMAKE_VERSION VERSION_LESS "3.13")
|
|
||||||
link_directories (${PKG_CAIRO_LIBRARY_DIRS})
|
|
||||||
else()
|
|
||||||
target_link_directories (fltk_cairo_SHARED PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
endif (OPTION_BUILD_SHARED_LIBS)
|
endif (OPTION_BUILD_SHARED_LIBS)
|
||||||
|
|
||||||
|
@ -71,11 +71,7 @@ endif (APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL))
|
|||||||
|
|
||||||
target_link_libraries (fluid fltk fltk_images fltk_forms)
|
target_link_libraries (fluid fltk fltk_images fltk_forms)
|
||||||
if (FLTK_HAVE_CAIRO)
|
if (FLTK_HAVE_CAIRO)
|
||||||
if (CMAKE_VERSION VERSION_LESS "3.13")
|
fl_target_link_directories (fluid PRIVATE "${PKG_CAIRO_LIBRARY_DIRS}")
|
||||||
link_directories (${PKG_CAIRO_LIBRARY_DIRS})
|
|
||||||
else()
|
|
||||||
target_link_directories (fluid PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
|
|
||||||
endif()
|
|
||||||
endif (FLTK_HAVE_CAIRO)
|
endif (FLTK_HAVE_CAIRO)
|
||||||
|
|
||||||
if (USE_GDIPLUS) # can only be true on Windows
|
if (USE_GDIPLUS) # can only be true on Windows
|
||||||
|
Loading…
Reference in New Issue
Block a user