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
39 set(POTENTIAL_ICONV_LIBS iconv libiconv libiconv2)
41 find_library(ICONV_LIBRARY NAMES ${POTENTIAL_ICONV_LIBS}
42 PATHS /usr/lib /usr/local/lib)
45 set(ICONV_DLL_NAMES iconv.dll libiconv.dll libiconv2.dll)
47 NAMES ${ICONV_DLL_NAMES}
50 find_file(ICONV_DLL_HELP
51 NAMES ${ICONV_DLL_NAMES}
53 ${ICONV_INCLUDE_DIR}/../bin)
54 if(ICONV_FIND_REQUIRED)
55 if(NOT ICONV_DLL AND NOT ICONV_DLL_HELP)
56 message(FATAL_ERROR "Could not find iconv.dll, please add correct your PATH environment variable")
58 if(NOT ICONV_DLL AND ICONV_DLL_HELP)
59 get_filename_component(ICONV_DLL_HELP ${ICONV_DLL_HELP} PATH)
61 message(STATUS "Could not find iconv.dll in standard search path, please add ")
62 message(STATUS "${ICONV_DLL_HELP}")
63 message(STATUS "to your PATH environment variable.")
65 message(FATAL_ERROR "exit cmake")
68 if(ICONV_INCLUDE_DIR AND ICONV_LIBRARY AND ICONV_DLL)
72 include(CheckFunctionExists)
73 check_function_exists(iconv HAVE_ICONV_IN_LIBC)
74 if(ICONV_INCLUDE_DIR AND HAVE_ICONV_IN_LIBC)
76 set(ICONV_LIBRARY CACHE TYPE STRING FORCE)
78 if(ICONV_INCLUDE_DIR AND ICONV_LIBRARY)
86 if(NOT ICONV_FIND_QUIETLY)
87 message(STATUS "Found iconv library: ${ICONV_LIBRARY}")
88 #message(STATUS "Found iconv dll : ${ICONV_DLL}")
91 if(ICONV_FIND_REQUIRED)
92 message(STATUS "Looked for iconv library named ${POTENTIAL_ICONV_LIBS}.")
93 message(STATUS "Found no acceptable iconv library. This is fatal.")
94 message(STATUS "iconv header: ${ICONV_INCLUDE_DIR}")
95 message(STATUS "iconv lib : ${ICONV_LIBRARY}")
96 message(FATAL_ERROR "Could NOT find iconv library")
100 mark_as_advanced(ICONV_LIBRARY ICONV_INCLUDE_DIR ICONV_DLL ICONV_DLL_HELP)