Download libimagequant in cmakefile if needed

--HG--
branch : liq
extra : source : de3e993342bc3d4eefe4b638143a7657e0aafe62
extra : histedit_source : 961d951975c5df5b9da5848ce2b04777a2156890%2C12013ded8ac6e49f8af6e757daa1aad8299d3e65
master
Kornel Lesiński 2013-03-25 23:46:54 +00:00
parent 46054d2327
commit cfa23367ad
6 changed files with 79 additions and 3 deletions

View File

@ -9,3 +9,5 @@ cscope.out
CPackConfig.cmake
CPackSourceConfig.cmake
CTestTestfile.cmake
libimagequant
libimagequant-prefix

View File

@ -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

View File

@ -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)

View File

@ -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})

View File

@ -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

View File

@ -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 */