1# - Try to find LibIconv
2# Once done this will define
3#
4#  LIBICONV_FOUND - system has LibIconv
5#  LIBICONV_INCLUDE_DIR - the LibIconv include directory
6#  LIBICONV_LIBRARIES - the libraries needed to use LibIconv
7#  LIBICONV_DEFINITIONS - Compiler switches required for using LibIconv
8
9if (LIBICONV_INCLUDE_DIR AND LIBICONV_LIBRARIES)
10
11    # in cache already
12    SET(LIBICONV_FOUND TRUE)
13
14else (LIBICONV_INCLUDE_DIR AND LIBICONV_LIBRARIES)
15
16    IF (NOT WIN32)
17        MESSAGE(FATAL_ERROR "Please set this to the correct values!")
18        # use pkg-config to get the directories and then use these values
19        # in the FIND_PATH() and FIND_LIBRARY() calls
20        INCLUDE(UsePkgConfig)
21        PKGCONFIG(libiconv-1.9 _LibIconvIncDir _LibIconvLinkDir _LibIconvLinkFlags _LiIconvCflags)
22        SET(LIBICONV_DEFINITIONS ${_LibIconvCflags})
23    ENDIF (NOT WIN32)
24
25    FIND_PATH(LIBICONV_INCLUDE_DIR iconv.h
26      PATHS
27     ${_LibIconvIncDir}
28      PATH_SUFFIXES libiconv
29    )
30
31    FIND_LIBRARY(LIBICONV_LIBRARIES NAMES iconv libiconv
32      PATHS
33      ${_LibIconvLinkDir}
34    )
35
36    if (LIBICONV_INCLUDE_DIR AND LIBICONV_LIBRARIES)
37       set(LIBICONV_FOUND TRUE)
38    endif (LIBICONV_INCLUDE_DIR AND LIBICONV_LIBRARIES)
39
40    if (LIBICONV_FOUND)
41      if (NOT LibIconv_FIND_QUIETLY)
42        message(STATUS "Found LibIconv: ${LIBICONV_LIBRARIES}")
43      endif (NOT LibIconv_FIND_QUIETLY)
44    else (LIBICONV_FOUND)
45      if (LibIconv_FIND_REQUIRED)
46        message(SEND_ERROR "Could NOT find LibIconv")
47      endif (LibIconv_FIND_REQUIRED)
48    endif (LIBICONV_FOUND)
49
50    MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARIES)
51
52endif (LIBICONV_INCLUDE_DIR AND LIBICONV_LIBRARIES)
53