This patch provides users the optional hint via the environment variable PNG_ROOT. This comes very useful when libpng is not installed in a default location and/or if several versions are installed in parallel. --- Modules/FindPNG.cmake | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index fa04bf0..b6d0473 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -8,6 +8,9 @@ # # This module searches libpng, the library for working with PNG images. # +# To provide the module with a hint about where to find your libpng +# installation, you can set the environment variable PNG_ROOT. +# # It defines the following variables # # :: @@ -32,6 +35,7 @@ #============================================================================= # Copyright 2002-2009 Kitware, Inc. +# Copyright 2014 Axel Huebl https://github.com/ax3l # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -49,8 +53,10 @@ endif() find_package(ZLIB ${_FIND_ZLIB_ARG}) if(ZLIB_FOUND) - find_path(PNG_PNG_INCLUDE_DIR png.h - /usr/local/include/libpng # OpenBSD + find_path(PNG_PNG_INCLUDE_DIR + NAMES png.h + PATHS /usr/local/include/libpng # OpenBSD + PATHS $ENV{PNG_ROOT}/include # generic hint ) list(APPEND PNG_NAMES png libpng) @@ -75,8 +81,8 @@ if(ZLIB_FOUND) # For compatiblity with versions prior to this multi-config search, honor # any PNG_LIBRARY that is already specified and skip the search. if(NOT PNG_LIBRARY) - find_library(PNG_LIBRARY_RELEASE NAMES ${PNG_NAMES}) - find_library(PNG_LIBRARY_DEBUG NAMES ${PNG_NAMES_DEBUG}) + find_library(PNG_LIBRARY_RELEASE NAMES ${PNG_NAMES} HINTS $ENV{PNG_ROOT}/lib) + find_library(PNG_LIBRARY_DEBUG NAMES ${PNG_NAMES_DEBUG} HINTS $ENV{PNG_ROOT}/lib) include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(PNG) mark_as_advanced(PNG_LIBRARY_RELEASE PNG_LIBRARY_DEBUG) -- 2.0.0
smime.p7s
Description: S/MIME Cryptographic Signature
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers