From aa95dee697d0d688795839695099c383b0ac39f6 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Mon, 19 Feb 2024 14:25:55 +0200 Subject: [PATCH] build: Update the CMake build options PNG_TOOLS and PNG_FRAMEWORK Update the PNG_TOOLS option: set it to OFF by default when the target is an embedded system, yet still allow it to be overridden. Update the PNG_FRAMEWORK option: force it back to OFF and print a warning if the option was ON but the target is not an Apple system. --- CMakeLists.txt | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 112f05afe0..45bd2d5426 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,9 +62,18 @@ if(APPLE) endif() # Allow the users to switch on/off the auxiliary build and test artifacts. -# NOTE: These artifacts are NOT part of libpng proper, and are subject to change at any time. +# These artifacts are NOT part of libpng proper, and are subject to change +# at any time. option(PNG_TESTS "Build the libpng tests" ON) -option(PNG_TOOLS "Build the libpng tools" ON) + +# Same as above, but for the third-party tools. +# Although these tools are targetted at development environments only, +# the users are allowed to override the option to build by default. +if (ANDROID OR IOS) + option(PNG_TOOLS "Build the libpng tools" OFF) +else() + option(PNG_TOOLS "Build the libpng tools" ON) +endif() # Maintain backwards compatibility with the deprecated option PNG_EXECUTABLES. option(PNG_EXECUTABLES "[Deprecated; please use PNG_TOOLS]" ON) @@ -719,7 +728,13 @@ if(PNG_STATIC) target_link_libraries(png_static PUBLIC ZLIB::ZLIB ${M_LIBRARY}) endif() -if(PNG_FRAMEWORK AND APPLE) +if(PNG_FRAMEWORK AND NOT APPLE) + message(AUTHOR_WARNING + "Setting PNG_FRAMEWORK to OFF, as it only applies to Apple systems") + set(PNG_FRAMEWORK OFF) +endif() + +if(PNG_FRAMEWORK) add_library(png_framework SHARED ${libpng_sources}) add_dependencies(png_framework png_genfiles) list(APPEND PNG_LIBRARY_TARGETS png_framework)