Commits

pornel  committed de3e993

CMake config for libimagequant

  • Participants
  • Parent commits 8fe18e4

Comments (0)

Files changed (5)

File CMakeLists.txt

 
 	FIND_PACKAGE(ZLIB)
 
+	FIND_PACKAGE(LIQ)
+
 	IF (NOT WIN32)
 		FIND_PACKAGE(PTHREAD)
 	ENDIF (NOT WIN32)
 		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)

File cmake/modules/FindLIQ.cmake

+# Find libimagequant includes and library
+# 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"
+/usr/local/include
+/usr/include
+)
+
+FIND_LIBRARY(LIQ_LIBRARY
+  NAMES libimagequant imagequant
+  PATHS "${PROJECT_SOURCE_DIR}/libimagequant" /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 (LIQ_FIND_REQUIRED)
+    MESSAGE(FATAL_ERROR "Could not find LIQ library")
+  ENDIF (LIQ_FIND_REQUIRED)
+ENDIF (LIQ_FOUND)
+
+MARK_AS_ADVANCED(LIQ_INCLUDE_DIR LIQ_LIBRARIES)

File src/CMakeLists.txt

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

File src/config.h.cmake

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

File src/gd_topal.c

  * If it is not working, it's not Thomas G. Lane's fault.
  */
 
-/*
-  SETTING THIS ONE CAUSES STRIPED IMAGE
-  to be done: solve this
-  #define ORIGINAL_LIB_JPEG_REVERSE_ODD_ROWS
- */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include <string.h>
 #include "gd.h"
 #include "gdhelpers.h"
 
-#define HAVE_LIBIMAGEQUANT_H 1
 #ifdef HAVE_LIBIMAGEQUANT_H
-#include "libimagequant/libimagequant.h"
+#include <libimagequant.h>
 #endif
 
 /* (Re)define some defines known by libjpeg */