From 40e4869f69a511e4cfb7a00fd62edf2fe4866294 Mon Sep 17 00:00:00 2001 From: Gaeel Bradshaw Date: Sun, 15 Aug 2021 13:15:33 +0200 Subject: [PATCH] build: use pkg-config to find correct libpng version as recommended by this StackOverflow answer: https://stackoverflow.com/a/30981965 --- CMakeLists.txt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 362fa58..f457b20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)