FindImageMagick: Allow including multiple times

This prevents attempting to create a duplicate target by adding an
`if(NOT TARGET ...)` check as in other modules.  The condition was
missed in commit 1bba218214 (FindImageMagick: Define targets for
specific components, 2023-01-20, v3.26.0-rc1~23^2).

Fixes: #25970
This commit is contained in:
Josiah VanderZee
2024-06-21 07:02:53 -05:00
committed by Brad King
parent b83fabd0d3
commit 63bb3fca54
+7 -5
View File
@@ -185,11 +185,13 @@ function(FIND_IMAGEMAGICK_API component header)
)
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}")
if(NOT TARGET ImageMagick::${component})
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()
endif()
endfunction()