CMAKE FINDGRAPHICSMAGICK MODULE
星海
posted @ 2012年7月08日 00:49
in 通用知识
, 1755 阅读
最近在用GM API编程,采用了CMAKE作为构建系统
CMAKE自带ImageMagick的Find module,但是缺少GraphisMagick的
碰巧我在使用GM,所以找了下网上的GM module,最早的也是15个月前的,且稍稍有点问题。
于是我结合FINDIMAGEMAGICK MODULE代码,稍稍修改了下GraphisMagick。
以支持WINDOWS和LINUX双系统(只是搜索Magick API和Magick++ API)
内容如下:
#-*-cmake-*- # # Test for GraphicsMagick libraries, unlike CMake's FindGraphicsMagick.cmake which # tests for GraphicsMagick's binary utilities # # Once loaded this will define # MAGICK_FOUND - system has GraphicsMagick # MAGICK_INCLUDE_DIR - include directory for GraphicsMagick # MAGICK_LIBRARY_DIR - library directory for GraphicsMagick # MAGICK_LIBRARIES - libraries you need to link to # # MAGICK++_FOUND - system has GraphicsMagick # MAGICK++_INCLUDE_DIR - include directory for GraphicsMagick # MAGICK++_LIBRARY_DIR - library directory for GraphicsMagick # MAGICK++_LIBRARIES - libraries you need to link to # SET(MAGICK_FOUND "NO" ) SET(MAGICK++_FOUND "NO" ) FIND_PATH( MAGICK_INCLUDE_DIR NAMES magick.h PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GraphicsMagick\\Current;BinPath]/include" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GraphicsMagick\\Current;BinPath]/include/magick" /usr/include/GraphicsMagick/magick "$ENV{MAGICK_LOCATION}/magick" "$ENV{MAGICK_LOCATION}/include" "$ENV{MAGICK_LOCATION}/include/GraphicsMagick" "$ENV{MAGICK_LOCATION}/include/magick" "$ENV{MAGICK_HOME}/include/magick" /usr/include/magick /usr/include/ /usr/local/include /usr/local/include/GraphicsMagick/magick /usr/local/include/GraphicsMagick/ /opt/local/include/GraphicsMagick/magick /opt/local/include/GraphicsMagick ) FIND_PATH( MAGICK++_INCLUDE_DIR NAMES Magick++.h PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GraphicsMagick\\Current;BinPath]/include" "$ENV{MAGICK++_LOCATION}/Magick++" "$ENV{MAGICK++_LOCATION}/include/" "$ENV{MAGICK_LOCATION}/Magick++" "$ENV{MAGICK_LOCATION}/include/Magick++" "$ENV{MAGICK_LOCATION}/include/GraphicsMagick" "$ENV{MAGICK_LOCATION}/include/" "$ENV{MAGICK_HOME}/include/" /usr/include/GraphicsMagick /usr/include/Magick++ /usr/include/ /usr/local/include /usr/local/include/GraphicsMagick /opt/local/include/GraphicsMagick/Magick++ /opt/local/include/GraphicsMagick ) FIND_LIBRARY( Magick NAMES GraphicsMagick CORE_RL_magick_ PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GraphicsMagick\\Current;BinPath]/lib" "$ENV{MAGICK_LOCATION}/magick/.libs" "$ENV{MAGICK_LOCATION}/lib" "$ENV{MAGICK_HOME}/lib" /usr/lib64 /usr/local/lib64 /opt/local/lib64 /usr/lib /usr/local/lib /opt/local/lib DOC "GraphicsMagick magic library" ) FIND_LIBRARY( Magick++ NAMES GraphicsMagick++ CORE_RL_Magick++_ PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GraphicsMagick\\Current;BinPath]/lib" "$ENV{MAGICK++_LOCATION}/.libs" "$ENV{MAGICK_LOCATION}/.libs" "$ENV{MAGICK++_LOCATION}/lib" "$ENV{MAGICK_LOCATION}/lib" "$ENV{MAGICK_HOME}/lib" /opt/local/lib64 /usr/lib64 /usr/local/lib64 /opt/local/lib /usr/lib /usr/local/lib DOC "GraphicsMagick Magick++ library" ) SET(MAGICK_LIBRARIES ${Magick} ) SET(MAGICK++_LIBRARIES ${Magick++} ) IF (MAGICK_INCLUDE_DIR) IF(MAGICK_LIBRARIES) SET(MAGICK_FOUND "YES") GET_FILENAME_COMPONENT(MAGICK_LIBRARY_DIR ${Magick} PATH) ENDIF(MAGICK_LIBRARIES) ENDIF(MAGICK_INCLUDE_DIR) IF (MAGICK++_INCLUDE_DIR) IF(MAGICK++_LIBRARIES) SET(MAGICK++_FOUND "YES") GET_FILENAME_COMPONENT(MAGICK++_LIBRARY_DIR ${Magick++} PATH) ENDIF(MAGICK++_LIBRARIES) ENDIF(MAGICK++_INCLUDE_DIR) IF(NOT MAGICK_FOUND) # make FIND_PACKAGE friendly IF(NOT Magick_FIND_QUIETLY) IF(Magick_FIND_REQUIRED) MESSAGE(FATAL_ERROR "GraphicsMagick required, please specify it's location with MAGICK_HOME, MAGICK_LOCATION or MAGICK++_LOCATION") ELSE(Magick_FIND_REQUIRED) MESSAGE(STATUS "GraphicsMagick was not found.") ENDIF(Magick_FIND_REQUIRED) ENDIF(NOT Magick_FIND_QUIETLY) ENDIF(NOT MAGICK_FOUND) #####