FindImageMagick.cmake 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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):
  6. #
  7. # animate
  8. # compare
  9. # composite
  10. # conjure
  11. # convert
  12. # display
  13. # identify
  14. # import
  15. # mogrify
  16. # montage
  17. # stream
  18. #
  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:
  22. #
  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.
  27. #
  28. # There are also components for the following ImageMagick APIs:
  29. #
  30. # Magick++
  31. # MagickWand
  32. # Magick
  33. #
  34. # For these components the following variables are set:
  35. #
  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.
  42. #
  43. # Example Usages:
  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)
  49. #
  50. # Note that the standard FIND_PACKAGE features are supported
  51. # (i.e., QUIET, REQUIRED, etc.).
  52. # Copyright (c) 2007-2008,
  53. # Miguel A. Figueroa-Villanueva, miguelf at ieee dot org.
  54. #
  55. # Redistribution and use is allowed according to the terms of the BSD license.
  56. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  57. #---------------------------------------------------------------------
  58. # Helper functions
  59. #---------------------------------------------------------------------
  60. FUNCTION(FIND_IMAGEMAGICK_API component header)
  61. SET(ImageMagick_${component}_FOUND FALSE PARENT_SCOPE)
  62. FIND_PATH(ImageMagick_${component}_INCLUDE_DIR
  63. NAMES ${header}
  64. PATHS
  65. ${ImageMagick_INCLUDE_DIRS}
  66. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]/include"
  67. PATH_SUFFIXES
  68. ImageMagick
  69. DOC "Path to the ImageMagick include dir."
  70. )
  71. FIND_LIBRARY(ImageMagick_${component}_LIBRARY
  72. NAMES ${ARGN}
  73. PATHS
  74. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]/lib"
  75. DOC "Path to the ImageMagick Magick++ library."
  76. )
  77. IF(ImageMagick_${component}_INCLUDE_DIR AND ImageMagick_${component}_LIBRARY)
  78. SET(ImageMagick_${component}_FOUND TRUE PARENT_SCOPE)
  79. LIST(APPEND ImageMagick_INCLUDE_DIRS
  80. ${ImageMagick_${component}_INCLUDE_DIR}
  81. )
  82. LIST(REMOVE_DUPLICATES ImageMagick_INCLUDE_DIRS)
  83. SET(ImageMagick_INCLUDE_DIRS ${ImageMagick_INCLUDE_DIRS} PARENT_SCOPE)
  84. LIST(APPEND ImageMagick_LIBRARIES
  85. ${ImageMagick_${component}_LIBRARY}
  86. )
  87. SET(ImageMagick_LIBRARIES ${ImageMagick_LIBRARIES} PARENT_SCOPE)
  88. ENDIF(ImageMagick_${component}_INCLUDE_DIR AND ImageMagick_${component}_LIBRARY)
  89. ENDFUNCTION(FIND_IMAGEMAGICK_API)
  90. FUNCTION(FIND_IMAGEMAGICK_EXE component)
  91. SET(_IMAGEMAGICK_EXECUTABLE
  92. ${ImageMagick_EXECUTABLE_DIR}/${component}${CMAKE_EXECUTABLE_SUFFIX})
  93. IF(EXISTS ${_IMAGEMAGICK_EXECUTABLE})
  94. SET(ImageMagick_${component}_EXECUTABLE
  95. ${_IMAGEMAGICK_EXECUTABLE}
  96. PARENT_SCOPE
  97. )
  98. SET(ImageMagick_${component}_FOUND TRUE PARENT_SCOPE)
  99. ELSE(EXISTS ${_IMAGEMAGICK_EXECUTABLE})
  100. SET(ImageMagick_${component}_FOUND FALSE PARENT_SCOPE)
  101. ENDIF(EXISTS ${_IMAGEMAGICK_EXECUTABLE})
  102. ENDFUNCTION(FIND_IMAGEMAGICK_EXE)
  103. #---------------------------------------------------------------------
  104. # Start Actual Work
  105. #---------------------------------------------------------------------
  106. # Try to find a ImageMagick installation binary path.
  107. FIND_PATH(ImageMagick_EXECUTABLE_DIR
  108. NAMES mogrify${CMAKE_EXECUTABLE_SUFFIX}
  109. PATHS
  110. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]"
  111. DOC "Path to the ImageMagick binary directory."
  112. NO_DEFAULT_PATH
  113. )
  114. FIND_PATH(ImageMagick_EXECUTABLE_DIR
  115. NAMES mogrify${CMAKE_EXECUTABLE_SUFFIX}
  116. )
  117. # Find each component. Search for all tools in same dir
  118. # <ImageMagick_EXECUTABLE_DIR>; otherwise they should be found
  119. # independently and not in a cohesive module such as this one.
  120. SET(ImageMagick_FOUND TRUE)
  121. FOREACH(component ${ImageMagick_FIND_COMPONENTS}
  122. # DEPRECATED: forced components for backward compatibility
  123. convert mogrify import montage composite
  124. )
  125. IF(component STREQUAL "Magick++")
  126. FIND_IMAGEMAGICK_API(Magick++ Magick++.h
  127. Magick++ CORE_RL_Magick++_
  128. )
  129. ELSEIF(component STREQUAL "MagickWand")
  130. FIND_IMAGEMAGICK_API(MagickWand wand/MagickWand.h
  131. Wand MagickWand CORE_RL_wand_
  132. )
  133. ELSEIF(component STREQUAL "MagickCore")
  134. FIND_IMAGEMAGICK_API(MagickCore magick/MagickCore.h
  135. Magick MagickCore CORE_RL_magick_
  136. )
  137. ELSE(component STREQUAL "Magick++")
  138. IF(ImageMagick_EXECUTABLE_DIR)
  139. FIND_IMAGEMAGICK_EXE(${component})
  140. ENDIF(ImageMagick_EXECUTABLE_DIR)
  141. ENDIF(component STREQUAL "Magick++")
  142. IF(NOT ImageMagick_${component}_FOUND)
  143. LIST(FIND ImageMagick_FIND_COMPONENTS ${component} is_requested)
  144. IF(is_requested GREATER -1)
  145. SET(ImageMagick_FOUND FALSE)
  146. ENDIF(is_requested GREATER -1)
  147. ENDIF(NOT ImageMagick_${component}_FOUND)
  148. ENDFOREACH(component)
  149. SET(ImageMagick_INCLUDE_DIRS ${ImageMagick_INCLUDE_DIRS})
  150. SET(ImageMagick_LIBRARIES ${ImageMagick_LIBRARIES})
  151. #---------------------------------------------------------------------
  152. # Standard Package Output
  153. #---------------------------------------------------------------------
  154. INCLUDE(FindPackageHandleStandardArgs)
  155. FIND_PACKAGE_HANDLE_STANDARD_ARGS(
  156. ImageMagick DEFAULT_MSG ImageMagick_FOUND
  157. )
  158. # Maintain consistency with all other variables.
  159. SET(ImageMagick_FOUND ${IMAGEMAGICK_FOUND})
  160. #---------------------------------------------------------------------
  161. # DEPRECATED: Setting variables for backward compatibility.
  162. #---------------------------------------------------------------------
  163. SET(IMAGEMAGICK_BINARY_PATH ${ImageMagick_EXECUTABLE_DIR}
  164. CACHE PATH "Path to the ImageMagick binary directory.")
  165. SET(IMAGEMAGICK_CONVERT_EXECUTABLE ${ImageMagick_convert_EXECUTABLE}
  166. CACHE FILEPATH "Path to ImageMagick's convert executable.")
  167. SET(IMAGEMAGICK_MOGRIFY_EXECUTABLE ${ImageMagick_mogrify_EXECUTABLE}
  168. CACHE FILEPATH "Path to ImageMagick's mogrify executable.")
  169. SET(IMAGEMAGICK_IMPORT_EXECUTABLE ${ImageMagick_import_EXECUTABLE}
  170. CACHE FILEPATH "Path to ImageMagick's import executable.")
  171. SET(IMAGEMAGICK_MONTAGE_EXECUTABLE ${ImageMagick_montage_EXECUTABLE}
  172. CACHE FILEPATH "Path to ImageMagick's montage executable.")
  173. SET(IMAGEMAGICK_COMPOSITE_EXECUTABLE ${ImageMagick_composite_EXECUTABLE}
  174. CACHE FILEPATH "Path to ImageMagick's composite executable.")
  175. MARK_AS_ADVANCED(
  176. IMAGEMAGICK_BINARY_PATH
  177. IMAGEMAGICK_CONVERT_EXECUTABLE
  178. IMAGEMAGICK_MOGRIFY_EXECUTABLE
  179. IMAGEMAGICK_IMPORT_EXECUTABLE
  180. IMAGEMAGICK_MONTAGE_EXECUTABLE
  181. IMAGEMAGICK_COMPOSITE_EXECUTABLE
  182. )