c86648fabb19289543998ca00a95afc79d092d68~suv# - Try to find Iconv
c86648fabb19289543998ca00a95afc79d092d68~suv# Once done this will define
c86648fabb19289543998ca00a95afc79d092d68~suv#
c86648fabb19289543998ca00a95afc79d092d68~suv# ICONV_FOUND - system has Iconv
c86648fabb19289543998ca00a95afc79d092d68~suv# ICONV_INCLUDE_DIR - the Iconv include directory
c86648fabb19289543998ca00a95afc79d092d68~suv# ICONV_LIBRARIES - Link these to use Iconv
c86648fabb19289543998ca00a95afc79d092d68~suv# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
c86648fabb19289543998ca00a95afc79d092d68~suv#
c86648fabb19289543998ca00a95afc79d092d68~suvinclude(CheckCXXSourceCompiles)
c86648fabb19289543998ca00a95afc79d092d68~suv
c86648fabb19289543998ca00a95afc79d092d68~suvIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
c86648fabb19289543998ca00a95afc79d092d68~suv # Already in cache, be silent
c86648fabb19289543998ca00a95afc79d092d68~suv SET(ICONV_FIND_QUIETLY TRUE)
c86648fabb19289543998ca00a95afc79d092d68~suvENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
c86648fabb19289543998ca00a95afc79d092d68~suv
c86648fabb19289543998ca00a95afc79d092d68~suvFIND_PATH(ICONV_INCLUDE_DIR iconv.h)
c86648fabb19289543998ca00a95afc79d092d68~suv
c86648fabb19289543998ca00a95afc79d092d68~suvFIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)
c86648fabb19289543998ca00a95afc79d092d68~suv
c86648fabb19289543998ca00a95afc79d092d68~suvIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
c86648fabb19289543998ca00a95afc79d092d68~suv SET(ICONV_FOUND TRUE)
c86648fabb19289543998ca00a95afc79d092d68~suvENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
c86648fabb19289543998ca00a95afc79d092d68~suv
c86648fabb19289543998ca00a95afc79d092d68~suvset(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
c86648fabb19289543998ca00a95afc79d092d68~suvset(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
c86648fabb19289543998ca00a95afc79d092d68~suvIF(ICONV_FOUND)
c86648fabb19289543998ca00a95afc79d092d68~suv check_cxx_source_compiles("
c86648fabb19289543998ca00a95afc79d092d68~suv #include <iconv.h>
c86648fabb19289543998ca00a95afc79d092d68~suv int main(){
c86648fabb19289543998ca00a95afc79d092d68~suv iconv_t conv = 0;
c86648fabb19289543998ca00a95afc79d092d68~suv const char* in = 0;
c86648fabb19289543998ca00a95afc79d092d68~suv size_t ilen = 0;
c86648fabb19289543998ca00a95afc79d092d68~suv char* out = 0;
c86648fabb19289543998ca00a95afc79d092d68~suv size_t olen = 0;
c86648fabb19289543998ca00a95afc79d092d68~suv iconv(conv, &in, &ilen, &out, &olen);
c86648fabb19289543998ca00a95afc79d092d68~suv return 0;
c86648fabb19289543998ca00a95afc79d092d68~suv }
c86648fabb19289543998ca00a95afc79d092d68~suv" ICONV_SECOND_ARGUMENT_IS_CONST )
c86648fabb19289543998ca00a95afc79d092d68~suv IF(ICONV_SECOND_ARGUMENT_IS_CONST)
c86648fabb19289543998ca00a95afc79d092d68~suv SET(ICONV_CONST "const")
c86648fabb19289543998ca00a95afc79d092d68~suv ENDIF(ICONV_SECOND_ARGUMENT_IS_CONST)
c86648fabb19289543998ca00a95afc79d092d68~suvENDIF(ICONV_FOUND)
c86648fabb19289543998ca00a95afc79d092d68~suvset(CMAKE_REQUIRED_INCLUDES)
c86648fabb19289543998ca00a95afc79d092d68~suvset(CMAKE_REQUIRED_LIBRARIES)
c86648fabb19289543998ca00a95afc79d092d68~suv
c86648fabb19289543998ca00a95afc79d092d68~suvIF(ICONV_FOUND)
c86648fabb19289543998ca00a95afc79d092d68~suv IF(NOT ICONV_FIND_QUIETLY)
c86648fabb19289543998ca00a95afc79d092d68~suv MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
c86648fabb19289543998ca00a95afc79d092d68~suv ENDIF(NOT ICONV_FIND_QUIETLY)
c86648fabb19289543998ca00a95afc79d092d68~suvELSE(ICONV_FOUND)
c86648fabb19289543998ca00a95afc79d092d68~suv IF(Iconv_FIND_REQUIRED)
c86648fabb19289543998ca00a95afc79d092d68~suv MESSAGE(FATAL_ERROR "Could not find Iconv")
c86648fabb19289543998ca00a95afc79d092d68~suv ENDIF(Iconv_FIND_REQUIRED)
c86648fabb19289543998ca00a95afc79d092d68~suvENDIF(ICONV_FOUND)
c86648fabb19289543998ca00a95afc79d092d68~suv
c86648fabb19289543998ca00a95afc79d092d68~suvMARK_AS_ADVANCED(
c86648fabb19289543998ca00a95afc79d092d68~suv ICONV_INCLUDE_DIR
c86648fabb19289543998ca00a95afc79d092d68~suv ICONV_LIBRARIES
c86648fabb19289543998ca00a95afc79d092d68~suv ICONV_SECOND_ARGUMENT_IS_CONST
c86648fabb19289543998ca00a95afc79d092d68~suv)