CMake: Fix fltk-config for Windows and Unix/Linux.

This update ought to work with

  fltk-config [--use-images] [--use-gl] --compile <c source file>

on both Windows and Unix/Linux when built with CMake. It was tested
under Windows and Linux using fltk-config directly from the build tree,
but it should work as well after installation.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12686 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2018-02-23 19:41:52 +00:00
parent a0863e393a
commit 7d1488507d
9 changed files with 337 additions and 164 deletions

View File

@ -71,21 +71,17 @@ set(srcdir ".")
set(LIBNAME "${libdir}/libfltk.a")
if (WIN32)
set (LDFLAGS "-mwindows")
set (LIBS "-lole32 -luuid -lcomctl32")
endif ()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/fltk-config.in"
"${CMAKE_CURRENT_BINARY_DIR}/fltk-config"
@ONLY
)
if(UNIX)
execute_process(COMMAND chmod 755 fltk-config
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
endif(UNIX)
if (UNIX)
execute_process(COMMAND chmod 755 fltk-config
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
endif (UNIX)
# prepare some variables for config.h

View File

@ -84,11 +84,6 @@ set(srcdir ".")
set(LIBNAME "${libdir}/libfltk.a")
if (WIN32)
set (LDFLAGS "-mwindows")
set (LIBS "-lole32 -luuid -lcomctl32")
endif ()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/fltk-config.in"
"${CMAKE_CURRENT_BINARY_DIR}/bin/fltk-config"

View File

@ -17,6 +17,22 @@
# http://www.fltk.org/str.php
#
set (DEBUG_OPTIONS_CMAKE 0)
if (DEBUG_OPTIONS_CMAKE)
message (STATUS "[** options.cmake **]")
fl_debug_var (WIN32)
fl_debug_var (FLTK_LDLIBS)
endif (DEBUG_OPTIONS_CMAKE)
#######################################################################
# *temporary* option to modify header searches
#######################################################################
option(USE_FIND_FILE
"Deprecated: use find_file() for header searches"
OFF
)
mark_as_advanced(USE_FIND_FILE)
#######################################################################
# options
#######################################################################
@ -42,10 +58,14 @@ set(FL_ABI_VERSION ${OPTION_ABI_VERSION})
#######################################################################
#######################################################################
if(UNIX)
if (UNIX)
option(OPTION_CREATE_LINKS "create backwards compatibility links" OFF)
list(APPEND FLTK_LDLIBS -lm)
endif(UNIX)
endif (UNIX)
if (WIN32)
list(APPEND FLTK_LDLIBS -lole32 -luuid -lcomctl32)
endif (WIN32)
#######################################################################
## Add a TEMPORARY OPTION to enable high-DPI support under Windows.
@ -177,21 +197,31 @@ if(OPTION_USE_GL)
endif(OPTION_APPLE_X11)
endif(OPTION_USE_GL)
if(OPENGL_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${OPENGL_INCLUDE_DIR}/GL)
set(GLLIB "-lGLU -lGL")
if (DEBUG_OPTIONS_CMAKE)
fl_debug_var(OPENGL_FOUND)
fl_debug_var(OPENGL_INCLUDE_DIR)
fl_debug_var(OPENGL_LIBRARIES)
endif (DEBUG_OPTIONS_CMAKE)
# check if function glXGetProcAddressARB exists
set(TEMP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_LIBRARIES GLU GL)
CHECK_FUNCTION_EXISTS(glXGetProcAddressARB HAVE_GLXGETPROCADDRESSARB)
set(CMAKE_REQUIRED_LIBRARIES ${TEMP_REQUIRED_LIBRARIES})
unset(TEMP_REQUIRED_LIBRARIES)
if (OPENGL_FOUND)
set (CMAKE_REQUIRED_INCLUDES ${OPENGL_INCLUDE_DIR}/GL)
if (WIN32)
set (GLLIBS "-lglu32 -lopengl32")
else ()
set (GLLIBS "-lGLU -lGL")
endif ()
set(FLTK_GL_FOUND TRUE)
else()
set(FLTK_GL_FOUND FALSE)
endif(OPENGL_FOUND)
# check if function glXGetProcAddressARB exists
set (TEMP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set (CMAKE_REQUIRED_LIBRARIES ${OPENGL_LIBRARIES})
CHECK_FUNCTION_EXISTS (glXGetProcAddressARB HAVE_GLXGETPROCADDRESSARB)
set (CMAKE_REQUIRED_LIBRARIES ${TEMP_REQUIRED_LIBRARIES})
unset (TEMP_REQUIRED_LIBRARIES)
set (FLTK_GL_FOUND TRUE)
else ()
set (FLTK_GL_FOUND FALSE)
endif (OPENGL_FOUND)
#######################################################################
# Create an option whether we want to check for pthreads.
@ -257,91 +287,91 @@ endif (debug_threads)
unset (debug_threads)
#######################################################################
option(OPTION_LARGE_FILE "enable large file support" ON)
option (OPTION_LARGE_FILE "enable large file support" ON)
if(OPTION_LARGE_FILE)
if(NOT MSVC)
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE)
list(APPEND FLTK_CFLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE)
endif(NOT MSVC)
endif(OPTION_LARGE_FILE)
if (OPTION_LARGE_FILE)
if (NOT MSVC)
add_definitions (-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE)
list (APPEND FLTK_CFLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE)
endif (NOT MSVC)
endif (OPTION_LARGE_FILE)
#######################################################################
option(OPTION_USE_SYSTEM_ZLIB "use system zlib" ON)
option (OPTION_USE_SYSTEM_ZLIB "use system zlib" ON)
if(OPTION_USE_SYSTEM_ZLIB AND LIB_zlib)
include(FindZLIB)
endif(OPTION_USE_SYSTEM_ZLIB AND LIB_zlib)
if (OPTION_USE_SYSTEM_ZLIB)
include (FindZLIB)
endif (OPTION_USE_SYSTEM_ZLIB)
if(OPTION_USE_SYSTEM_ZLIB AND ZLIB_FOUND)
set(FLTK_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
include_directories(${ZLIB_INCLUDE_DIRS})
set(FLTK_BUILTIN_ZLIB_FOUND FALSE)
if (ZLIB_FOUND)
set (FLTK_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
include_directories (${ZLIB_INCLUDE_DIRS})
set (FLTK_BUILTIN_ZLIB_FOUND FALSE)
else()
add_subdirectory(zlib)
set(FLTK_ZLIB_LIBRARIES fltk_z)
set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zlib)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/zlib)
set(FLTK_BUILTIN_ZLIB_FOUND TRUE)
endif(OPTION_USE_SYSTEM_ZLIB AND ZLIB_FOUND)
if (OPTION_USE_SYSTEM_ZLIB)
message(STATUS "\ncannot find system zlib library - using built-in\n")
endif (OPTION_USE_SYSTEM_ZLIB)
if(OPTION_USE_SYSTEM_ZLIB AND NOT ZLIB_FOUND)
message(STATUS "\ncannot find system zlib library - using built-in\n")
endif(OPTION_USE_SYSTEM_ZLIB AND NOT ZLIB_FOUND)
add_subdirectory (zlib)
set (FLTK_ZLIB_LIBRARIES fltk_z)
set (ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zlib)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/zlib)
set (FLTK_BUILTIN_ZLIB_FOUND TRUE)
endif (ZLIB_FOUND)
set(HAVE_LIBZ 1)
set (HAVE_LIBZ 1)
#######################################################################
option(OPTION_USE_SYSTEM_LIBJPEG "use system libjpeg" ON)
option (OPTION_USE_SYSTEM_LIBJPEG "use system libjpeg" ON)
if(OPTION_USE_SYSTEM_LIBJPEG AND LIB_jpeg)
include(FindJPEG)
endif(OPTION_USE_SYSTEM_LIBJPEG AND LIB_jpeg)
if (OPTION_USE_SYSTEM_LIBJPEG)
include (FindJPEG)
endif (OPTION_USE_SYSTEM_LIBJPEG)
if(OPTION_USE_SYSTEM_LIBJPEG AND JPEG_FOUND)
set(FLTK_JPEG_LIBRARIES ${JPEG_LIBRARIES})
include_directories(${JPEG_INCLUDE_DIR})
set(FLTK_BUILTIN_JPEG_FOUND FALSE)
else()
add_subdirectory(jpeg)
set(FLTK_JPEG_LIBRARIES fltk_jpeg)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/jpeg)
set(FLTK_BUILTIN_JPEG_FOUND TRUE)
endif(OPTION_USE_SYSTEM_LIBJPEG AND JPEG_FOUND)
if (JPEG_FOUND)
set(FLTK_JPEG_LIBRARIES ${JPEG_LIBRARIES})
include_directories(${JPEG_INCLUDE_DIR})
set(FLTK_BUILTIN_JPEG_FOUND FALSE)
else ()
if (OPTION_USE_SYSTEM_LIBJPEG)
message (STATUS "\ncannot find system jpeg library - using built-in\n")
endif (OPTION_USE_SYSTEM_LIBJPEG)
if(OPTION_USE_SYSTEM_LIBJPEG AND NOT JPEG_FOUND)
message(STATUS "\ncannot find system jpeg library - using built-in\n")
endif(OPTION_USE_SYSTEM_LIBJPEG AND NOT JPEG_FOUND)
add_subdirectory (jpeg)
set (FLTK_JPEG_LIBRARIES fltk_jpeg)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/jpeg)
set (FLTK_BUILTIN_JPEG_FOUND TRUE)
endif (JPEG_FOUND)
set(HAVE_LIBJPEG 1)
set (HAVE_LIBJPEG 1)
#######################################################################
option(OPTION_USE_SYSTEM_LIBPNG "use system libpng" ON)
option (OPTION_USE_SYSTEM_LIBPNG "use system libpng" ON)
if(OPTION_USE_SYSTEM_LIBPNG AND LIB_png)
include(FindPNG)
endif(OPTION_USE_SYSTEM_LIBPNG AND LIB_png)
if (OPTION_USE_SYSTEM_LIBPNG)
include (FindPNG)
endif (OPTION_USE_SYSTEM_LIBPNG)
if(OPTION_USE_SYSTEM_LIBPNG AND PNG_FOUND)
set(FLTK_PNG_LIBRARIES ${PNG_LIBRARIES})
include_directories(${PNG_INCLUDE_DIR})
add_definitions(${PNG_DEFINITIONS})
set(FLTK_BUILTIN_PNG_FOUND FALSE)
if (PNG_FOUND)
set (FLTK_PNG_LIBRARIES ${PNG_LIBRARIES})
include_directories (${PNG_INCLUDE_DIR})
add_definitions (${PNG_DEFINITIONS})
set (FLTK_BUILTIN_PNG_FOUND FALSE)
else()
add_subdirectory(png)
set(FLTK_PNG_LIBRARIES fltk_png)
set(HAVE_PNG_H 1)
set(HAVE_PNG_GET_VALID 1)
set(HAVE_PNG_SET_TRNS_TO_ALPHA 1)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/png)
set(FLTK_BUILTIN_PNG_FOUND TRUE)
endif(OPTION_USE_SYSTEM_LIBPNG AND PNG_FOUND)
if (OPTION_USE_SYSTEM_LIBPNG)
message (STATUS "\ncannot find system png library - using built-in\n")
endif (OPTION_USE_SYSTEM_LIBPNG)
if(OPTION_USE_SYSTEM_LIBPNG AND NOT PNG_FOUND)
message(STATUS "\ncannot find system png library - using built-in\n")
endif(OPTION_USE_SYSTEM_LIBPNG AND NOT PNG_FOUND)
add_subdirectory (png)
set (FLTK_PNG_LIBRARIES fltk_png)
set (HAVE_PNG_H 1)
set (HAVE_PNG_GET_VALID 1)
set (HAVE_PNG_SET_TRNS_TO_ALPHA 1)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/png)
set (FLTK_BUILTIN_PNG_FOUND TRUE)
endif (PNG_FOUND)
set(HAVE_LIBPNG 1)
set (HAVE_LIBPNG 1)
#######################################################################
if(X11_Xinerama_FOUND)
@ -440,6 +470,7 @@ if(X11_Xft_FOUND AND OPTION_USE_PANGO)
find_path(GLIB_H_PATH glib.h ${PANGO_H_PREFIX}/glib/glib-2.0)
endif(NOT GLIB_H_PATH)
include_directories(${PANGO_H_PREFIX}/pango-1.0 ${GLIB_H_PATH} ${PANGOLIB_DIR}/glib-2.0/include)
list(APPEND FLTK_LDLIBS -lpango-1.0 -lpangoxft-1.0 -lgobject-2.0)
endif(HAVE_LIB_PANGO AND HAVE_LIB_PANGOXFT AND HAVE_LIB_GOBJECT)
endif(X11_Xft_FOUND AND OPTION_USE_PANGO)
@ -505,3 +536,16 @@ if(NOT CMAKE_VERSION VERSION_LESS 3.0.0)
"suppress rules to re-run CMake on rebuild" OFF)
mark_as_advanced(CMAKE_SUPPRESS_REGENERATION)
endif(NOT CMAKE_VERSION VERSION_LESS 3.0.0)
#######################################################################
# Debugging ...
if (DEBUG_OPTIONS_CMAKE)
fl_debug_var (WIN32)
fl_debug_var (LIBS)
fl_debug_var (GLLIBS)
fl_debug_var (FLTK_LDLIBS)
fl_debug_var (USE_FIND_FILE)
message (STATUS "[** end of options.cmake **]")
endif (DEBUG_OPTIONS_CMAKE)
unset (DEBUG_OPTIONS_CMAKE)

View File

@ -20,27 +20,71 @@
#######################################################################
# check for headers, libraries and functions
#######################################################################
# headers
find_file(HAVE_ALSA_ASOUNDLIB_H alsa/asoundlib.h)
find_file(HAVE_DLFCN_H dlfcn.h)
find_file(HAVE_FREETYPE_H freetype.h PATH_SUFFIXES freetype2 freetype2/freetype)
find_file(HAVE_GL_GLU_H GL/glu.h)
find_file(HAVE_LIBPNG_PNG_H libpng/png.h)
find_file(HAVE_LOCALE_H locale.h)
find_file(HAVE_OPENGL_GLU_H OpenGL/glu.h)
find_file(HAVE_PNG_H png.h)
find_file(HAVE_STDIO_H stdio.h)
find_file(HAVE_STRINGS_H strings.h)
find_file(HAVE_SYS_SELECT_H sys/select.h)
find_file(HAVE_SYS_STDTYPES_H sys/stdtypes.h)
find_file(HAVE_X11_XREGION_H X11/Xregion.h)
find_path(HAVE_XDBE_H Xdbe.h PATH_SUFFIXES X11/extensions extensions)
# The following code is work in progress (as of Feb 2018) - AlbrechtS
# The cache option USE_FIND_FILE can be set to ON to switch back to the old
# behavior that tries to find headers by find_file() which appears to be
# error prone at least under Windows when MSYS2 and MinGW are both
# installed on one system.
# If USE_FIND_FILE is OFF (new behavior), then headers are searched for by
# check_include_files() which tries to compile a small file to test if
# the header file can be used. In some cases this needs more than one
# header in a list because another header must be included before the
# header being searched for.
# Example: X11/Xlib.h must be included before X11/Xregion.h so Xregion.h
# can be compiled successfully.
# If CMAKE_REQUIRED_QUIET is 1 (default) the search is mostly quiet, if
# it is 0 (or not defined) check_include_files() is more verbose and
# the result of the search is logged with fl_debug_var().
# This is useful for debugging.
set (CMAKE_REQUIRED_QUIET 1)
include(CheckIncludeFiles)
# The following macro is used to switch between old and new behavior.
# Once this is stable (USE_FIND_FILE = 0) the unused part may be removed.
macro (fl_find_header VAR HEADER)
if (USE_FIND_FILE)
find_file (${VAR} "${HEADER}")
else (USE_FIND_FILE)
check_include_files("${HEADER}" ${VAR})
endif (USE_FIND_FILE)
if (NOT CMAKE_REQUIRED_QUIET)
fl_debug_var (${VAR})
endif (NOT CMAKE_REQUIRED_QUIET)
endmacro (fl_find_header)
# Find header files...
fl_find_header (HAVE_ALSA_ASOUNDLIB_H alsa/asoundlib.h)
fl_find_header (HAVE_DLFCN_H dlfcn.h)
fl_find_header (HAVE_GL_GLU_H GL/glu.h)
fl_find_header (HAVE_LIBPNG_PNG_H libpng/png.h)
fl_find_header (HAVE_LOCALE_H locale.h)
fl_find_header (HAVE_OPENGL_GLU_H OpenGL/glu.h)
fl_find_header (HAVE_PNG_H png.h)
fl_find_header (HAVE_STDIO_H stdio.h)
fl_find_header (HAVE_STRINGS_H strings.h)
fl_find_header (HAVE_SYS_SELECT_H sys/select.h)
fl_find_header (HAVE_SYS_STDTYPES_H sys/stdtypes.h)
if (USE_FIND_FILE)
fl_find_header (HAVE_X11_XREGION_H "X11/Xregion.h")
fl_find_header (HAVE_XDBE_H "X11/extensions/Xdbe.h")
else ()
fl_find_header (HAVE_X11_XREGION_H "X11/Xlib.h;X11/Xregion.h")
fl_find_header (HAVE_XDBE_H "X11/Xlib.h;X11/extensions/Xdbe.h")
endif()
if (WIN32 AND NOT CYGWIN)
# we don't use pthreads on Windows (except for Cygwin, see options.cmake)
set(HAVE_PTHREAD_H 0)
else ()
find_file(HAVE_PTHREAD_H pthread.h)
fl_find_header (HAVE_PTHREAD_H pthread.h)
endif (WIN32 AND NOT CYGWIN)
# Special case for Microsoft Visual Studio generator (MSVC):
@ -91,24 +135,24 @@ endif (MSVC)
# Simulate the behavior of autoconf macro AC_HEADER_DIRENT, see:
# https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Headers.html
# "Check for the following header files. For the first one that is found
# and defines DIR, define the listed C preprocessor macro ..."
# and defines 'DIR', define the listed C preprocessor macro ..."
#
# Note: we don't check if it really defines 'DIR', but we stop processing
# once we found the first suitable header file.
find_file(HAVE_DIRENT_H dirent.h)
fl_find_header (HAVE_DIRENT_H dirent.h)
if(NOT HAVE_DIRENT_H)
find_file(HAVE_SYS_NDIR_H sys/ndir.h)
fl_find_header (HAVE_SYS_NDIR_H sys/ndir.h)
if(NOT HAVE_SYS_NDIR_H)
find_file(HAVE_SYS_DIR_H sys/dir.h)
fl_find_header (HAVE_SYS_DIR_H sys/dir.h)
if(NOT HAVE_SYS_DIR_H)
find_file(HAVE_NDIR_H ndir.h)
fl_find_header (HAVE_NDIR_H ndir.h)
endif(NOT HAVE_SYS_DIR_H)
endif(NOT HAVE_SYS_NDIR_H)
endif(NOT HAVE_DIRENT_H)
mark_as_advanced(HAVE_ALSA_ASOUNDLIB_H HAVE_DIRENT_H HAVE_DLFCN_H)
mark_as_advanced(HAVE_FREETYPE_H HAVE_GL_GLU_H)
mark_as_advanced(HAVE_GL_GLU_H)
mark_as_advanced(HAVE_LIBPNG_PNG_H HAVE_LOCALE_H HAVE_NDIR_H)
mark_as_advanced(HAVE_OPENGL_GLU_H HAVE_PNG_H HAVE_PTHREAD_H)
mark_as_advanced(HAVE_STDIO_H HAVE_STRINGS_H HAVE_SYS_DIR_H)
@ -116,12 +160,19 @@ mark_as_advanced(HAVE_SYS_NDIR_H HAVE_SYS_SELECT_H)
mark_as_advanced(HAVE_SYS_STDTYPES_H HAVE_XDBE_H)
mark_as_advanced(HAVE_X11_XREGION_H)
#----------------------------------------------------------------------
# The following code is used to find the include path for freetype
# headers to be able to #include <ft2build.h> in Xft.h.
# where to find freetype headers
find_path(FREETYPE_PATH freetype.h PATH_SUFFIXES freetype2)
find_path(FREETYPE_PATH freetype/freetype.h PATH_SUFFIXES freetype2)
if(FREETYPE_PATH)
include_directories(${FREETYPE_PATH})
endif(FREETYPE_PATH)
if (FREETYPE_PATH)
include_directories(${FREETYPE_PATH})
endif (FREETYPE_PATH)
mark_as_advanced(FREETYPE_PATH)
#######################################################################
@ -153,7 +204,7 @@ endif(DEFINED CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_LIBRARIES)
if(HAVE_DLFCN_H)
set(HAVE_DLFCN_H 1)
set(HAVE_DLFCN_H 1)
endif(HAVE_DLFCN_H)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
@ -169,19 +220,19 @@ if(LIB_png)
set(CMAKE_REQUIRED_LIBRARIES)
endif(LIB_png)
CHECK_FUNCTION_EXISTS(scandir HAVE_SCANDIR)
CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
CHECK_FUNCTION_EXISTS(scandir HAVE_SCANDIR)
CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
# not really true but we convert strcasecmp calls to _stricmp calls in flstring.h
if(MSVC)
set(HAVE_STRCASECMP 1)
endif(MSVC)
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
CHECK_FUNCTION_EXISTS(strlcat HAVE_STRLCAT)
CHECK_FUNCTION_EXISTS(strlcpy HAVE_STRLCPY)
CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF)
CHECK_FUNCTION_EXISTS(strlcat HAVE_STRLCAT)
CHECK_FUNCTION_EXISTS(strlcpy HAVE_STRLCPY)
CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF)
if(HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX)
set(MSG "POSIX compatible scandir")
@ -231,6 +282,10 @@ endif (DOXYGEN_FOUND)
# message("LaTex found : ${LATEX_FOUND}")
# message("LaTex Compiler : ${LATEX_COMPILER}")
# Cleanup: unset local variables
unset (CMAKE_REQUIRED_QUIET)
#
# End of "$Id$".
#

View File

@ -4,7 +4,7 @@
# This file sets variables for common use in export.cmake and install.cmake
# Written by Michael Surette
#
# Copyright 1998-2015 by Bill Spitzak and others.
# Copyright 1998-2018 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
@ -18,37 +18,88 @@
#
#######################################################################
set(FL_MAJOR_VERSION ${FLTK_VERSION_MAJOR})
set(FL_MINOR_VERSION ${FLTK_VERSION_MINOR})
set(FL_PATCH_VERSION ${FLTK_VERSION_PATCH})
set (FL_MAJOR_VERSION ${FLTK_VERSION_MAJOR})
set (FL_MINOR_VERSION ${FLTK_VERSION_MINOR})
set (FL_PATCH_VERSION ${FLTK_VERSION_PATCH})
set (DEBUG_VARIABLES_CMAKE 0)
if (DEBUG_VARIABLES_CMAKE)
message (STATUS "[** variables.cmake **]")
fl_debug_var (CMAKE_EXE_LINKER_FLAGS)
fl_debug_var (LDFLAGS)
fl_debug_var (LIBS)
fl_debug_var (GLLIBS)
fl_debug_var (IMAGELIBS)
fl_debug_var (STATICIMAGELIBS)
fl_debug_var (FLTK_LDLIBS)
fl_debug_var (LIB_jpeg)
fl_debug_var (LIB_png)
fl_debug_var (LIB_zlib)
endif (DEBUG_VARIABLES_CMAKE)
#######################################################################
# add several libraries (STR #3011)
# FIXME: libraries may need reordering, and this version does not yet
# correctly support static linking and local zlib, png, and jpeg libs.
# add several libraries
# FIXME: libraries may need reordering.
if(LIB_fontconfig)
list(APPEND FLTK_LDLIBS -lfontconfig)
endif(LIB_fontconfig)
if (LIB_fontconfig)
list(APPEND FLTK_LDLIBS -lfontconfig)
endif (LIB_fontconfig)
if(HAVE_DLSYM)
list(APPEND FLTK_LDLIBS -ldl)
endif(HAVE_DLSYM)
if (HAVE_DLSYM AND NOT WIN32)
list(APPEND FLTK_LDLIBS -ldl)
endif (HAVE_DLSYM AND NOT WIN32)
if(LIB_png)
list(APPEND IMAGELIBS -lpng)
endif(LIB_png)
#######################################################################
# Set variables for fltk-config (generated from fltk-config.in)
#######################################################################
if(LIB_zlib)
list(APPEND IMAGELIBS -lz)
endif(LIB_zlib)
# Variables in fltk-config.in (@VAR@) are used in configure(.ac)
# and in CMake so their names and usage must be synchronized.
# CMake generates two instances of fltk-config, one that can be used
# directly in the build tree (see export.cmake) and one that is copied
# to the installation directory (see install.cmake). Common variables
# should be set here, whereas variables with different values should
# be set in install.cmake or export.cmake, respectively.
if(LIB_jpeg)
list(APPEND IMAGELIBS -ljpeg)
endif(LIB_jpeg)
if (WIN32)
set (LDFLAGS "${CMAKE_EXE_LINKER_FLAGS} -mwindows")
endif ()
set (IMAGELIBS)
set (STATICIMAGELIBS)
if (FLTK_BUILTIN_JPEG_FOUND)
list(APPEND IMAGELIBS -lfltk_jpeg)
list(APPEND STATICIMAGELIBS \$libdir/libfltk_jpeg.a)
else ()
if (LIB_jpeg)
list(APPEND IMAGELIBS -ljpeg)
list(APPEND STATICIMAGELIBS -ljpeg)
endif (LIB_jpeg)
endif (FLTK_BUILTIN_JPEG_FOUND)
if (FLTK_BUILTIN_PNG_FOUND)
list(APPEND IMAGELIBS -lfltk_png)
list(APPEND STATICIMAGELIBS \$libdir/libfltk_png.a)
else ()
if (LIB_png)
list(APPEND IMAGELIBS -lpng)
list(APPEND STATICIMAGELIBS -lpng)
endif (LIB_png)
endif (FLTK_BUILTIN_PNG_FOUND)
if (FLTK_BUILTIN_ZLIB_FOUND)
list(APPEND IMAGELIBS -lfltk_z)
list(APPEND STATICIMAGELIBS \$libdir/libfltk_z.a)
else ()
if (LIB_zlib)
list(APPEND IMAGELIBS -lz)
list(APPEND STATICIMAGELIBS -lz)
endif (LIB_zlib)
endif (FLTK_BUILTIN_ZLIB_FOUND)
string(REPLACE ";" " " IMAGELIBS "${IMAGELIBS}")
set(STATICIMAGELIBS "${IMAGELIBS}")
string(REPLACE ";" " " STATICIMAGELIBS "${STATICIMAGELIBS}")
#######################################################################
set(CC ${CMAKE_C_COMPILER})
@ -57,9 +108,9 @@ set(CXX ${CMAKE_CXX_COMPILER})
set(ARCHFLAGS ${OPTION_ARCHFLAGS})
string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_UPPER)
if(${BUILD_UPPER})
if (${BUILD_UPPER})
set(CFLAGS "${CMAKE_C_FLAGS_${BUILD_UPPER}} ${CFLAGS}")
endif(${BUILD_UPPER})
endif (${BUILD_UPPER})
set(CFLAGS "${OPTION_OPTIM} ${CMAKE_C_FLAGS} ${CFLAGS}")
foreach(arg ${FLTK_CFLAGS})
@ -79,3 +130,18 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "AIX")
else ()
set(SHAREDSUFFIX "")
endif (${CMAKE_SYSTEM_NAME} STREQUAL "AIX")
if (DEBUG_VARIABLES_CMAKE)
fl_debug_var (CMAKE_EXE_LINKER_FLAGS)
fl_debug_var (LDFLAGS)
fl_debug_var (LIBS)
fl_debug_var (GLLIBS)
fl_debug_var (IMAGELIBS)
fl_debug_var (STATICIMAGELIBS)
fl_debug_var (FLTK_LDLIBS)
fl_debug_var (LIB_jpeg)
fl_debug_var (LIB_png)
fl_debug_var (LIB_zlib)
message (STATUS "[** end of variables.cmake **]")
endif (DEBUG_VARIABLES_CMAKE)
unset (DEBUG_VARIABLES_CMAKE)

View File

@ -877,10 +877,10 @@ case $host_os_gui in
if test x$enable_gl != xno; then
AC_CHECK_HEADER(GL/gl.h,
AC_DEFINE(HAVE_GL)
GLLIB="-lopengl32")
GLLIBS="-lopengl32")
AC_CHECK_HEADER(GL/glu.h,
AC_DEFINE(HAVE_GL_GLU_H)
GLLIB="-lglu32 $GLLIB")
GLLIBS="-lglu32 $GLLIBS")
else
LINKFLTKGL=""
GLLIBNAME=""
@ -918,7 +918,7 @@ case $host_os_gui in
if test x$enable_gl != xno; then
AC_DEFINE(HAVE_GL)
AC_DEFINE(HAVE_GL_GLU_H)
GLLIB="-framework OpenGL"
GLLIBS="-framework OpenGL"
else
LINKFLTKGL=""
GLLIBNAME=""
@ -970,17 +970,17 @@ case $host_os_gui in
fi
dnl Check for OpenGL unless disabled...
GLLIB=
GLLIBS=
if test x$enable_gl != xno; then
AC_SEARCH_LIBS(dlopen, dl)
AC_CHECK_HEADER(GL/gl.h,
AC_CHECK_LIB(GL, glXMakeCurrent,
[AC_DEFINE(HAVE_GL)
GLLIB="-lGL"],
GLLIBS="-lGL"],
AC_CHECK_LIB(MesaGL, glXMakeCurrent,
[AC_DEFINE(HAVE_GL)
GLLIB="-lMesaGL"],,
GLLIBS="-lMesaGL"],,
[-lm]),
[-lm])
AC_CHECK_LIB(GL, glXGetProcAddressARB,
@ -989,10 +989,10 @@ case $host_os_gui in
AC_CHECK_HEADER(GL/glu.h,
AC_DEFINE(HAVE_GL_GLU_H)
if test x$ac_cv_lib_GL_glXMakeCurrent = xyes; then
GLLIB="-lGLU $GLLIB"
GLLIBS="-lGLU $GLLIBS"
fi
if test x$ac_cv_lib_MesaGL_glXMakeCurrent = xyes; then
GLLIB="-lMesaGLU $GLLIB"
GLLIBS="-lMesaGLU $GLLIBS"
fi
)
@ -1202,7 +1202,7 @@ case $host_os_gui in
esac
AC_SUBST(GLDEMOS)
AC_SUBST(GLLIB)
AC_SUBST(GLLIBS)
AC_SUBST(HLINKS)
AC_SUBST(OSX_ONLY)
AC_SUBST(THREADS)

View File

@ -243,8 +243,8 @@ if test x$use_forms = xyes; then
LDSTATIC="$libdir/libfltk_forms.a $LDSTATIC"
fi
if test x$use_gl = xyes; then
LDLIBS="-lfltk_gl$SHAREDSUFFIX @GLLIB@ $LDLIBS"
LDSTATIC="$libdir/libfltk_gl.a @GLLIB@ $LDSTATIC"
LDLIBS="-lfltk_gl$SHAREDSUFFIX @GLLIBS@ $LDLIBS"
LDSTATIC="$libdir/libfltk_gl.a @GLLIBS@ $LDSTATIC"
fi
if test x$use_images = xyes; then
LDLIBS="-lfltk_images$SHAREDSUFFIX $IMAGELIBS $LDLIBS"

View File

@ -3,7 +3,7 @@
#
# Make include file for the Fast Light Tool Kit (FLTK).
#
# Copyright 1998-2014 by Bill Spitzak and others.
# Copyright 1998-2018 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
@ -97,7 +97,7 @@ CAIROFLAGS = @CAIROFLAGS@
DSOFLAGS = -L. @DSOFLAGS@
LDFLAGS = $(OPTIM) @LDFLAGS@
LDLIBS = @LIBS@
GLDLIBS = @GLLIB@ @LIBS@
GLDLIBS = @GLLIBS@ @LIBS@
LINKFLTK = @LINKFLTK@
LINKFLTKGL = @LINKFLTKGL@
LINKFLTKFORMS = @LINKFLTKFORMS@ @LINKFLTK@

View File

@ -1,3 +1,20 @@
#
# "$Id$"
#
# CMakeLists.txt to build the FLTK library using CMake (www.cmake.org)
#
# Copyright 1998-2018 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:
#
# http://www.fltk.org/COPYING.php
#
# Please report all bugs and problems on the following page:
#
# http://www.fltk.org/str.php
#
set (CPPFILES
Fl.cxx