diff options
author | Kornel Lesiński <kornel@geekhood.net> | 2013-03-25 23:46:54 +0000 |
---|---|---|
committer | Kornel Lesiński <kornel@geekhood.net> | 2013-03-25 23:46:54 +0000 |
commit | cfa23367ad30485d92b186697bc378101b55b770 (patch) | |
tree | 564e10360ec7e5b2291bf74a90e6dc717399d587 | |
parent | 46054d232750f9bc1375bf85fa18045b3084cd01 (diff) | |
download | libgd-cfa23367ad30485d92b186697bc378101b55b770.tar.gz |
Download libimagequant in cmakefile if needed
--HG--
branch : liq
extra : source : de3e993342bc3d4eefe4b638143a7657e0aafe62
extra : histedit_source : 961d951975c5df5b9da5848ce2b04777a2156890%2C12013ded8ac6e49f8af6e757daa1aad8299d3e65
-rwxr-xr-x | .hgignore | 2 | ||||
-rw-r--r-- | CMakeLists.txt | 14 | ||||
-rw-r--r-- | cmake/modules/FindLIQ.cmake | 57 | ||||
-rw-r--r-- | src/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/config.h.cmake | 3 | ||||
-rw-r--r-- | src/gd_topal.c | 2 |
6 files changed, 79 insertions, 3 deletions
@@ -9,3 +9,5 @@ cscope.out CPackConfig.cmake CPackSourceConfig.cmake CTestTestfile.cmake +libimagequant +libimagequant-prefix
\ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c926ce..27866ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ PROJECT(GD) SET(CMAKE_MODULE_PATH "${GD_SOURCE_DIR}/cmake/modules") OPTION(ENABLE_PNG "Enable PNG support" 1) +OPTION(ENABLE_LIQ "Enable libimagequant support" 1) OPTION(ENABLE_JPEG "Enable JPEG support" 1) OPTION(ENABLE_TIFF "Enable TIFF support" 1) OPTION(ENABLE_XPM "Enable XPM support" 1) @@ -69,6 +70,10 @@ else (USE_EXT_GD) FIND_PACKAGE(ZLIB) + IF (ENABLE_LIQ) + FIND_PACKAGE(LIQ) + ENDIF (ENABLE_LIQ) + IF (NOT WIN32) FIND_PACKAGE(PTHREAD) ENDIF (NOT WIN32) @@ -117,6 +122,11 @@ else (USE_EXT_GD) SET(HAVE_LIBPNG 1) ENDIF(PNG_FOUND) + IF(LIQ_FOUND) + INCLUDE_DIRECTORIES(${LIQ_INCLUDE_DIR}) + SET(HAVE_LIBIMAGEQUANT_H 1) + ENDIF(LIQ_FOUND) + IF(XPM_FOUND) INCLUDE_DIRECTORIES(${XPM_INCLUDE_DIR}) SET(HAVE_LIBXPM 1) @@ -193,6 +203,10 @@ else(WIN32) set(CPACK_GENERATOR TGZ) endif(WIN32) +IF (ENABLE_LIQ AND LIQ_BUILD) + ADD_DEPENDENCIES(${GD_LIB} libimagequant) + ADD_DEPENDENCIES(${GD_LIB_STATIC} libimagequant) +ENDIF(ENABLE_LIQ AND LIQ_BUILD) set(CPACK_SOURCE_GENERATOR TGZ) set(CPACK_SOURCE_IGNORE_FILES diff --git a/cmake/modules/FindLIQ.cmake b/cmake/modules/FindLIQ.cmake new file mode 100644 index 0000000..ec6fb9b --- /dev/null +++ b/cmake/modules/FindLIQ.cmake @@ -0,0 +1,57 @@ +# Find libimagequant includes and library (and download+build if needed) +# http://pngquant.org/lib +# +# This module defines +# LIQ_INCLUDE_DIR, where to find libimagequant.h +# LIQ_LIBRARIES, the libraries to link against to use libimagequant. +# LIQ_FOUND, If false, do not try to use libimagequant. + +SET(LIQ_FOUND "NO") + +FIND_PATH(LIQ_INCLUDE_DIR libimagequant.h +"${PROJECT_SOURCE_DIR}/libimagequant" +"${PROJECT_SOURCE_DIR}/pngquant/lib" +/usr/local/include +/usr/include +) + +FIND_LIBRARY(LIQ_LIBRARY + NAMES libimagequant imagequant + PATHS "${PROJECT_SOURCE_DIR}/libimagequant" "${PROJECT_SOURCE_DIR}/pngquant/lib" /usr/lib64 /usr/lib /usr/local/lib +) + +IF (LIQ_LIBRARY AND LIQ_INCLUDE_DIR) + SET(LIQ_FOUND "YES") + SET(LIQ_LIBRARIES ${LIQ_LIBRARY}) + SET(HAVE_LIBIMAGEQUANT_H 1) +ENDIF (LIQ_LIBRARY AND LIQ_INCLUDE_DIR) + +IF (LIQ_FOUND) + IF (NOT LIQ_FIND_QUIETLY) + MESSAGE(STATUS "Found LIQ: ${LIQ_LIBRARY} ${LIQ_INCLUDE_DIR}") + ENDIF (NOT LIQ_FIND_QUIETLY) +ELSE (LIQ_FOUND) + # if existing library not found, then download and build it + IF (NOT WIN32 OR CYGWIN OR MINGW) # MSVC's C compiler is too old to compile libimagequant + MESSAGE(STATUS "LIQ will be built") + INCLUDE(ExternalProject) + EXTERNALPROJECT_ADD( + libimagequant + URL "http://pngquant.org/libimagequant-2.0.0-src.tar.bz2" + SOURCE_DIR libimagequant + BUILD_IN_SOURCE 1 + INSTALL_DIR libimagequant + INSTALL_COMMAND true + CONFIGURE_COMMAND true + BUILD_COMMAND make static + ) + + SET(LIQ_FOUND "SORTOF") + SET(LIQ_BUILD "YES") + SET(LIQ_LIBRARIES "${PROJECT_SOURCE_DIR}/libimagequant/libimagequant.a") + SET(LIQ_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/libimagequant/") + SET(HAVE_LIBIMAGEQUANT_H 1) + ENDIF(NOT WIN32 OR CYGWIN OR MINGW) +ENDIF (LIQ_FOUND) + +MARK_AS_ADVANCED(LIQ_INCLUDE_DIR LIQ_LIBRARIES LIQ_BUILD) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b716212..fa86f1c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -75,8 +75,8 @@ endif (MINGW OR MSYS) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/ ${GD_SOURCE_DIR}/src) -target_link_libraries(${GD_LIB} ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${XPM_LIBRARIES} ${FONTCONFIG_LIBRARY}) -target_link_libraries(${GD_LIB_STATIC} ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${XPM_LIBRARIES} ${FONTCONFIG_LIBRARY}) +target_link_libraries(${GD_LIB} ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${LIQ_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${XPM_LIBRARIES} ${FONTCONFIG_LIBRARY}) +target_link_libraries(${GD_LIB_STATIC} ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${LIQ_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${XPM_LIBRARIES} ${FONTCONFIG_LIBRARY}) set(GD_PROGRAMS annotate gdparttopng gdtopng gd2copypal gd2topng pngtogd pngtogd2 webpng gd2togif gdcmpgif giftogd2) foreach(program ${GD_PROGRAMS}) diff --git a/src/config.h.cmake b/src/config.h.cmake index 650d1df..d76aaeb 100644 --- a/src/config.h.cmake +++ b/src/config.h.cmake @@ -42,6 +42,9 @@ /* Define to 1 if you have the <libpng/png.h> header file. */ #cmakedefine HAVE_LIBPNG_PNG_H +/* Define to 1 if you have the <libimagequant.h> header file. */ +#cmakedefine HAVE_LIBIMAGEQUANT_H + /* Define if you have the Xpm library. */ #cmakedefine HAVE_LIBXPM diff --git a/src/gd_topal.c b/src/gd_topal.c index 3c7e17a..417c17c 100644 --- a/src/gd_topal.c +++ b/src/gd_topal.c @@ -46,7 +46,7 @@ #include "gdhelpers.h" #ifdef HAVE_LIBIMAGEQUANT_H -#include <libimagequant.h> +#include <libimagequant.h> /* if this fails then set -DENABLE_LIQ=NO in cmake or make static libimagequant.a in libimagequant/ */ #endif /* (Re)define some defines known by libjpeg */ |