summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorKornel Lesiński <kornel@geekhood.net>2013-03-25 23:46:54 +0000
committerKornel Lesiński <kornel@geekhood.net>2013-03-25 23:46:54 +0000
commitcfa23367ad30485d92b186697bc378101b55b770 (patch)
tree564e10360ec7e5b2291bf74a90e6dc717399d587 /cmake
parent46054d232750f9bc1375bf85fa18045b3084cd01 (diff)
downloadlibgd-cfa23367ad30485d92b186697bc378101b55b770.tar.gz
Download libimagequant in cmakefile if needed
--HG-- branch : liq extra : source : de3e993342bc3d4eefe4b638143a7657e0aafe62 extra : histedit_source : 961d951975c5df5b9da5848ce2b04777a2156890%2C12013ded8ac6e49f8af6e757daa1aad8299d3e65
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindLIQ.cmake57
1 files changed, 57 insertions, 0 deletions
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)