2014-02-09 22:41:29 +04:00
|
|
|
#
|
|
|
|
# CMakeLists.txt to build the FLTK project using CMake (www.cmake.org)
|
2022-03-13 23:47:26 +03:00
|
|
|
# Originally written by Michael Surette
|
2014-02-09 22:41:29 +04:00
|
|
|
#
|
2022-03-13 23:47:26 +03:00
|
|
|
# Copyright 1998-2022 by Bill Spitzak and others.
|
2014-02-09 22:41:29 +04:00
|
|
|
#
|
|
|
|
# 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:
|
|
|
|
#
|
2020-07-01 19:03:10 +03:00
|
|
|
# https://www.fltk.org/COPYING.php
|
2014-02-09 22:41:29 +04:00
|
|
|
#
|
2020-07-01 19:03:10 +03:00
|
|
|
# Please see the following page on how to report bugs and issues:
|
2014-02-09 22:41:29 +04:00
|
|
|
#
|
2020-07-01 19:03:10 +03:00
|
|
|
# https://www.fltk.org/bugs.php
|
2014-02-09 22:41:29 +04:00
|
|
|
#
|
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
# basic setup
|
|
|
|
#######################################################################
|
2017-06-29 20:51:27 +03:00
|
|
|
|
2020-06-13 16:19:27 +03:00
|
|
|
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)
|
2014-02-09 22:41:29 +04:00
|
|
|
|
|
|
|
# Search for modules in the FLTK source dir first
|
2020-06-13 16:19:27 +03:00
|
|
|
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
|
2014-02-09 22:41:29 +04:00
|
|
|
|
2020-06-13 16:19:27 +03:00
|
|
|
set (FLTK_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
include_directories (${FLTK_INCLUDE_DIRS})
|
2014-02-09 22:41:29 +04:00
|
|
|
|
2018-01-10 23:49:03 +03:00
|
|
|
# Remember root of FLTK source directory in case we're in a subdirectory.
|
|
|
|
# Used for instance to find the source directory for doxygen docs
|
2020-06-13 16:19:27 +03:00
|
|
|
set (FLTK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
|
|
|
# Setup install locations (requires CMake 2.8.4)
|
|
|
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
|
|
|
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
|
|
|
|
"Library install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute 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
|
|
|
|
"Non-arch data install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute 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
|
|
|
|
"Non-arch doc install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
|
2015-02-16 17:30:27 +03:00
|
|
|
|
|
|
|
|
2022-03-25 17:02:53 +03:00
|
|
|
#######################################################################
|
|
|
|
# initialize internally used variables
|
|
|
|
# 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 "")
|
|
|
|
|
2014-02-09 22:41:29 +04:00
|
|
|
#######################################################################
|
|
|
|
# platform dependent information
|
|
|
|
#######################################################################
|
|
|
|
|
2015-04-10 18:50:59 +03:00
|
|
|
# set where config files go
|
2020-06-13 16:19:27 +03:00
|
|
|
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)
|
2014-09-27 04:41:06 +04:00
|
|
|
|
2014-02-09 22:41:29 +04:00
|
|
|
include(TestBigEndian)
|
|
|
|
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
|
|
|
|
|
2021-12-03 22:29:20 +03:00
|
|
|
if (CMAKE_GENERATOR MATCHES "Xcode")
|
2022-03-13 23:47:26 +03:00
|
|
|
if (NOT (CMAKE_VERSION VERSION_LESS 3.9)) # CMake 3.9 and up
|
2021-12-03 22:29:20 +03:00
|
|
|
# Tell Xcode to regenerate scheme information automatically whenever the
|
2022-03-13 23:47:26 +03:00
|
|
|
# CMake configuration changes without asking the user
|
2021-12-03 22:29:20 +03:00
|
|
|
set (CMAKE_XCODE_GENERATE_SCHEME 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-06-13 16:19:27 +03:00
|
|
|
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)
|
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U__APPLE__")
|
|
|
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U__APPLE__")
|
2020-08-27 18:49:10 +03:00
|
|
|
if (NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0)) # a.k.a. macOS version ≥ 10.13
|
2020-06-13 16:19:27 +03:00
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCPP_HAS_THREAD_API_PTHREAD")
|
2020-08-27 18:49:10 +03:00
|
|
|
endif (NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0))
|
2020-06-13 16:19:27 +03:00
|
|
|
else ()
|
|
|
|
set (__APPLE_QUARTZ__ 1)
|
|
|
|
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 (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)
|
|
|
|
add_definitions (-DWIN32_LEAN_AND_MEAN)
|
|
|
|
add_definitions (-D_CRT_SECURE_NO_WARNINGS)
|
2022-03-26 20:13:47 +03:00
|
|
|
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 ()
|
2020-06-13 16:19:27 +03:00
|
|
|
set (BORDER_WIDTH 2)
|
|
|
|
endif (MSVC)
|
|
|
|
if (MINGW AND EXISTS /mingw)
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH /mingw)
|
|
|
|
endif (MINGW AND EXISTS /mingw)
|
|
|
|
endif (WIN32)
|
2014-02-09 22:41:29 +04:00
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
# size of ints
|
|
|
|
include(CheckTypeSize)
|
|
|
|
|
|
|
|
CHECK_TYPE_SIZE(short SIZEOF_SHORT)
|
|
|
|
CHECK_TYPE_SIZE(int SIZEOF_INT)
|
|
|
|
CHECK_TYPE_SIZE(long SIZEOF_LONG)
|
2020-06-13 16:19:27 +03:00
|
|
|
CHECK_TYPE_SIZE("long long" HAVE_LONG_LONG)
|
|
|
|
|
|
|
|
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 "^8$")
|
|
|
|
set (U64 "unsigned")
|
|
|
|
else ()
|
|
|
|
if (${SIZEOF_LONG} MATCHES "^8$")
|
|
|
|
set (U64 "unsigned long")
|
|
|
|
endif (${SIZEOF_LONG} MATCHES "^8$")
|
|
|
|
endif (${SIZEOF_INT} MATCHES "^8$")
|