FindTIFF.cmake 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #.rst:
  2. # FindTIFF
  3. # --------
  4. #
  5. # Find TIFF library
  6. #
  7. # Find the native TIFF includes and library This module defines
  8. #
  9. # ::
  10. #
  11. # TIFF_INCLUDE_DIR, where to find tiff.h, etc.
  12. # TIFF_LIBRARIES, libraries to link against to use TIFF.
  13. # TIFF_FOUND, If false, do not try to use TIFF.
  14. #
  15. # also defined, but not for general use are
  16. #
  17. # ::
  18. #
  19. # TIFF_LIBRARY, where to find the TIFF library.
  20. #=============================================================================
  21. # Copyright 2002-2009 Kitware, Inc.
  22. #
  23. # Distributed under the OSI-approved BSD License (the "License");
  24. # see accompanying file Copyright.txt for details.
  25. #
  26. # This software is distributed WITHOUT ANY WARRANTY; without even the
  27. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  28. # See the License for more information.
  29. #=============================================================================
  30. # (To distribute this file outside of CMake, substitute the full
  31. # License text for the above reference.)
  32. set(TIFF_NAMES ${TIFF_NAMES} tiff libtiff tiff3 libtiff3)
  33. find_path(TIFF_INCLUDE_DIR tiff.h
  34. HINTS ENV TIFF_DIR
  35. PATH_SUFFIXES include/libtiff include
  36. PATHS
  37. ~/Library/Frameworks
  38. /Library/Frameworks
  39. /usr/local
  40. /usr
  41. /sw # Fink
  42. /opt/local # DarwinPorts
  43. /opt/csw # Blastwave
  44. /opt
  45. )
  46. find_library(TIFF_LIBRARY
  47. NAMES ${TIFF_NAMES}
  48. HINTS ENV TIFF_DIR
  49. PATH_SUFFIXES lib
  50. PATHS
  51. ~/Library/Frameworks
  52. /Library/Frameworks
  53. /usr/local
  54. /usr
  55. /sw
  56. /opt/local
  57. /opt/csw
  58. /opt
  59. )
  60. if(TIFF_INCLUDE_DIR AND EXISTS "${TIFF_INCLUDE_DIR}/tiffvers.h")
  61. file(STRINGS "${TIFF_INCLUDE_DIR}/tiffvers.h" tiff_version_str
  62. REGEX "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version .*")
  63. string(REGEX REPLACE "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version +([^ \\n]*).*"
  64. "\\1" TIFF_VERSION_STRING "${tiff_version_str}")
  65. unset(tiff_version_str)
  66. endif()
  67. set(TIFF_INCLUDE_DIRS ${TIFF_INCLUDE_DIR})
  68. # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if
  69. # all listed variables are TRUE
  70. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  71. FIND_PACKAGE_HANDLE_STANDARD_ARGS(TIFF
  72. REQUIRED_VARS TIFF_LIBRARY TIFF_INCLUDE_DIRS
  73. VERSION_VAR TIFF_VERSION_STRING
  74. )
  75. if(TIFF_FOUND)
  76. set( TIFF_LIBRARIES ${TIFF_LIBRARY} )
  77. endif()
  78. mark_as_advanced(TIFF_INCLUDE_DIRS TIFF_LIBRARY)