summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-01-30 14:00:59 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-01-30 14:01:08 (GMT)
commitf235fb2a40e9803580b37e7f118e6409e4487909 (patch)
treeec2953f74ea8ea0823c1cb459700981e8fc679ea
parentb96d7418b700e1c35dcd2a9e5cdab092fef1b4e2 (diff)
parent1bba21821466c5f64f0853df155488227263f0fa (diff)
downloadCMake-f235fb2a40e9803580b37e7f118e6409e4487909.zip
CMake-f235fb2a40e9803580b37e7f118e6409e4487909.tar.gz
CMake-f235fb2a40e9803580b37e7f118e6409e4487909.tar.bz2
Merge topic 'FindImageMagick'
1bba218214 FindImageMagick: Define targets for specific components Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Alex <leha-bot@yandex.ru> Merge-request: !8098
-rw-r--r--.gitlab/ci/configure_debian10_aarch64_ninja.cmake1
-rw-r--r--.gitlab/ci/configure_debian10_ninja.cmake1
-rw-r--r--.gitlab/ci/configure_fedora37_makefiles.cmake1
-rw-r--r--Modules/FindImageMagick.cmake117
-rw-r--r--Tests/CMakeLists.txt1
-rw-r--r--Tests/FindImageMagick/CMakeLists.txt10
-rw-r--r--Tests/FindImageMagick/Test/CMakeLists.txt13
-rw-r--r--Tests/FindImageMagick/Test/main_magick++.cxx10
-rw-r--r--Tests/FindImageMagick/Test/main_magick_wand.c8
9 files changed, 122 insertions, 40 deletions
diff --git a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake
index 605f6ba..808f91d 100644
--- a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake
+++ b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake
@@ -27,6 +27,7 @@ set(CMake_TEST_FindGTest "ON" CACHE BOOL "")
set(CMake_TEST_FindGTK2 "ON" CACHE BOOL "")
set(CMake_TEST_FindIconv "ON" CACHE BOOL "")
set(CMake_TEST_FindICU "ON" CACHE BOOL "")
+set(CMake_TEST_FindImageMagick "ON" CACHE BOOL "")
set(CMake_TEST_FindIntl "ON" CACHE BOOL "")
set(CMake_TEST_FindJNI "ON" CACHE BOOL "")
set(CMake_TEST_FindJPEG "ON" CACHE BOOL "")
diff --git a/.gitlab/ci/configure_debian10_ninja.cmake b/.gitlab/ci/configure_debian10_ninja.cmake
index 214828a..acada17 100644
--- a/.gitlab/ci/configure_debian10_ninja.cmake
+++ b/.gitlab/ci/configure_debian10_ninja.cmake
@@ -31,6 +31,7 @@ set(CMake_TEST_FindGTest "ON" CACHE BOOL "")
set(CMake_TEST_FindGTK2 "ON" CACHE BOOL "")
set(CMake_TEST_FindIconv "ON" CACHE BOOL "")
set(CMake_TEST_FindICU "ON" CACHE BOOL "")
+set(CMake_TEST_FindImageMagick "ON" CACHE BOOL "")
set(CMake_TEST_FindIntl "ON" CACHE BOOL "")
set(CMake_TEST_FindJNI "ON" CACHE BOOL "")
set(CMake_TEST_FindJPEG "ON" CACHE BOOL "")
diff --git a/.gitlab/ci/configure_fedora37_makefiles.cmake b/.gitlab/ci/configure_fedora37_makefiles.cmake
index 11d1a08..6cd3d35 100644
--- a/.gitlab/ci/configure_fedora37_makefiles.cmake
+++ b/.gitlab/ci/configure_fedora37_makefiles.cmake
@@ -30,6 +30,7 @@ set(CMake_TEST_FindGTest "ON" CACHE BOOL "")
set(CMake_TEST_FindGTK2 "ON" CACHE BOOL "")
set(CMake_TEST_FindIconv "ON" CACHE BOOL "")
set(CMake_TEST_FindICU "ON" CACHE BOOL "")
+set(CMake_TEST_FindImageMagick "ON" CACHE BOOL "")
set(CMake_TEST_FindIntl "ON" CACHE BOOL "")
set(CMake_TEST_FindJNI "ON" CACHE BOOL "")
set(CMake_TEST_FindJPEG "ON" CACHE BOOL "")
diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake
index d7de0dd..2210e1b 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()
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index e5e592b..c22f704 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1480,6 +1480,7 @@ if(BUILD_TESTING)
GTK2
Iconv
ICU
+ ImageMagick
Intl
Jasper
JNI
diff --git a/Tests/FindImageMagick/CMakeLists.txt b/Tests/FindImageMagick/CMakeLists.txt
new file mode 100644
index 0000000..8a3c70c
--- /dev/null
+++ b/Tests/FindImageMagick/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindImageMagick.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindImageMagick/Test"
+ "${CMake_BINARY_DIR}/Tests/FindImageMagick/Test"
+ ${build_generator_args}
+ --build-project TestFindImageMagick
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindImageMagick/Test/CMakeLists.txt b/Tests/FindImageMagick/Test/CMakeLists.txt
new file mode 100644
index 0000000..6182260
--- /dev/null
+++ b/Tests/FindImageMagick/Test/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.4)
+project(FindImageMagick C CXX)
+include(CTest)
+
+find_package(ImageMagick REQUIRED COMPONENTS Magick++ MagickWand)
+
+add_executable(test_magick++ main_magick++.cxx)
+target_link_libraries(test_magick++ PRIVATE ImageMagick::Magick++)
+add_test(NAME test_magick++ COMMAND test_magick++)
+
+add_executable(test_magick_wand main_magick_wand.c)
+target_link_libraries(test_magick_wand ImageMagick::MagickWand)
+add_test(NAME test_magick_wand COMMAND test_magick_wand)
diff --git a/Tests/FindImageMagick/Test/main_magick++.cxx b/Tests/FindImageMagick/Test/main_magick++.cxx
new file mode 100644
index 0000000..d0208d4
--- /dev/null
+++ b/Tests/FindImageMagick/Test/main_magick++.cxx
@@ -0,0 +1,10 @@
+#include <iostream>
+#include <string>
+
+#include <Magick++.h>
+
+int main()
+{
+ Magick::InitializeMagick("");
+ return 0;
+}
diff --git a/Tests/FindImageMagick/Test/main_magick_wand.c b/Tests/FindImageMagick/Test/main_magick_wand.c
new file mode 100644
index 0000000..fa6d170
--- /dev/null
+++ b/Tests/FindImageMagick/Test/main_magick_wand.c
@@ -0,0 +1,8 @@
+#include <wand/MagickWand.h>
+
+int main()
+{
+ MagickWand* wand = NewMagickWand();
+ wand = DestroyMagickWand(wand);
+ return 0;
+}