1 | # Copyright (c) 2018-2024 Cosmin Truta
|
---|
2 | #
|
---|
3 | # This software is released under the MIT license. For conditions of
|
---|
4 | # distribution and use, see the LICENSE file part of this package.
|
---|
5 |
|
---|
6 | cmake_minimum_required(VERSION 3.5)
|
---|
7 |
|
---|
8 | project(PNGMINUS C)
|
---|
9 |
|
---|
10 | option(PNGMINUS_USE_SYSTEM_PNG
|
---|
11 | "Use the libpng build found in the system" OFF)
|
---|
12 |
|
---|
13 | add_executable(png2pnm png2pnm.c)
|
---|
14 | add_executable(pnm2png pnm2png.c)
|
---|
15 |
|
---|
16 | if(PNGMINUS_USE_SYSTEM_PNG)
|
---|
17 | # Use the system libpng.
|
---|
18 | find_package(PNG REQUIRED)
|
---|
19 | target_link_libraries(png2pnm PRIVATE PNG::PNG)
|
---|
20 | target_link_libraries(pnm2png PRIVATE PNG::PNG)
|
---|
21 | else()
|
---|
22 | # Build and use the internal libpng.
|
---|
23 | # Configure libpng for static linking, to produce single-file executables.
|
---|
24 | set(PNG_STATIC ON
|
---|
25 | CACHE STRING "Build the internal libpng as a static library" FORCE)
|
---|
26 | set(PNG_SHARED OFF
|
---|
27 | CACHE STRING "Build the internal libpng as a shared library" FORCE)
|
---|
28 | set(PNG_FRAMEWORK OFF
|
---|
29 | CACHE STRING "Build the internal libpng as a framework bundle" FORCE)
|
---|
30 | add_subdirectory(../.. libpng)
|
---|
31 | target_include_directories(png2pnm PRIVATE
|
---|
32 | "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>"
|
---|
33 | "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/libpng>"
|
---|
34 | )
|
---|
35 | target_include_directories(pnm2png PRIVATE
|
---|
36 | "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>"
|
---|
37 | "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/libpng>"
|
---|
38 | )
|
---|
39 | target_link_libraries(png2pnm PRIVATE png_static)
|
---|
40 | target_link_libraries(pnm2png PRIVATE png_static)
|
---|
41 | endif()
|
---|