Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / FindTIFF.cmake
1 # - Find TIFF library
2 # Find the native TIFF includes and library
3 # This module defines
4 #  TIFF_INCLUDE_DIR, where to find tiff.h, etc.
5 #  TIFF_LIBRARIES, libraries to link against to use TIFF.
6 #  TIFF_FOUND, If false, do not try to use TIFF.
7 # also defined, but not for general use are
8 #  TIFF_LIBRARY, where to find the TIFF library.
9
10 #=============================================================================
11 # Copyright 2002-2009 Kitware, Inc.
12 #
13 # Distributed under the OSI-approved BSD License (the "License");
14 # see accompanying file Copyright.txt for details.
15 #
16 # This software is distributed WITHOUT ANY WARRANTY; without even the
17 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 # See the License for more information.
19 #=============================================================================
20 # (To distribute this file outside of CMake, substitute the full
21 #  License text for the above reference.)
22
23 find_path(TIFF_INCLUDE_DIR tiff.h)
24
25 set(TIFF_NAMES ${TIFF_NAMES} tiff libtiff tiff3 libtiff3)
26 find_library(TIFF_LIBRARY NAMES ${TIFF_NAMES} )
27
28 if(TIFF_INCLUDE_DIR AND EXISTS "${TIFF_INCLUDE_DIR}/tiffvers.h")
29     file(STRINGS "${TIFF_INCLUDE_DIR}/tiffvers.h" tiff_version_str
30          REGEX "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version .*")
31
32     string(REGEX REPLACE "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version +([^ \\n]*).*"
33            "\\1" TIFF_VERSION_STRING "${tiff_version_str}")
34     unset(tiff_version_str)
35 endif()
36
37 # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if
38 # all listed variables are TRUE
39 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
40 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TIFF
41                                   REQUIRED_VARS TIFF_LIBRARY TIFF_INCLUDE_DIR
42                                   VERSION_VAR TIFF_VERSION_STRING)
43
44 if(TIFF_FOUND)
45   set( TIFF_LIBRARIES ${TIFF_LIBRARY} )
46 endif()
47
48 mark_as_advanced(TIFF_INCLUDE_DIR TIFF_LIBRARY)