summaryrefslogtreecommitdiff
path: root/Build/source/libs/libpng/libpng-src/contrib/pngminus/CMakeLists.txt
blob: d7893648a72f0f47d8da3b3233b438136c341d47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 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()