diff options
author | Maximilian Heinzler <m.heinzler@heinzler.de> | 2018-11-18 15:59:50 (GMT) |
---|---|---|
committer | Maximilian Heinzler <m.heinzler@heinzler.de> | 2018-11-20 20:07:03 (GMT) |
commit | 5bc64fe6c25f3c02dda7d22eb65c07bdf2e6eb46 (patch) | |
tree | ce77bf984e0afb4c545c0aea3c6e662703975fa3 /Modules/FindGIF.cmake | |
parent | ea52ec9420a6f147a78276bda8110999faa9e094 (diff) | |
download | CMake-5bc64fe6c25f3c02dda7d22eb65c07bdf2e6eb46.zip CMake-5bc64fe6c25f3c02dda7d22eb65c07bdf2e6eb46.tar.gz CMake-5bc64fe6c25f3c02dda7d22eb65c07bdf2e6eb46.tar.bz2 |
FindGIF: Modernize
This brings the module up to the current find module standards by adding
the GIF_INCLUDE_DIRS variable and the target GIF::GIF. It also updates
the documentation style to that of similar modules.
Diffstat (limited to 'Modules/FindGIF.cmake')
-rw-r--r-- | Modules/FindGIF.cmake | 60 |
1 files changed, 47 insertions, 13 deletions
diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake index 9a995af..9687b57 100644 --- a/Modules/FindGIF.cmake +++ b/Modules/FindGIF.cmake @@ -7,22 +7,43 @@ FindGIF This finds the GIF library (giflib) -The module defines the following variables: +Imported targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` target: + +``GIF::GIF`` + The giflib library, if found. + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: ``GIF_FOUND`` - True if giflib was found + If false, do not try to use GIF. +``GIF_INCLUDE_DIRS`` + where to find gif_lib.h, etc. ``GIF_LIBRARIES`` - Libraries to link to in order to use giflib -``GIF_INCLUDE_DIR`` - where to find the headers + the libraries needed to use GIF. ``GIF_VERSION`` - 3, 4 or a full version string (eg 5.1.4) for versions >= 4.1.6 + 3, 4 or a full version string (eg 5.1.4) for versions >= 4.1.6. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: -The minimum required version of giflib can be specified using the -standard syntax, e.g. find_package(GIF 4) +``GIF_INCLUDE_DIR`` + where to find the GIF headers. +``GIF_LIBRARY`` + where to find the GIF library. + +Hints +^^^^^ -$GIF_DIR is an environment variable that would correspond to the -./configure --prefix=$GIF_DIR +``GIF_DIR`` is an environment variable that would correspond to the +``./configure --prefix=$GIF_DIR``. #]=======================================================================] # Created by Eric Wing. @@ -44,9 +65,6 @@ find_library(GIF_LIBRARY PATH_SUFFIXES lib ) -# see readme.txt -set(GIF_LIBRARIES ${GIF_LIBRARY}) - # 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. @@ -90,4 +108,20 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GIF REQUIRED_VARS GIF_LIBRARY GIF_INCLUDE_DIR VERSION_VAR GIF_VERSION ) +if(GIF_FOUND) + set(GIF_INCLUDE_DIRS "${GIF_INCLUDE_DIR}") + set(GIF_LIBRARIES ${GIF_LIBRARY}) + + if(NOT TARGET GIF::GIF) + add_library(GIF::GIF UNKNOWN IMPORTED) + set_target_properties(GIF::GIF PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${GIF_INCLUDE_DIRS}") + if(EXISTS "${GIF_LIBRARY}") + set_target_properties(GIF::GIF PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${GIF_LIBRARY}") + endif() + endif() +endif() + mark_as_advanced(GIF_INCLUDE_DIR GIF_LIBRARY) |