|
|
commit a484541d4b6203d538f1a65db5a95e98f5bde920
Author: Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Fri Apr 30 19:47:47 2021 +0200
Commit: Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Fri Apr 30 19:47:47 2021 +0200
CMake: improve detection and configuration of image libs
Also: fix old (pre 3.13) link_directories() usage
CMake/fl_create_example.cmake | 4 +--
CMake/options.cmake | 84 ++++++++++++++++++++++++-------------------
fluid/CMakeLists.txt | 4 +--
jpeg/CMakeLists.txt | 51 ++++++++++++++++++--------
png/CMakeLists.txt | 39 ++++++++++----------
zlib/CMakeLists.txt | 18 ++++++++++
6 files changed, 126 insertions(+), 74 deletions(-)
diff --git CMake/fl_create_example.cmake CMake/fl_create_example.cmake
index a245bb5..8071b50 100644
--- CMake/fl_create_example.cmake
+++ CMake/fl_create_example.cmake
@@ -117,9 +117,9 @@ macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
if (FLTK_HAVE_CAIRO)
if (CMAKE_VERSION VERSION_LESS "3.13")
- link_directories (${TARGET_NAME} PUBLIC ${PKG_CAIRO_LIBRARY_DIRS})
+ link_directories (${PKG_CAIRO_LIBRARY_DIRS})
else()
- target_link_directories (${TARGET_NAME} PUBLIC ${PKG_CAIRO_LIBRARY_DIRS})
+ target_link_directories (${TARGET_NAME} PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
endif()
endif (FLTK_HAVE_CAIRO)
diff --git CMake/options.cmake CMake/options.cmake
index 008088a..cf50da6 100644
--- CMake/options.cmake
+++ CMake/options.cmake
@@ -168,11 +168,16 @@ if (OPTION_CAIRO OR OPTION_CAIROEXT)
endif (OPTION_CAIROEXT)
add_subdirectory (cairo)
- # fl_debug_var (PKG_CAIRO_INCLUDE_DIRS)
- # fl_debug_var (PKG_CAIRO_CFLAGS)
- # fl_debug_var (PKG_CAIRO_STATIC_CFLAGS)
- # fl_debug_var (PKG_CAIRO_LIBRARIES)
- # fl_debug_var (PKG_CAIRO_STATIC_LIBRARIES)
+ if (0)
+ fl_debug_var (PKG_CAIRO_INCLUDE_DIRS)
+ fl_debug_var (PKG_CAIRO_CFLAGS)
+ fl_debug_var (PKG_CAIRO_LIBRARIES)
+ fl_debug_var (PKG_CAIRO_LIBRARY_DIRS)
+ fl_debug_var (PKG_CAIRO_STATIC_INCLUDE_DIRS)
+ fl_debug_var (PKG_CAIRO_STATIC_CFLAGS)
+ fl_debug_var (PKG_CAIRO_STATIC_LIBRARIES)
+ fl_debug_var (PKG_CAIRO_STATIC_LIBRARY_DIRS)
+ endif()
include_directories (${PKG_CAIRO_INCLUDE_DIRS})
@@ -339,87 +344,92 @@ endif (debug_threads)
unset (debug_threads)
#######################################################################
-option (OPTION_USE_SYSTEM_ZLIB "use system zlib" ON)
+# Image Library Options
+#######################################################################
+
+option (OPTION_USE_SYSTEM_ZLIB "use system zlib" ON)
+
+if (APPLE)
+ option (OPTION_USE_SYSTEM_LIBJPEG "use system libjpeg" OFF)
+ option (OPTION_USE_SYSTEM_LIBPNG "use system libpng" OFF)
+else ()
+ option (OPTION_USE_SYSTEM_LIBJPEG "use system libjpeg" ON)
+ option (OPTION_USE_SYSTEM_LIBPNG "use system libpng" ON)
+endif ()
+
+#######################################################################
+# Image Library : ZLIB
+#######################################################################
if (OPTION_USE_SYSTEM_ZLIB)
- include (FindZLIB)
-endif (OPTION_USE_SYSTEM_ZLIB)
+ find_package (ZLIB)
+endif ()
-if (ZLIB_FOUND)
+if (OPTION_USE_SYSTEM_ZLIB AND ZLIB_FOUND)
+ set (FLTK_USE_BUILTIN_ZLIB FALSE)
set (FLTK_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
include_directories (${ZLIB_INCLUDE_DIRS})
- set (FLTK_BUILTIN_ZLIB_FOUND FALSE)
else()
if (OPTION_USE_SYSTEM_ZLIB)
message (STATUS "cannot find system zlib library - using built-in\n")
- endif (OPTION_USE_SYSTEM_ZLIB)
+ endif ()
add_subdirectory (zlib)
+ set (FLTK_USE_BUILTIN_ZLIB TRUE)
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)
+endif ()
set (HAVE_LIBZ 1)
#######################################################################
-if (APPLE)
- option (OPTION_USE_SYSTEM_LIBJPEG "use system libjpeg" OFF)
-else ()
- option (OPTION_USE_SYSTEM_LIBJPEG "use system libjpeg" ON)
-endif (APPLE)
if (OPTION_USE_SYSTEM_LIBJPEG)
- include (FindJPEG)
-endif (OPTION_USE_SYSTEM_LIBJPEG)
+ find_package (JPEG)
+endif ()
-if (JPEG_FOUND)
+if (OPTION_USE_SYSTEM_LIBJPEG AND JPEG_FOUND)
+ set (FLTK_USE_BUILTIN_JPEG FALSE)
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 "cannot find system jpeg library - using built-in\n")
- endif (OPTION_USE_SYSTEM_LIBJPEG)
+ endif ()
add_subdirectory (jpeg)
+ set (FLTK_USE_BUILTIN_JPEG TRUE)
set (FLTK_JPEG_LIBRARIES fltk_jpeg)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/jpeg)
- set (FLTK_BUILTIN_JPEG_FOUND TRUE)
-endif (JPEG_FOUND)
+endif ()
set (HAVE_LIBJPEG 1)
#######################################################################
-if (APPLE)
- option (OPTION_USE_SYSTEM_LIBPNG "use system libpng" OFF)
-else ()
- option (OPTION_USE_SYSTEM_LIBPNG "use system libpng" ON)
-endif (APPLE)
if (OPTION_USE_SYSTEM_LIBPNG)
- include (FindPNG)
-endif (OPTION_USE_SYSTEM_LIBPNG)
+ find_package (PNG)
+endif ()
-if (PNG_FOUND)
+if (OPTION_USE_SYSTEM_LIBPNG AND PNG_FOUND)
+ set (FLTK_USE_BUILTIN_PNG FALSE)
set (FLTK_PNG_LIBRARIES ${PNG_LIBRARIES})
include_directories (${PNG_INCLUDE_DIR})
add_definitions (${PNG_DEFINITIONS})
- set (FLTK_BUILTIN_PNG_FOUND FALSE)
else()
if (OPTION_USE_SYSTEM_LIBPNG)
message (STATUS "cannot find system png library - using built-in\n")
- endif (OPTION_USE_SYSTEM_LIBPNG)
+ endif ()
add_subdirectory (png)
+ set (FLTK_USE_BUILTIN_PNG TRUE)
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)
+endif ()
set (HAVE_LIBPNG 1)
diff --git fluid/CMakeLists.txt fluid/CMakeLists.txt
index 1b98c17..73cdb45 100644
--- fluid/CMakeLists.txt
+++ fluid/CMakeLists.txt
@@ -72,9 +72,9 @@ endif (APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL))
target_link_libraries (fluid fltk fltk_images fltk_forms)
if (FLTK_HAVE_CAIRO)
if (CMAKE_VERSION VERSION_LESS "3.13")
- link_directories (fluid PUBLIC ${PKG_CAIRO_LIBRARY_DIRS})
+ link_directories (${PKG_CAIRO_LIBRARY_DIRS})
else()
- target_link_directories (fluid PUBLIC ${PKG_CAIRO_LIBRARY_DIRS})
+ target_link_directories (fluid PRIVATE ${PKG_CAIRO_LIBRARY_DIRS})
endif()
endif (FLTK_HAVE_CAIRO)
diff --git jpeg/CMakeLists.txt jpeg/CMakeLists.txt
index 2e30f2d..16a423a 100644
--- jpeg/CMakeLists.txt
+++ jpeg/CMakeLists.txt
@@ -1,36 +1,56 @@
+#
+# JPEG library CMake configuration for the Fast Light Toolkit (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
+#
# memmgr back ends: compile only one of these into a working library
# (For now, let's use the mode that requires the image fit into memory.
# This is the recommended mode for Win32 anyway.)
-set(systemdependent_SRCS jmemnobs.c)
+
+set (systemdependent_SRCS jmemnobs.c)
# library object files common to compression and decompression
-set(common_SRCS
- jaricom.c jcomapi.c jutils.c jerror.c jmemmgr.c
+
+set (common_SRCS
+ jaricom.c jcomapi.c jutils.c jerror.c jmemmgr.c
)
# compression library object files
-set(compression_SRCS
- jcapimin.c jcapistd.c jcarith.c jctrans.c jcparam.c jdatadst.c jcinit.c
- jcmaster.c jcmarker.c jcmainct.c jcprepct.c jccoefct.c jccolor.c
- jcsample.c jchuff.c jcdctmgr.c jfdctfst.c jfdctflt.c
- jfdctint.c
+
+set (compression_SRCS
+ jcapimin.c jcapistd.c jcarith.c jctrans.c jcparam.c jdatadst.c jcinit.c
+ jcmaster.c jcmarker.c jcmainct.c jcprepct.c jccoefct.c jccolor.c
+ jcsample.c jchuff.c jcdctmgr.c jfdctfst.c jfdctflt.c
+ jfdctint.c
)
# decompression library object files
-set(decompression_SRCS
- jdapimin.c jdapistd.c jdarith.c jdtrans.c jdatasrc.c jdmaster.c
- jdinput.c jdmarker.c jdhuff.c jdmainct.c jdcoefct.c
- jdpostct.c jddctmgr.c jidctfst.c jidctflt.c jidctint.c
- jdsample.c jdcolor.c jquant1.c jquant2.c jdmerge.c
+
+set (decompression_SRCS
+ jdapimin.c jdapistd.c jdarith.c jdtrans.c jdatasrc.c jdmaster.c
+ jdinput.c jdmarker.c jdhuff.c jdmainct.c jdcoefct.c
+ jdpostct.c jddctmgr.c jidctfst.c jidctflt.c jidctint.c
+ jdsample.c jdcolor.c jquant1.c jquant2.c jdmerge.c
)
-list(APPEND BUILD_SRCS "${systemdependent_SRCS};${common_SRCS}")
-list(APPEND BUILD_SRCS "${compression_SRCS};${decompression_SRCS}")
+list (APPEND BUILD_SRCS "${systemdependent_SRCS};${common_SRCS}")
+list (APPEND BUILD_SRCS "${compression_SRCS};${decompression_SRCS}")
#######################################################################
# Suppress some Visual Studio compiler warnings
+
set (msvc_warnings /wd4267)
#######################################################################
@@ -48,6 +68,7 @@ endif (MSVC)
#######################################################################
if (OPTION_BUILD_SHARED_LIBS)
+
FL_ADD_LIBRARY (fltk_jpeg SHARED "${BUILD_SRCS}")
if (MSVC)
diff --git png/CMakeLists.txt png/CMakeLists.txt
index faf7062..a67c7eb 100644
--- png/CMakeLists.txt
+++ png/CMakeLists.txt
@@ -39,29 +39,32 @@ set(PNG_SRCS
)
#######################################################################
-FL_ADD_LIBRARY(fltk_png STATIC "${PNG_SRCS}")
-# install the png headers
-install(FILES png.h;pngconf.h;pnglibconf.h
- DESTINATION ${FLTK_INCLUDEDIR}/FL/images
-)
+# Build the static library
+#######################################################################
-if(OPTION_USE_SYSTEM_ZLIB)
- target_link_libraries(fltk_png ${FLTK_ZLIB_LIBRARIES})
-else()
- target_link_libraries(fltk_png fltk_z)
-endif(OPTION_USE_SYSTEM_ZLIB)
+FL_ADD_LIBRARY (fltk_png STATIC "${PNG_SRCS}")
+target_link_libraries (fltk_png ${FLTK_ZLIB_LIBRARIES})
#######################################################################
-if(OPTION_BUILD_SHARED_LIBS)
+# Build the shared library (optional)
#######################################################################
-FL_ADD_LIBRARY(fltk_png SHARED "${PNG_SRCS}")
-if(OPTION_USE_SYSTEM_ZLIB)
- target_link_libraries(fltk_png_SHARED ${FLTK_ZLIB_LIBRARIES})
-else()
- target_link_libraries(fltk_png_SHARED fltk_z_SHARED)
-endif(OPTION_USE_SYSTEM_ZLIB)
+if (OPTION_BUILD_SHARED_LIBS)
+
+ FL_ADD_LIBRARY (fltk_png SHARED "${PNG_SRCS}")
+
+ if (FLTK_USE_BUILTIN_ZLIB)
+ target_link_libraries (fltk_png_SHARED fltk_z_SHARED)
+ else()
+ target_link_libraries (fltk_png_SHARED ${FLTK_ZLIB_LIBRARIES})
+ endif ()
+
+endif ()
#######################################################################
-endif(OPTION_BUILD_SHARED_LIBS)
+# Install the library headers
#######################################################################
+
+install (FILES png.h pngconf.h pnglibconf.h
+ DESTINATION ${FLTK_INCLUDEDIR}/FL/images
+)
diff --git zlib/CMakeLists.txt zlib/CMakeLists.txt
index 33d6f58..1dc3042 100644
--- zlib/CMakeLists.txt
+++ zlib/CMakeLists.txt
@@ -1,5 +1,21 @@
+#
+# ZLIB library CMake configuration for the Fast Light Toolkit (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
+#
# source files for zlib
+
set (ZLIB_SRCS
adler32.c
compress.c
@@ -21,6 +37,7 @@ set (ZLIB_SRCS
#######################################################################
# Suppress some Visual Studio compiler warnings
+
set (msvc_warnings /wd4267 /wd4996)
#######################################################################
@@ -38,6 +55,7 @@ endif (MSVC)
#######################################################################
if (OPTION_BUILD_SHARED_LIBS)
+
FL_ADD_LIBRARY (fltk_z SHARED "${ZLIB_SRCS}")
if (MSVC)
[ Direct Link to Message ] | |
|
| |