2016-09-27 22:01:08 +03:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
2013-10-15 19:17:36 +04:00
|
|
|
#.rst:
|
|
|
|
# FindGIF
|
|
|
|
# -------
|
|
|
|
#
|
2016-07-13 06:05:47 +03:00
|
|
|
# This finds the GIF library (giflib)
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
2016-07-13 06:05:47 +03:00
|
|
|
# The module defines the following variables:
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
2016-07-13 06:05:47 +03:00
|
|
|
# ``GIF_FOUND``
|
|
|
|
# True if giflib was found
|
|
|
|
# ``GIF_LIBRARIES``
|
|
|
|
# Libraries to link to in order to use giflib
|
|
|
|
# ``GIF_INCLUDE_DIR``
|
|
|
|
# where to find the headers
|
|
|
|
# ``GIF_VERSION``
|
|
|
|
# 3, 4 or a full version string (eg 5.1.4) for versions >= 4.1.6
|
2011-08-02 02:30:58 +04:00
|
|
|
#
|
|
|
|
# The minimum required version of giflib can be specified using the
|
2013-10-15 19:17:36 +04:00
|
|
|
# standard syntax, e.g. find_package(GIF 4)
|
2007-12-21 04:59:44 +03:00
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
# $GIF_DIR is an environment variable that would correspond to the
|
|
|
|
# ./configure --prefix=$GIF_DIR
|
2008-01-04 20:38:34 +03:00
|
|
|
|
2011-07-27 22:32:59 +04:00
|
|
|
# Created by Eric Wing.
|
2016-07-13 06:05:47 +03:00
|
|
|
# Modifications by Alexander Neundorf, Ben Campbell
|
2007-12-21 04:59:44 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
find_path(GIF_INCLUDE_DIR gif_lib.h
|
2008-06-10 00:04:06 +04:00
|
|
|
HINTS
|
2012-03-29 02:00:54 +04:00
|
|
|
ENV GIF_DIR
|
2007-12-21 04:59:44 +03:00
|
|
|
PATH_SUFFIXES include
|
|
|
|
PATHS
|
|
|
|
~/Library/Frameworks
|
2011-07-27 22:34:09 +04:00
|
|
|
/usr/freeware
|
2007-12-21 04:59:44 +03:00
|
|
|
)
|
|
|
|
|
2008-01-04 20:38:34 +03:00
|
|
|
# the gif library can have many names :-/
|
2012-08-13 21:47:32 +04:00
|
|
|
set(POTENTIAL_GIF_LIBS gif libgif ungif libungif giflib giflib4)
|
2008-01-04 20:38:34 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
find_library(GIF_LIBRARY
|
2008-01-04 20:38:34 +03:00
|
|
|
NAMES ${POTENTIAL_GIF_LIBS}
|
2008-06-10 00:04:06 +04:00
|
|
|
HINTS
|
2012-03-29 02:00:54 +04:00
|
|
|
ENV GIF_DIR
|
2012-03-29 02:51:06 +04:00
|
|
|
PATH_SUFFIXES lib
|
2007-12-21 04:59:44 +03:00
|
|
|
PATHS
|
|
|
|
~/Library/Frameworks
|
|
|
|
/usr/freeware
|
|
|
|
)
|
|
|
|
|
2008-01-04 20:38:34 +03:00
|
|
|
# see readme.txt
|
2012-08-13 21:47:32 +04:00
|
|
|
set(GIF_LIBRARIES ${GIF_LIBRARY})
|
2007-12-21 04:59:44 +03:00
|
|
|
|
2011-08-02 02:30:58 +04:00
|
|
|
# Very basic version detection.
|
|
|
|
# The GIF_LIB_VERSION string in gif_lib.h seems to be unreliable, since it seems
|
|
|
|
# to be always " Version 2.0, " in versions 3.x of giflib.
|
|
|
|
# In version 4 the member UserData was added to GifFileType, so we check for this
|
|
|
|
# one.
|
2016-07-13 06:05:47 +03:00
|
|
|
# Versions after 4.1.6 define GIFLIB_MAJOR, GIFLIB_MINOR, and GIFLIB_RELEASE
|
|
|
|
# see http://giflib.sourceforge.net/gif_lib.html#compatibility
|
2012-08-13 21:47:32 +04:00
|
|
|
if(GIF_INCLUDE_DIR)
|
2012-11-04 00:35:44 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
|
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/CheckStructHasMember.cmake)
|
2011-08-02 02:30:58 +04:00
|
|
|
CMAKE_PUSH_CHECK_STATE()
|
2014-03-30 06:22:54 +04:00
|
|
|
set(CMAKE_REQUIRED_QUIET ${GIF_FIND_QUIETLY})
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_REQUIRED_INCLUDES "${GIF_INCLUDE_DIR}")
|
2016-07-13 06:05:47 +03:00
|
|
|
|
|
|
|
# Check for the specific version defines (>=4.1.6 only)
|
|
|
|
file(STRINGS ${GIF_INCLUDE_DIR}/gif_lib.h _GIF_DEFS REGEX "^[ \t]*#define[ \t]+GIFLIB_(MAJOR|MINOR|RELEASE)")
|
|
|
|
if(_GIF_DEFS)
|
|
|
|
# yay - got exact version info
|
|
|
|
string(REGEX REPLACE ".*GIFLIB_MAJOR ([0-9]+).*" "\\1" _GIF_MAJ "${_GIF_DEFS}")
|
|
|
|
string(REGEX REPLACE ".*GIFLIB_MINOR ([0-9]+).*" "\\1" _GIF_MIN "${_GIF_DEFS}")
|
|
|
|
string(REGEX REPLACE ".*GIFLIB_RELEASE ([0-9]+).*" "\\1" _GIF_REL "${_GIF_DEFS}")
|
|
|
|
set(GIF_VERSION "${_GIF_MAJ}.${_GIF_MIN}.${_GIF_REL}")
|
|
|
|
else()
|
|
|
|
# use UserData field to sniff version instead
|
|
|
|
CHECK_STRUCT_HAS_MEMBER(GifFileType UserData gif_lib.h GIF_GifFileType_UserData )
|
|
|
|
if(GIF_GifFileType_UserData)
|
|
|
|
set(GIF_VERSION 4)
|
|
|
|
else()
|
|
|
|
set(GIF_VERSION 3)
|
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
endif()
|
2016-07-13 06:05:47 +03:00
|
|
|
|
|
|
|
unset(_GIF_MAJ)
|
|
|
|
unset(_GIF_MIN)
|
|
|
|
unset(_GIF_REL)
|
|
|
|
unset(_GIF_DEFS)
|
2011-08-02 02:30:58 +04:00
|
|
|
CMAKE_POP_CHECK_STATE()
|
2012-08-13 21:47:32 +04:00
|
|
|
endif()
|
2011-08-02 02:30:58 +04:00
|
|
|
|
2011-07-27 22:32:59 +04:00
|
|
|
# handle the QUIETLY and REQUIRED arguments and set GIF_FOUND to TRUE if
|
2008-01-04 20:38:34 +03:00
|
|
|
# all listed variables are TRUE
|
2012-08-13 21:47:32 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2011-08-02 02:30:58 +04:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GIF REQUIRED_VARS GIF_LIBRARY GIF_INCLUDE_DIR
|
|
|
|
VERSION_VAR GIF_VERSION )
|
2007-12-21 04:59:44 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
mark_as_advanced(GIF_INCLUDE_DIR GIF_LIBRARY)
|