find_package( ImageMagick 6 REQUIRED COMPONENTS Magick++ MagickCore )
在Linux上可以运行,但是在Windows上却出现错误:
Could NOT find ImageMagick (missing: ImageMagick_Magick++_LIBRARY
ImageMagick_MagickCore_LIBRARY) (found suitable version "6.9.10-80",
minimum required is "6")
我已经正确安装了带有所有库和标头的ImageMagick。一切都在INCLUDE和LIB,PATH路径中。
CMake找到了ImageMagick,但是找不到组件。我该如何解决?
ImageMagick库位于c:\3rdparty\lib
和CORE_RL_Magick++_.lib
所在的CORE_RL_magick_.lib
中。
CMake版本是3.16.2
答案 0 :(得分:2)
问题在于c:\3rdparty\lib
是添加到LIB
系统环境变量的目录,由于在特定环境变量中禁用了搜索,因此使用find_library()
的CMake搜索会丢失该目录。>
我编辑了FindImageMagick.cmake
并评论了此限制:
function(FIND_IMAGEMAGICK_API component header)
set(ImageMagick_${component}_FOUND FALSE PARENT_SCOPE)
pkg_check_modules(PC_${component} QUIET ${component})
find_path(ImageMagick_${component}_INCLUDE_DIR
NAMES ${header}
HINTS
${PC_${component}_INCLUDEDIR}
${PC_${component}_INCLUDE_DIRS}
PATHS
${ImageMagick_INCLUDE_DIRS}
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]/include"
PATH_SUFFIXES
ImageMagick ImageMagick-6 ImageMagick-7
DOC "Path to the ImageMagick arch-independent include dir."
# NO_DEFAULT_PATH
)
find_path(ImageMagick_${component}_ARCH_INCLUDE_DIR
NAMES magick/magick-baseconfig.h
HINTS
${PC_${component}_INCLUDEDIR}
${PC_${component}_INCLUDE_DIRS}
PATHS
${ImageMagick_INCLUDE_DIRS}
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]/include"
PATH_SUFFIXES
ImageMagick ImageMagick-6 ImageMagick-7
DOC "Path to the ImageMagick arch-specific include dir."
# NO_DEFAULT_PATH
)
find_library(ImageMagick_${component}_LIBRARY
NAMES ${ARGN}
HINTS
${PC_${component}_LIBDIR}
${PC_${component}_LIB_DIRS}
PATHS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]/lib"
DOC "Path to the ImageMagick Magick++ library."
# NO_DEFAULT_PATH
)
瞧,现在CMake能够找到我的ImageMagick。