From cf07fa09dc752d1283c22a2df402e7356b770871 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Mon, 4 Dec 2023 17:31:18 +0100 Subject: [PATCH] Minor updates of bundled libraries and README.CMake.txt Update Makefiles, CMakeLists.txt, improve formatting. --- CMake/options.cmake | 14 +++++++++++--- README.CMake.txt | 18 +++++++++--------- jpeg/CMakeLists.txt | 2 +- jpeg/Makefile | 9 +-------- png/CMakeLists.txt | 32 +++++++++++++++++--------------- png/Makefile | 2 +- zlib/CMakeLists.txt | 2 +- zlib/Makefile | 10 ++-------- 8 files changed, 43 insertions(+), 46 deletions(-) diff --git a/CMake/options.cmake b/CMake/options.cmake index b5150dee2..cc7060bd8 100644 --- a/CMake/options.cmake +++ b/CMake/options.cmake @@ -2,7 +2,7 @@ # Main CMakeLists.txt to build the FLTK project using CMake (www.cmake.org) # Originally written by Michael Surette # -# Copyright 1998-2022 by Bill Spitzak and others. +# Copyright 1998-2023 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 @@ -125,12 +125,12 @@ endif () # If either of them is not available, we fall back to using both local libraries if (OPTION_USE_SYSTEM_LIBPNG AND NOT (OPTION_USE_SYSTEM_ZLIB AND ZLIB_FOUND)) set (PNG_FOUND FALSE) - set (OPTION_USE_SYSTEM_LIBPNG FALSE) + set (OPTION_USE_SYSTEM_LIBPNG OFF) message (STATUS "Local z lib selected: overriding png lib to local for compatibility.\n") endif () if (OPTION_USE_SYSTEM_ZLIB AND NOT (OPTION_USE_SYSTEM_LIBPNG AND PNG_FOUND)) set (ZLIB_FOUND FALSE) - set (OPTION_USE_SYSTEM_ZLIB FALSE) + set (OPTION_USE_SYSTEM_ZLIB OFF) message (STATUS "Local png lib selected: overriding z lib to local for compatibility.\n") endif () @@ -951,6 +951,14 @@ if (DEBUG_OPTIONS_CMAKE) fl_debug_var (OPENGL_FOUND) fl_debug_var (OPENGL_INCLUDE_DIR) fl_debug_var (OPENGL_LIBRARIES) + fl_debug_var (CMAKE_MSVC_RUNTIME_LIBRARY) + message ("--- bundled libraries ---") + fl_debug_var (OPTION_USE_SYSTEM_LIBJPEG) + fl_debug_var (OPTION_USE_SYSTEM_LIBPNG) + fl_debug_var (OPTION_USE_SYSTEM_ZLIB) + fl_debug_var (FLTK_USE_BUILTIN_JPEG) + fl_debug_var (FLTK_USE_BUILTIN_PNG) + fl_debug_var (FLTK_USE_BUILTIN_ZLIB) message ("--- X11 ---") fl_debug_var (X11_FOUND) fl_debug_var (X11_INCLUDE_DIR) diff --git a/README.CMake.txt b/README.CMake.txt index c1a40e691..bd03ec4ea 100644 --- a/README.CMake.txt +++ b/README.CMake.txt @@ -580,12 +580,12 @@ find_package(FLTK REQUIRED CONFIG) add_executable(hello WIN32 MACOSX_BUNDLE hello.cxx) if (APPLE) - target_link_libraries(hello PRIVATE "-framework cocoa") + target_link_libraries (hello PRIVATE "-framework cocoa") endif (APPLE) -target_include_directories(hello PRIVATE ${FLTK_INCLUDE_DIRS}) +target_include_directories (hello PRIVATE ${FLTK_INCLUDE_DIRS}) -target_link_libraries(hello PRIVATE fltk) +target_link_libraries (hello PRIVATE fltk) --- The set(FLTK_DIR ...) command is a superhint to the find_package command. @@ -644,12 +644,12 @@ add_custom_command( add_executable(CubeView WIN32 MACOSX_BUNDLE CubeMain.cxx CubeView.cxx CubeViewUI.cxx) -target_include_directories(CubeView PRIVATE ${FLTK_INCLUDE_DIRS}) +target_include_directories (CubeView PRIVATE ${FLTK_INCLUDE_DIRS}) -target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories (CubeView PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories (CubeView PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(CubeView PRIVATE fltk fltk_gl) +target_link_libraries (CubeView PRIVATE fltk fltk_gl) --- You can repeat the add_custom_command for each fluid file or if you @@ -658,8 +658,8 @@ FLTK_RUN_FLUID for an example of how to run it in a loop. The two lines - target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + target_include_directories (CubeView PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + target_include_directories (CubeView PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) add the current build ("binary") and source directories as include directories. This is necessary for the compiler to find the local header files since the diff --git a/jpeg/CMakeLists.txt b/jpeg/CMakeLists.txt index 4b820a02f..f65f71636 100644 --- a/jpeg/CMakeLists.txt +++ b/jpeg/CMakeLists.txt @@ -1,7 +1,7 @@ # # JPEG library CMake configuration for the Fast Light Toolkit (FLTK). # -# Copyright 1998-2021 by Bill Spitzak and others. +# Copyright 1998-2023 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 diff --git a/jpeg/Makefile b/jpeg/Makefile index 6dd48e361..c83b4bb7a 100644 --- a/jpeg/Makefile +++ b/jpeg/Makefile @@ -4,7 +4,7 @@ # # JPEG library makefile for the Fast Light Toolkit (FLTK). # -# Copyright 1997-2011 by Bill Spitzak and others. +# Copyright 1997-2023 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 @@ -19,7 +19,6 @@ include ../makeinclude - # # Object files... # @@ -74,14 +73,12 @@ OBJS = \ LIBJPEG = ../lib/libfltk_jpeg$(LIBEXT) - # # Make all targets... # all: $(LIBJPEG) - # # Clean all targets and object files... # @@ -90,7 +87,6 @@ clean: $(RM) $(OBJS) $(RM) $(LIBJPEG) - # # Install everything... # @@ -108,7 +104,6 @@ install: $(LIBJPEG) $(INSTALL_DATA) jpeglib.h $(DESTDIR)$(includedir)/FL/images $(INSTALL_DATA) fltk_jpeg_prefix.h $(DESTDIR)$(includedir)/FL/images - # # Uninstall everything... # @@ -123,7 +118,6 @@ uninstall: $(RM) $(includedir)/FL/images/jpeglib.h $(RM) $(includedir)/FL/images/fltk_jpeg_prefix.h - # # libfltk_jpeg.a # @@ -134,7 +128,6 @@ $(LIBJPEG): $(OBJS) $(LIBCOMMAND) $@ $(OBJS) $(RANLIB) $@ - # # Make dependencies... # diff --git a/png/CMakeLists.txt b/png/CMakeLists.txt index b47323fe4..c61b1a544 100644 --- a/png/CMakeLists.txt +++ b/png/CMakeLists.txt @@ -1,7 +1,7 @@ # # PNG library CMake configuration for the Fast Light Toolkit (FLTK). # -# Copyright 1998-2022 by Bill Spitzak and others. +# Copyright 1998-2023 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 @@ -15,7 +15,7 @@ # # source files for png -set(PNG_SRCS +set (PNG_SRCS png.c pngerror.c pngget.c @@ -33,6 +33,13 @@ set(PNG_SRCS pngwutil.c ) +####################################################################### +# Note: This file is used only if we build the bundled PNG library, +# and if we do this we MUST also build and use the *bundled* ZLIB, +# hence we MUST also link against the bundled ZLIB (see below). +# There's no need to check which ZLIB version to use in this context. +####################################################################### + ####################################################################### # Build some files on ARM (e.g. Apple M1 systems) ####################################################################### @@ -43,16 +50,16 @@ set(PNG_SRCS # This includes all non-macOS platforms. if (CMAKE_OSX_ARCHITECTURES) - string(REGEX MATCH "arm64" is_arm "${CMAKE_OSX_ARCHITECTURES}") + string (REGEX MATCH "arm64" is_arm "${CMAKE_OSX_ARCHITECTURES}") else () set (is_arm TRUE) endif () if (is_arm) LIST (APPEND PNG_SRCS - arm/arm_init.c - arm/filter_neon_intrinsics.c - arm/palette_neon_intrinsics.c + arm/arm_init.c + arm/filter_neon_intrinsics.c + arm/palette_neon_intrinsics.c ) endif () @@ -65,8 +72,8 @@ unset (is_arm) ####################################################################### LIST (APPEND PNG_SRCS - powerpc/powerpc_init.c - powerpc/filter_vsx_intrinsics.c + powerpc/powerpc_init.c + powerpc/filter_vsx_intrinsics.c ) ####################################################################### @@ -74,7 +81,7 @@ LIST (APPEND PNG_SRCS ####################################################################### FL_ADD_LIBRARY (fltk_png STATIC "${PNG_SRCS}") -target_link_libraries (fltk_png ${FLTK_ZLIB_LIBRARIES}) +target_link_libraries (fltk_png PUBLIC fltk_z) ####################################################################### # Build the shared library (optional) @@ -83,12 +90,7 @@ target_link_libraries (fltk_png ${FLTK_ZLIB_LIBRARIES}) 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) - else() - target_link_libraries (fltk_png_SHARED ${FLTK_ZLIB_LIBRARIES}) - endif () + target_link_libraries (fltk_png_SHARED PUBLIC fltk_z_SHARED) endif () diff --git a/png/Makefile b/png/Makefile index 3326f7a8c..7fd9a8765 100644 --- a/png/Makefile +++ b/png/Makefile @@ -2,7 +2,7 @@ # PNG library Makefile for the Fast Light Toolkit (FLTK). # # Copyright 1997-2011 by Easy Software Products. -# Copyright 2012-2020 by Bill Spitzak and others. +# Copyright 2012-2023 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 diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt index 1dc30427f..4596a538d 100644 --- a/zlib/CMakeLists.txt +++ b/zlib/CMakeLists.txt @@ -1,7 +1,7 @@ # # ZLIB library CMake configuration for the Fast Light Toolkit (FLTK). # -# Copyright 1998-2021 by Bill Spitzak and others. +# Copyright 1998-2023 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 diff --git a/zlib/Makefile b/zlib/Makefile index c34082679..67fcdd801 100644 --- a/zlib/Makefile +++ b/zlib/Makefile @@ -1,7 +1,7 @@ # -# GNU ZIP library makefile for the Fast Light Toolkit (FLTK). +# ZIP library makefile for the Fast Light Toolkit (FLTK). # -# Copyright 1998-2021 by Bill Spitzak and others. +# Copyright 1998-2023 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 @@ -16,7 +16,6 @@ include ../makeinclude - # # Object files... # @@ -27,14 +26,12 @@ OBJS = adler32.o compress.o crc32.o uncompr.o deflate.o \ LIBZ = ../lib/libfltk_z$(LIBEXT) - # # Make all targets... # all: $(LIBZ) - # # Clean all targets and object files... # @@ -43,7 +40,6 @@ clean: $(RM) $(OBJS) $(RM) $(LIBZ) - # # Install everything... # @@ -59,7 +55,6 @@ install: $(LIBZ) $(INSTALL_DATA) zlib.h $(DESTDIR)$(includedir)/FL/images $(INSTALL_DATA) zutil.h $(DESTDIR)$(includedir)/FL/images - # # Uninstall everything... # @@ -72,7 +67,6 @@ uninstall: $(RM) $(includedir)/FL/images/zlib.h $(RM) $(includedir)/FL/images/zutil.h - # # libfltk_z.a #