1 # - Find the ImageMagick binary suite.
2 # This module will search for a set of ImageMagick tools specified
3 # as components in the FIND_PACKAGE call. Typical components include,
4 # but are not limited to (future versions of ImageMagick might have
5 # additional components not listed here):
19 # If no component is specified in the FIND_PACKAGE call, then it only
20 # searches for the ImageMagick executable directory. This code defines
21 # the following variables:
23 # ImageMagick_FOUND - TRUE if all components are found.
24 # ImageMagick_EXECUTABLE_DIR - Full path to executables directory.
25 # ImageMagick_<component>_FOUND - TRUE if <component> is found.
26 # ImageMagick_<component>_EXECUTABLE - Full path to <component> executable.
28 # There are also components for the following ImageMagick APIs:
34 # For these components the following variables are set:
36 # ImageMagick_FOUND - TRUE if all components are found.
37 # ImageMagick_INCLUDE_DIRS - Full paths to all include dirs.
38 # ImageMagick_LIBRARIES - Full paths to all libraries.
39 # ImageMagick_<component>_FOUND - TRUE if <component> is found.
40 # ImageMagick_<component>_INCLUDE_DIRS - Full path to <component> include dirs.
41 # ImageMagick_<component>_LIBRARIES - Full path to <component> libraries.
44 # FIND_PACKAGE(ImageMagick)
45 # FIND_PACKAGE(ImageMagick COMPONENTS convert)
46 # FIND_PACKAGE(ImageMagick COMPONENTS convert mogrify display)
47 # FIND_PACKAGE(ImageMagick COMPONENTS Magick++)
48 # FIND_PACKAGE(ImageMagick COMPONENTS Magick++ convert)
50 # Note that the standard FIND_PACKAGE features are supported
51 # (i.e., QUIET, REQUIRED, etc.).
53 # Copyright (c) 2007-2008,
54 # Miguel A. Figueroa-Villanueva, miguelf at ieee dot org.
56 # Redistribution and use is allowed according to the terms of the BSD license.
57 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
59 #---------------------------------------------------------------------
61 #---------------------------------------------------------------------
62 FUNCTION(FIND_IMAGEMAGICK_API component header)
63 SET(ImageMagick_${component}_FOUND FALSE PARENT_SCOPE)
65 FIND_PATH(ImageMagick_${component}_INCLUDE_DIR
68 ${ImageMagick_INCLUDE_DIRS}
69 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]/include"
72 DOC "Path to the ImageMagick include dir."
74 FIND_LIBRARY(ImageMagick_${component}_LIBRARY
77 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]/lib"
78 DOC "Path to the ImageMagick Magick++ library."
81 IF(ImageMagick_${component}_INCLUDE_DIR AND ImageMagick_${component}_LIBRARY)
82 SET(ImageMagick_${component}_FOUND TRUE PARENT_SCOPE)
84 LIST(APPEND ImageMagick_INCLUDE_DIRS
85 ${ImageMagick_${component}_INCLUDE_DIR}
87 LIST(REMOVE_DUPLICATES ImageMagick_INCLUDE_DIRS)
88 SET(ImageMagick_INCLUDE_DIRS ${ImageMagick_INCLUDE_DIRS} PARENT_SCOPE)
90 LIST(APPEND ImageMagick_LIBRARIES
91 ${ImageMagick_${component}_LIBRARY}
93 SET(ImageMagick_LIBRARIES ${ImageMagick_LIBRARIES} PARENT_SCOPE)
94 ENDIF(ImageMagick_${component}_INCLUDE_DIR AND ImageMagick_${component}_LIBRARY)
95 ENDFUNCTION(FIND_IMAGEMAGICK_API)
97 FUNCTION(FIND_IMAGEMAGICK_EXE component)
98 SET(_IMAGEMAGICK_EXECUTABLE
99 ${ImageMagick_EXECUTABLE_DIR}/${component}${CMAKE_EXECUTABLE_SUFFIX})
100 IF(EXISTS ${_IMAGEMAGICK_EXECUTABLE})
101 SET(ImageMagick_${component}_EXECUTABLE
102 ${_IMAGEMAGICK_EXECUTABLE}
105 SET(ImageMagick_${component}_FOUND TRUE PARENT_SCOPE)
106 ELSE(EXISTS ${_IMAGEMAGICK_EXECUTABLE})
107 SET(ImageMagick_${component}_FOUND FALSE PARENT_SCOPE)
108 ENDIF(EXISTS ${_IMAGEMAGICK_EXECUTABLE})
109 ENDFUNCTION(FIND_IMAGEMAGICK_EXE)
111 #---------------------------------------------------------------------
113 #---------------------------------------------------------------------
114 # Try to find a ImageMagick installation binary path.
115 FIND_PATH(ImageMagick_EXECUTABLE_DIR
116 NAMES mogrify${CMAKE_EXECUTABLE_SUFFIX}
118 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]"
119 DOC "Path to the ImageMagick binary directory."
122 FIND_PATH(ImageMagick_EXECUTABLE_DIR
123 NAMES mogrify${CMAKE_EXECUTABLE_SUFFIX}
126 # Find each component. Search for all tools in same dir
127 # <ImageMagick_EXECUTABLE_DIR>; otherwise they should be found
128 # independently and not in a cohesive module such as this one.
129 SET(ImageMagick_FOUND TRUE)
130 FOREACH(component ${ImageMagick_FIND_COMPONENTS}
131 # DEPRECATED: forced components for backward compatibility
132 convert mogrify import montage composite
134 IF(component STREQUAL "Magick++")
135 FIND_IMAGEMAGICK_API(Magick++ Magick++.h
136 Magick++ CORE_RL_Magick++_
138 ELSEIF(component STREQUAL "MagickWand")
139 FIND_IMAGEMAGICK_API(MagickWand wand/MagickWand.h
140 Wand MagickWand CORE_RL_wand_
142 ELSEIF(component STREQUAL "MagickCore")
143 FIND_IMAGEMAGICK_API(MagickCore magick/MagickCore.h
144 Magick MagickCore CORE_RL_magick_
146 ELSE(component STREQUAL "Magick++")
147 IF(ImageMagick_EXECUTABLE_DIR)
148 FIND_IMAGEMAGICK_EXE(${component})
149 ENDIF(ImageMagick_EXECUTABLE_DIR)
150 ENDIF(component STREQUAL "Magick++")
152 IF(NOT ImageMagick_${component}_FOUND)
153 LIST(FIND ImageMagick_FIND_COMPONENTS ${component} is_requested)
154 IF(is_requested GREATER -1)
155 SET(ImageMagick_FOUND FALSE)
156 ENDIF(is_requested GREATER -1)
157 ENDIF(NOT ImageMagick_${component}_FOUND)
158 ENDFOREACH(component)
160 SET(ImageMagick_INCLUDE_DIRS ${ImageMagick_INCLUDE_DIRS})
161 SET(ImageMagick_LIBRARIES ${ImageMagick_LIBRARIES})
163 #---------------------------------------------------------------------
164 # Standard Package Output
165 #---------------------------------------------------------------------
166 INCLUDE(FindPackageHandleStandardArgs)
167 FIND_PACKAGE_HANDLE_STANDARD_ARGS(
168 ImageMagick DEFAULT_MSG ImageMagick_FOUND
170 # Maintain consistency with all other variables.
171 SET(ImageMagick_FOUND ${IMAGEMAGICK_FOUND})
173 #---------------------------------------------------------------------
174 # DEPRECATED: Setting variables for backward compatibility.
175 #---------------------------------------------------------------------
176 SET(IMAGEMAGICK_BINARY_PATH ${ImageMagick_EXECUTABLE_DIR}
177 CACHE PATH "Path to the ImageMagick binary directory.")
178 SET(IMAGEMAGICK_CONVERT_EXECUTABLE ${ImageMagick_convert_EXECUTABLE}
179 CACHE FILEPATH "Path to ImageMagick's convert executable.")
180 SET(IMAGEMAGICK_MOGRIFY_EXECUTABLE ${ImageMagick_mogrify_EXECUTABLE}
181 CACHE FILEPATH "Path to ImageMagick's mogrify executable.")
182 SET(IMAGEMAGICK_IMPORT_EXECUTABLE ${ImageMagick_import_EXECUTABLE}
183 CACHE FILEPATH "Path to ImageMagick's import executable.")
184 SET(IMAGEMAGICK_MONTAGE_EXECUTABLE ${ImageMagick_montage_EXECUTABLE}
185 CACHE FILEPATH "Path to ImageMagick's montage executable.")
186 SET(IMAGEMAGICK_COMPOSITE_EXECUTABLE ${ImageMagick_composite_EXECUTABLE}
187 CACHE FILEPATH "Path to ImageMagick's composite executable.")
189 IMAGEMAGICK_BINARY_PATH
190 IMAGEMAGICK_CONVERT_EXECUTABLE
191 IMAGEMAGICK_MOGRIFY_EXECUTABLE
192 IMAGEMAGICK_IMPORT_EXECUTABLE
193 IMAGEMAGICK_MONTAGE_EXECUTABLE
194 IMAGEMAGICK_COMPOSITE_EXECUTABLE