1#
2# Find a PNG library
3#
4#
5# This file is used to manage using either a natively provided PNG library or the one in v3p if provided.
6#
7#
8# As per the standard scheme the following definitions are used
9# PNG_INCLUDE_DIR - where to find png.h
10# PNG_LIBRARIES   - the set of libraries to include to use PNG.
11# PNG_DEFINITIONS - You should ADD_DEFINITONS(${PNG_DEFINITIONS}) before compiling code that includes png library files.
12# PNG_FOUND       - TRUE, if available somewhere on the system.
13
14# Additionally
15# VXL_USING_NATIVE_PNG  - True if we are using a PNG library provided outsidevxl (or v3p)
16
17
18# If this FORCE variable is unset or is FALSE, try to find a native library.
19if( VXL_FORCE_V3P_PNG )
20else()
21# Suppress not found messages
22  set( ZLIB_FIND_QUIETLY "YES" )
23  find_package( PNG QUIET )
24  set( ZLIB_FIND_QUIETLY )
25endif()
26
27if(PNG_FOUND)
28
29  set(VXL_USING_NATIVE_PNG "YES")
30
31else()
32
33  include( ${MODULE_PATH}/FindZLIB.cmake )
34  if(ZLIB_FOUND)
35
36  #
37  # At some point, in a "release" version, it is possible that someone
38  # will not have the v3p png library, so make sure the headers
39  # exist.
40  #
41
42
43    if(EXISTS ${VXL_ROOT_SOURCE_DIR}/v3p/png/png.h)
44
45      set( PNG_FOUND "YES" )
46      set( PNG_LIBRARIES png)
47      set( PNG_INCLUDE_DIR ${VXL_ROOT_SOURCE_DIR}/v3p/png ${ZLIB_INCLUDE_DIR} )
48      set( PNG_INSTALL_INCLUDE_DIR
49        ${CMAKE_INSTALL_PREFIX}/include/vxl/v3p/png
50        ${ZLIB_INSTALL_INCLUDE_DIR}
51      )
52
53      if(CYGWIN)
54        if(BUILD_SHARED_LIBS)
55           # No need to define PNG_USE_DLL here, because it's default for Cygwin.
56        else()
57          set(PNG_DEFINITIONS  ${PNG_DEFINITIONS} -DPNG_STATIC)
58        endif()
59      endif()
60
61    endif()
62
63  endif()
64endif()
65