From 14e885a54c4cab19011ec10f466fc992f3e03f4e Mon Sep 17 00:00:00 2001 From: Sam Serrels Date: Mon, 2 Jan 2017 01:36:47 +0000 Subject: [PATCH] Added option to Cmake build allowing a custom location of Zlib to be specified. This is useful in a scenario where libpng is being built as a subproject alongside zlib by another project.. --- CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5d429e9c..5bd8d2803 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,15 @@ set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) # needed packages -find_package(ZLIB REQUIRED) -include_directories(${ZLIB_INCLUDE_DIR}) + +#Allow users to specify location of Zlib, +# Useful if zlib is being built alongside this as a sub-project +option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF) + +IF(NOT PNG_BUILD_ZLIB) + find_package(ZLIB REQUIRED) + include_directories(${ZLIB_INCLUDE_DIR}) +ENDIF(NOT PNG_BUILD_ZLIB) if(NOT WIN32) find_library(M_LIBRARY