FindGIF.cmake 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #.rst:
  2. # FindGIF
  3. # -------
  4. #
  5. #
  6. #
  7. # This module searches giflib and defines GIF_LIBRARIES - libraries to
  8. # link to in order to use GIF GIF_FOUND, if false, do not try to link
  9. # GIF_INCLUDE_DIR, where to find the headers GIF_VERSION, reports either
  10. # version 4 or 3 (for everything before version 4)
  11. #
  12. # The minimum required version of giflib can be specified using the
  13. # standard syntax, e.g. find_package(GIF 4)
  14. #
  15. # $GIF_DIR is an environment variable that would correspond to the
  16. # ./configure --prefix=$GIF_DIR
  17. #=============================================================================
  18. # Copyright 2007-2009 Kitware, Inc.
  19. #
  20. # Distributed under the OSI-approved BSD License (the "License");
  21. # see accompanying file Copyright.txt for details.
  22. #
  23. # This software is distributed WITHOUT ANY WARRANTY; without even the
  24. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  25. # See the License for more information.
  26. #=============================================================================
  27. # (To distribute this file outside of CMake, substitute the full
  28. # License text for the above reference.)
  29. # Created by Eric Wing.
  30. # Modifications by Alexander Neundorf
  31. find_path(GIF_INCLUDE_DIR gif_lib.h
  32. HINTS
  33. ENV GIF_DIR
  34. PATH_SUFFIXES include
  35. PATHS
  36. ~/Library/Frameworks
  37. /usr/freeware
  38. )
  39. # the gif library can have many names :-/
  40. set(POTENTIAL_GIF_LIBS gif libgif ungif libungif giflib giflib4)
  41. find_library(GIF_LIBRARY
  42. NAMES ${POTENTIAL_GIF_LIBS}
  43. HINTS
  44. ENV GIF_DIR
  45. PATH_SUFFIXES lib
  46. PATHS
  47. ~/Library/Frameworks
  48. /usr/freeware
  49. )
  50. # see readme.txt
  51. set(GIF_LIBRARIES ${GIF_LIBRARY})
  52. # Very basic version detection.
  53. # The GIF_LIB_VERSION string in gif_lib.h seems to be unreliable, since it seems
  54. # to be always " Version 2.0, " in versions 3.x of giflib.
  55. # In version 4 the member UserData was added to GifFileType, so we check for this
  56. # one.
  57. # http://giflib.sourcearchive.com/documentation/4.1.4/files.html
  58. if(GIF_INCLUDE_DIR)
  59. include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
  60. include(${CMAKE_CURRENT_LIST_DIR}/CheckStructHasMember.cmake)
  61. CMAKE_PUSH_CHECK_STATE()
  62. set(CMAKE_REQUIRED_QUIET ${GIF_FIND_QUIETLY})
  63. set(GIF_VERSION 3)
  64. set(CMAKE_REQUIRED_INCLUDES "${GIF_INCLUDE_DIR}")
  65. CHECK_STRUCT_HAS_MEMBER(GifFileType UserData gif_lib.h GIF_GifFileType_UserData )
  66. if(GIF_GifFileType_UserData)
  67. set(GIF_VERSION 4)
  68. endif()
  69. CMAKE_POP_CHECK_STATE()
  70. endif()
  71. # handle the QUIETLY and REQUIRED arguments and set GIF_FOUND to TRUE if
  72. # all listed variables are TRUE
  73. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  74. FIND_PACKAGE_HANDLE_STANDARD_ARGS(GIF REQUIRED_VARS GIF_LIBRARY GIF_INCLUDE_DIR
  75. VERSION_VAR GIF_VERSION )
  76. mark_as_advanced(GIF_INCLUDE_DIR GIF_LIBRARY)