build: use pkg-config to find correct libpng version

as recommended by this StackOverflow answer: https://stackoverflow.com/a/30981965
This commit is contained in:
Gaeel Bradshaw 2021-08-15 13:15:33 +02:00
parent 3f75fd5a3a
commit 40e4869f69

View file

@ -2,7 +2,21 @@ cmake_minimum_required(VERSION 2.8.12)
project(MINEDMAP CXX)
find_package(PNG REQUIRED)
# search for pkg-config
include (FindPkgConfig)
if (NOT PKG_CONFIG_FOUND)
message (FATAL_ERROR "pkg-config not found")
endif ()
# check for libpng
pkg_check_modules (LIBPNG libpng16 REQUIRED)
if (NOT LIBPNG_FOUND)
message(FATAL_ERROR "You don't seem to have libpng16 development libraries installed")
else ()
include_directories (${LIBPNG_INCLUDE_DIRS})
link_directories (${LIBPNG_LIBRARY_DIRS})
link_libraries (${LIBPNG_LIBRARIES})
endif ()
find_package(ZLIB REQUIRED)