diff options
author | hstejas <tejashs@rocketmail.com> | 2023-01-20 16:04:32 +0530 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-01-27 10:33:10 -0500 |
commit | 1bba21821466c5f64f0853df155488227263f0fa (patch) | |
tree | f70230dc62fec3b47cd1f17694d161f2a1a80259 /Modules | |
parent | 7ac338be9830bdc936b52a4135504ed011418f3c (diff) | |
download | cmake-1bba21821466c5f64f0853df155488227263f0fa.tar.gz |
FindImageMagick: Define targets for specific components
- With this change we can use e.g. ImageMagick::Magick++ directly
in targt_link_libraries.
- This change also adds CFLAGS which was missing before.
- Also adds example on how to use the targets.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindImageMagick.cmake | 117 |
1 files changed, 77 insertions, 40 deletions
diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake index d7de0ddccf..2210e1bd07 100644 --- a/Modules/FindImageMagick.cmake +++ b/Modules/FindImageMagick.cmake @@ -5,7 +5,9 @@ FindImageMagick --------------- -Find ImageMagick binary suite. +Find ImageMagick, software suite for displaying, converting and +manipulating raster images. + .. versionadded:: 3.9 Added support for ImageMagick 7. @@ -15,65 +17,87 @@ components in the :command:`find_package` call. Typical components include, but are not limited to (future versions of ImageMagick might have additional components not listed here): -:: +* ``animate`` +* ``compare`` +* ``composite`` +* ``conjure`` +* ``convert`` +* ``display`` +* ``identify`` +* ``import`` +* ``mogrify`` +* ``montage`` +* ``stream`` - animate - compare - composite - conjure - convert - display - identify - import - mogrify - montage - stream +If no component is specified in the :command:`find_package` call, then it only +searches for the ImageMagick executable directory. +There are also components for the following ImageMagick APIs: +* ``Magick++``: ImageMagick C++ API, if found. +* ``MagickWand``: ImageMagick MagickWand C API, if found. +* ``MagickCore``: ImageMagick MagickCore low-level C API, if found. -If no component is specified in the :command:`find_package` call, then it only -searches for the ImageMagick executable directory. This code defines -the following variables: -:: +Imported targets +^^^^^^^^^^^^^^^^ - ImageMagick_FOUND - TRUE if all components are found. - ImageMagick_EXECUTABLE_DIR - Full path to executables directory. - ImageMagick_<component>_FOUND - TRUE if <component> is found. - ImageMagick_<component>_EXECUTABLE - Full path to <component> executable. - ImageMagick_VERSION_STRING - the version of ImageMagick found - (since CMake 2.8.8) +.. versionadded:: 3.26 +This module defines the following :prop_tgt:`IMPORTED` targets: +``ImageMagick::Magick++`` + ImageMagick C++ API, if found. -``ImageMagick_VERSION_STRING`` will not work for old versions like 5.2.3. +``ImageMagick::MagickWand`` + ImageMagick MagickWand C API, if found. -There are also components for the following ImageMagick APIs: +``ImageMagick::MagickCore`` + ImageMagick MagickCore low-level C API, if found. -:: - Magick++ - MagickWand - MagickCore +Result Variables +^^^^^^^^^^^^^^^^ +``ImageMagick_FOUND`` + TRUE if all components are found. +``ImageMagick_EXECUTABLE_DIR`` + Full path to executables directory. -For these components the following variables are set: +``ImageMagick_INCLUDE_DIRS`` + Full paths to all include dirs. -:: +``ImageMagick_LIBRARIES`` + Full paths to all libraries. - ImageMagick_FOUND - TRUE if all components are found. - ImageMagick_INCLUDE_DIRS - Full paths to all include dirs. - ImageMagick_LIBRARIES - Full paths to all libraries. - ImageMagick_<component>_FOUND - TRUE if <component> is found. - ImageMagick_<component>_INCLUDE_DIRS - Full path to <component> include dirs. - ImageMagick_<component>_LIBRARIES - Full path to <component> libraries. +``ImageMagick_COMPILE_OPTIONS`` + Compile options of all libraries. +``ImageMagick_VERSION_STRING`` + The version of ImageMagick found (since CMake 2.8.8). + Will not work for old versions like 5.2.3. +``ImageMagick_<component>_FOUND`` + TRUE if <component> is found. -Example Usages: +``ImageMagick_<component>_EXECUTABLE`` + Full path to <component> executable. + +``ImageMagick_<component>_INCLUDE_DIRS`` + Full path to <component> include dirs. + +``ImageMagick_<component>_COMPILE_OPTIONS`` + .. versionadded:: 3.26 + + Compile options of <component>. -:: +``ImageMagick_<component>_LIBRARIES`` + Full path to <component> libraries. + + +Example Usages: +^^^^^^^^^^^^^^^ find_package(ImageMagick) find_package(ImageMagick COMPONENTS convert) @@ -81,7 +105,7 @@ Example Usages: find_package(ImageMagick COMPONENTS Magick++) find_package(ImageMagick COMPONENTS Magick++ convert) - + target_link_libraries(example PRIVATE ImageMagick::Magick++) Note that the standard :command:`find_package` features are supported (i.e., ``QUIET``, ``REQUIRED``, etc.). @@ -150,6 +174,8 @@ function(FIND_IMAGEMAGICK_API component header) set(ImageMagick_${component}_INCLUDE_DIRS ${ImageMagick_${component}_INCLUDE_DIRS} PARENT_SCOPE) + set(ImageMagick_${component}_COMPILE_OPTIONS ${PC_${component}_CFLAGS_OTHER}) + # Add the per-component include directories to the full include dirs. list(APPEND ImageMagick_INCLUDE_DIRS ${ImageMagick_${component}_INCLUDE_DIRS}) list(REMOVE_DUPLICATES ImageMagick_INCLUDE_DIRS) @@ -159,6 +185,17 @@ function(FIND_IMAGEMAGICK_API component header) ${ImageMagick_${component}_LIBRARY} ) set(ImageMagick_LIBRARIES ${ImageMagick_LIBRARIES} PARENT_SCOPE) + + list(APPEND ImageMagick_COMPILE_OPTIONS + ${ImageMagick_${component}_COMPILE_OPTIONS} + ) + set(ImageMagick_COMPILE_OPTIONS ${ImageMagick_COMPILE_OPTIONS} PARENT_SCOPE) + + add_library(ImageMagick::${component} UNKNOWN IMPORTED) + set_target_properties(ImageMagick::${component} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ImageMagick_${component}_INCLUDE_DIRS}" + INTERFACE_COMPILE_OPTIONS "${ImageMagick_${component}_COMPILE_OPTIONS}" + IMPORTED_LOCATION "${ImageMagick_${component}_LIBRARY}") endif() endfunction() |