mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-01-27 03:14:21 +00:00
FindImageMagick: Fix detection of version 7 from headers
This commit is contained in:
parent
faf8addc71
commit
a0642acbce
@ -298,23 +298,29 @@ function(_ImageMagick_GetVersion)
|
||||
)
|
||||
|
||||
foreach(dir IN LISTS ImageMagick_INCLUDE_DIRS)
|
||||
if(EXISTS ${dir}/magick/version.h)
|
||||
file(STRINGS "${dir}/magick/version.h" results REGEX "${regex}")
|
||||
foreach(subdir IN ITEMS MagickCore magick)
|
||||
if(EXISTS ${dir}/${subdir}/version.h)
|
||||
file(STRINGS "${dir}/${subdir}/version.h" results REGEX "${regex}")
|
||||
|
||||
foreach(line ${results})
|
||||
if(line MATCHES "${regex}")
|
||||
if(DEFINED version)
|
||||
string(APPEND version "${CMAKE_MATCH_2}")
|
||||
else()
|
||||
set(version "${CMAKE_MATCH_2}")
|
||||
endif()
|
||||
foreach(line ${results})
|
||||
if(line MATCHES "${regex}")
|
||||
if(DEFINED version)
|
||||
string(APPEND version "${CMAKE_MATCH_2}")
|
||||
else()
|
||||
set(version "${CMAKE_MATCH_2}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_MATCH_1 STREQUAL "MagickLibAddendum")
|
||||
break()
|
||||
if(CMAKE_MATCH_1 STREQUAL "MagickLibAddendum")
|
||||
break()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(DEFINED version)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(DEFINED version)
|
||||
break()
|
||||
|
||||
@ -14,4 +14,7 @@ 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)
|
||||
if(ImageMagick_VERSION VERSION_GREATER_EQUAL 7)
|
||||
target_compile_definitions(test_magick_wand PRIVATE TEST_IMAGE_MAGICK_7)
|
||||
endif()
|
||||
add_test(NAME test_magick_wand COMMAND test_magick_wand)
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
#include <wand/MagickWand.h>
|
||||
#ifdef TEST_IMAGE_MAGICK_7
|
||||
# include <MagickWand/MagickWand.h>
|
||||
#else
|
||||
# include <wand/MagickWand.h>
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user