2021-05-07 10:07:42 +02:00
|
|
|
# libPNG
|
|
|
|
# Select the version of libpng to use, default is builtin
|
|
|
|
if (NOT USE_SYSTEM_LIBPNG)
|
|
|
|
# We use libpng's static library and don't need to build the shared library and run the tests
|
2023-07-11 20:40:30 +02:00
|
|
|
set(PNG_SHARED OFF CACHE BOOL "Build shared lib")
|
|
|
|
set(PNG_TESTS OFF CACHE BOOL "Build libpng tests")
|
2024-03-18 00:34:08 +01:00
|
|
|
if (NOT USE_SYSTEM_ZLIB)
|
|
|
|
set(PNG_BUILD_ZLIB ON CACHE BOOL "Custom zlib location, else find_package is used")
|
|
|
|
add_library(ZLIB::ZLIB INTERFACE IMPORTED)
|
|
|
|
target_link_libraries(ZLIB::ZLIB INTERFACE 3rdparty_zlib)
|
|
|
|
endif()
|
2021-05-07 10:07:42 +02:00
|
|
|
set(SKIP_INSTALL_ALL ON)
|
|
|
|
add_subdirectory(libpng EXCLUDE_FROM_ALL)
|
|
|
|
target_include_directories(png_static INTERFACE "${libpng_BINARY_DIR}" "${libpng_SOURCE_DIR}")
|
|
|
|
|
2023-07-11 20:40:30 +02:00
|
|
|
set(LIBPNG_TARGET png_static PARENT_SCOPE)
|
2021-05-07 10:07:42 +02:00
|
|
|
else()
|
|
|
|
find_package(PNG REQUIRED)
|
|
|
|
|
|
|
|
add_library(3rdparty_system_libpng INTERFACE)
|
|
|
|
target_include_directories(3rdparty_system_libpng INTERFACE ${PNG_INCLUDE_DIR})
|
|
|
|
target_link_libraries(3rdparty_system_libpng INTERFACE ${PNG_LIBRARY})
|
|
|
|
target_compile_definitions(3rdparty_system_libpng INTERFACE ${PNG_DEFINITIONS})
|
|
|
|
|
|
|
|
set(LIBPNG_TARGET 3rdparty_system_libpng PARENT_SCOPE)
|
|
|
|
endif()
|