2 # Copyright (c) 2006, Peter Kümmel, <syntheticpp@gmx.net>
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # 3. The name of the author may not be used to endorse or promote products
14 # derived from this software without specific prior written permission.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
30 if (ICONV_INCLUDE_DIR)
31 # Already in cache, be silent
32 set(ICONV_FIND_QUIETLY TRUE)
35 find_path(ICONV_INCLUDE_DIR iconv.h PATHS
39 find_file(ICONV_HEADER iconv.h
40 PATHS ${ICONV_INCLUDE_DIR} NO_DEFAULT_PATH)
42 set(POTENTIAL_ICONV_LIBS iconv libiconv libiconv2)
45 find_library(ICONV_LIBRARY NAMES ${POTENTIAL_ICONV_LIBS}
47 ${ICONV_RELATIVE_TO_LIBINTL}
50 find_library(ICONV_LIBRARY NAMES ${POTENTIAL_ICONV_LIBS}
51 PATHS ${SYSTEM_LIB_DIRS} )
54 set(ICONV_DLL_NAMES iconv.dll libiconv.dll libiconv2.dll)
56 NAMES ${ICONV_DLL_NAMES}
58 ${ICONV_INCLUDE_DIR}/../bin)
59 find_file(ICONV_DLL_HELP
60 NAMES ${ICONV_DLL_NAMES}
62 ${ICONV_INCLUDE_DIR}/../bin)
63 if(ICONV_FIND_REQUIRED)
64 if(NOT ICONV_DLL AND NOT ICONV_DLL_HELP)
65 message(FATAL_ERROR "Could not find iconv.dll, please add correct your PATH environment variable")
67 if(NOT ICONV_DLL AND ICONV_DLL_HELP)
68 get_filename_component(ICONV_DLL_HELP ${ICONV_DLL_HELP} PATH)
70 message(STATUS "Could not find iconv.dll in standard search path, please add ")
71 message(STATUS "${ICONV_DLL_HELP}")
72 message(STATUS "to your PATH environment variable.")
74 message(FATAL_ERROR "exit cmake")
77 if(ICONV_INCLUDE_DIR AND ICONV_LIBRARY AND ICONV_DLL)
81 include(CheckFunctionExists)
82 check_function_exists(iconv HAVE_ICONV_IN_LIBC)
83 if(ICONV_INCLUDE_DIR AND HAVE_ICONV_IN_LIBC)
85 set(ICONV_LIBRARY CACHE TYPE STRING FORCE)
87 if(ICONV_INCLUDE_DIR AND ICONV_LIBRARY)
95 if(NOT ICONV_FIND_QUIETLY)
96 message(STATUS "Found iconv library: ${ICONV_LIBRARY}")
97 #message(STATUS "Found iconv dll : ${ICONV_DLL}")
100 if(ICONV_FIND_REQUIRED)
101 message(STATUS "Looked for iconv library named ${POTENTIAL_ICONV_LIBS}.")
102 message(STATUS "Found no acceptable iconv library. This is fatal.")
103 message(STATUS "iconv header: ${ICONV_INCLUDE_DIR}")
104 message(STATUS "iconv lib : ${ICONV_LIBRARY}")
105 message(FATAL_ERROR "Could NOT find iconv library")
109 mark_as_advanced(ICONV_LIBRARY ICONV_INCLUDE_DIR ICONV_DLL ICONV_DLL_HELP)