libpng/contrib/pngminus/CMakeLists.txt
Cosmin Truta c993ae4c67 pngminus: Update CMake file; rename test scripts; add .gitignore
Raise the minimum required CMake version to 3.5.

Add the configuration option `PNGMINUS_USE_SYSTEM_PNG` for compiling
and linking with the system libpng library instead of the internal one.

Remove the old configuration option `PNGMINUS_USE_STATIC_LIBRARIES`.
When using the internal libpng (via `PNGMINUS_USE_SYSTEM_PNG=OFF`),
simply enforce static linking and produce single-file executables.

Rename the scripts "png2pnm.sh" (etc.) to "test_png2pnm.sh" (etc.),
to make it obvious that they are test drivers, not program launchers.

Add a .gitignore file for project-specific build and test artifacts.
2024-01-05 19:59:07 +02:00

42 lines
1.5 KiB
CMake

# Copyright (c) 2018-2024 Cosmin Truta
#
# This software is released under the MIT license. For conditions of
# distribution and use, see the LICENSE file part of this package.
cmake_minimum_required(VERSION 3.5)
project(PNGMINUS C)
option(PNGMINUS_USE_SYSTEM_PNG
"Use the libpng build found in the system" OFF)
add_executable(png2pnm png2pnm.c)
add_executable(pnm2png pnm2png.c)
if(PNGMINUS_USE_SYSTEM_PNG)
# Use the system libpng.
find_package(PNG REQUIRED)
target_link_libraries(png2pnm PRIVATE PNG::PNG)
target_link_libraries(pnm2png PRIVATE PNG::PNG)
else()
# Build and use the internal libpng.
# Configure libpng for static linking, to produce single-file executables.
set(PNG_STATIC ON
CACHE STRING "Build the internal libpng as a static library" FORCE)
set(PNG_SHARED OFF
CACHE STRING "Build the internal libpng as a shared library" FORCE)
set(PNG_FRAMEWORK OFF
CACHE STRING "Build the internal libpng as a framework bundle" FORCE)
add_subdirectory(../.. libpng)
target_include_directories(png2pnm PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/libpng>"
)
target_include_directories(pnm2png PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/libpng>"
)
target_link_libraries(png2pnm PRIVATE png_static)
target_link_libraries(pnm2png PRIVATE png_static)
endif()