FindGIF.cmake 2.7 KB

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