From 06a838a1507e8ce1643e54a91a6e32c920b87410 Mon Sep 17 00:00:00 2001 From: Zach Lewis Date: Wed, 30 Oct 2024 16:00:46 -0400 Subject: [PATCH] deps(PNG): Add build recipe Signed-off-by: Zach Lewis --- src/cmake/build_PNG.cmake | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/cmake/build_PNG.cmake diff --git a/src/cmake/build_PNG.cmake b/src/cmake/build_PNG.cmake new file mode 100644 index 0000000000..ec6b293864 --- /dev/null +++ b/src/cmake/build_PNG.cmake @@ -0,0 +1,54 @@ +# Copyright Contributors to the OpenImageIO project. +# SPDX-License-Identifier: Apache-2.0 +# https://github.com/AcademySoftwareFoundation/OpenImageIO + +###################################################################### +# PNG by hand! +###################################################################### + +set_cache (PNG_BUILD_VERSION 1.6.44 "PNG version for local builds") +set (PNG_GIT_REPOSITORY "https://github.com/glennrp/libpng") +set (PNG_GIT_TAG "v${PNG_BUILD_VERSION}") + +set_cache (PNG_BUILD_SHARED_LIBS ${LOCAL_BUILD_SHARED_LIBS_DEFAULT} + DOC "Should execute a local PNG build, if necessary, build shared libraries" ADVANCED) + +string (MAKE_C_IDENTIFIER ${PNG_BUILD_VERSION} PNG_VERSION_IDENT) + +unset (PNG_FOUND) +unset (PNG_LIBRARIES) +unset (PNG_INCLUDE_DIRS) +unset (PNG_INCLUDE_DIR) + +build_dependency_with_cmake (PNG + VERSION ${PNG_BUILD_VERSION} + GIT_REPOSITORY ${PNG_GIT_REPOSITORY} + GIT_TAG ${PNG_GIT_TAG} + CMAKE_ARGS + -D PNG_SHARED=${PNG_BUILD_SHARED_LIBS} + -D PNG_STATIC=ON + -D PNG_EXECUTABLES=OFF + -D PNG_TESTS=OFF + -D PNG_FRAMEWORK=OFF + -D CMAKE_POSITION_INDEPENDENT_CODE=ON + -D CMAKE_INSTALL_LIBDIR=lib + ) + + +set (PNG_REFIND FALSE) +set (PNG_REFIND_VERSION ${PNG_BUILD_VERSION}) + + +set (PNG_REFIND_ARGS EXACT REQUIRED) + + +if (PNG_BUILD_VERSION VERSION_GREATER 1.6.43) + list (APPEND PNG_REFIND_ARGS CONFIG) +endif () + + +find_package(PNG ${PNG_REFIND_VERSION} ${PNG_REFIND_ARGS}) + +if (PNG_BUILD_SHARED_LIBS) + install_local_dependency_libs (PNG png) +endif ()