diff options
author | Nathanael Jones <nathanael.jones@gmail.com> | 2014-10-02 14:59:29 -0400 |
---|---|---|
committer | Nathanael Jones <nathanael.jones@gmail.com> | 2014-10-02 14:59:29 -0400 |
commit | f82b37141896b85acd411c6716abd231a996adf6 (patch) | |
tree | af7d6c6c706d17da13e3d963ba8c9127e1d3de97 | |
parent | 7f735f64589f6bf077d99e2ff452a3f1e635fa68 (diff) | |
download | libgd-f82b37141896b85acd411c6716abd231a996adf6.tar.gz |
Add libiconv support to CMake files
-rw-r--r-- | CMakeLists.txt | 11 | ||||
-rw-r--r-- | cmake/modules/FindICONV.cmake | 64 | ||||
-rw-r--r-- | src/CMakeLists.txt | 4 |
3 files changed, 77 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index edf1960..4d70f4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ OPTION(ENABLE_PNG "Enable PNG support" 0) OPTION(ENABLE_LIQ "Enable libimagequant support" 0) OPTION(ENABLE_JPEG "Enable JPEG support" 0) OPTION(ENABLE_TIFF "Enable TIFF support" 0) +OPTION(ENABLE_ICONV "Enable ICONV support" 0) OPTION(ENABLE_XPM "Enable XPM support" 0) OPTION(ENABLE_FREETYPE "Enable Freetype2 support" 0) OPTION(ENABLE_FONTCONFIG "Enable FontConfig support" 0) @@ -86,6 +87,10 @@ else (USE_EXT_GD) if (ENABLE_PNG) FIND_PACKAGE(PNG REQUIRED) endif (ENABLE_PNG) + + if (ENABLE_ICONV) + FIND_PACKAGE(ICONV REQUIRED) + endif (ENABLE_ICONV) FIND_PACKAGE(ZLIB) @@ -141,6 +146,12 @@ else (USE_EXT_GD) INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR}) SET(HAVE_LIBPNG 1) ENDIF(PNG_FOUND) + + IF(ICONV_FOUND) + INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR}) + SET(HAVE_ICONV 1) + SET(HAVE_ICONV_H 1) + ENDIF(ICONV_FOUND) IF(LIQ_FOUND) INCLUDE_DIRECTORIES(${LIQ_INCLUDE_DIR}) diff --git a/cmake/modules/FindICONV.cmake b/cmake/modules/FindICONV.cmake new file mode 100644 index 0000000..49d5f6b --- /dev/null +++ b/cmake/modules/FindICONV.cmake @@ -0,0 +1,64 @@ +# - Try to find Iconv +# Once done this will define +# +# ICONV_FOUND - system has Iconv +# ICONV_INCLUDE_DIR - the Iconv include directory +# ICONV_LIBRARIES - Link these to use Iconv +# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const +# +include(CheckCCompilerFlag) +include(CheckCSourceCompiles) + +IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + # Already in cache, be silent + SET(ICONV_FIND_QUIETLY TRUE) +ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + +FIND_PATH(ICONV_INCLUDE_DIR iconv.h HINTS /sw/include/ PATHS /opt/local) + +FIND_LIBRARY(ICONV_LIBRARIES NAMES libiconv_a iconv libiconv c PATHS /opt/local) + +IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + SET(ICONV_FOUND TRUE) +ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + +set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) +set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) +IF(ICONV_FOUND) + check_c_compiler_flag("-Werror" ICONV_HAVE_WERROR) + set (CMAKE_C_FLAGS_BACKUP "${CMAKE_C_FLAGS}") + if(ICONV_HAVE_WERROR) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + endif(ICONV_HAVE_WERROR) + check_c_source_compiles(" + #include <iconv.h> + int main(){ + iconv_t conv = 0; + const char* in = 0; + size_t ilen = 0; + char* out = 0; + size_t olen = 0; + iconv(conv, &in, &ilen, &out, &olen); + return 0; + } +" ICONV_SECOND_ARGUMENT_IS_CONST ) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_BACKUP}") +ENDIF(ICONV_FOUND) +set(CMAKE_REQUIRED_INCLUDES) +set(CMAKE_REQUIRED_LIBRARIES) + +IF(ICONV_FOUND) + IF(NOT ICONV_FIND_QUIETLY) + MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}") + ENDIF(NOT ICONV_FIND_QUIETLY) +ELSE(ICONV_FOUND) + IF(Iconv_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find Iconv") + ENDIF(Iconv_FIND_REQUIRED) +ENDIF(ICONV_FOUND) + +MARK_AS_ADVANCED( + ICONV_INCLUDE_DIR + ICONV_LIBRARIES + ICONV_SECOND_ARGUMENT_IS_CONST +)
\ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5e0dd04..1b2112f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,8 +81,8 @@ endif (MINGW OR MSYS) INCLUDE_DIRECTORIES(BEFORE "${PROJECT_BINARY_DIR}" "${CMAKE_BINARY_DIR}" "${GD_SOURCE_DIR}/src") -target_link_libraries(${GD_LIB} ${ZLIB_LIBRARIES} ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${LIQ_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${XPM_LIBRARIES} ${FONTCONFIG_LIBRARY} ${VPX_LIBRARIES}) -target_link_libraries(${GD_LIB_STATIC} ${ZLIB_LIBRARIES} ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${LIQ_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${XPM_LIBRARIES} ${FONTCONFIG_LIBRARY} ${VPX_LIBRARIES} ) +target_link_libraries(${GD_LIB} ${ZLIB_LIBRARIES} ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${ICONV_LIBRARIES} ${LIQ_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${XPM_LIBRARIES} ${FONTCONFIG_LIBRARY} ${VPX_LIBRARIES}) +target_link_libraries(${GD_LIB_STATIC} ${ZLIB_LIBRARIES} ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${ICONV_LIBRARIES} ${LIQ_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${XPM_LIBRARIES} ${FONTCONFIG_LIBRARY} ${VPX_LIBRARIES} ) set(GD_PROGRAMS annotate gdparttopng gdtopng gd2copypal gd2topng pngtogd pngtogd2 webpng gd2togif gdcmpgif giftogd2) foreach(program ${GD_PROGRAMS}) |