From c8024c7a3b8faec3b65d222c50fb4cfccd3ab03e Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sun, 1 Jan 2023 17:29:23 +0100 Subject: Make sure that zlib and png are both local or system (#621) Autoconf syncs png and zlib configuration Cmake png zlib selection --- CMake/options.cmake | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'CMake') diff --git a/CMake/options.cmake b/CMake/options.cmake index 25c5a181c..b45987d23 100644 --- a/CMake/options.cmake +++ b/CMake/options.cmake @@ -92,13 +92,34 @@ else () endif () ####################################################################### -# Bundled Compression Library : zlib +# Make sure that png and zlib are either system or local for compatibility ####################################################################### if (OPTION_USE_SYSTEM_ZLIB) find_package (ZLIB) endif () +if (OPTION_USE_SYSTEM_LIBPNG) + find_package (PNG) +endif () + +# If we use the system zlib, we must also use the system png zlib and vice versa +# 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) + 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) + message (STATUS "Local png lib selected: overriding z lib to local for compatibility.\n") +endif () + +####################################################################### +# Bundled Compression Library : zlib +####################################################################### + if (OPTION_USE_SYSTEM_ZLIB AND ZLIB_FOUND) set (FLTK_USE_BUILTIN_ZLIB FALSE) set (FLTK_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) @@ -146,10 +167,6 @@ set (HAVE_LIBJPEG 1) # Bundled Image Library : libpng ####################################################################### -if (OPTION_USE_SYSTEM_LIBPNG) - find_package (PNG) -endif () - if (OPTION_USE_SYSTEM_LIBPNG AND PNG_FOUND) set (FLTK_USE_BUILTIN_PNG FALSE) -- cgit v1.2.3