File: FindIconv.cmake

package info (click to toggle)
obexftp 0.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 792 kB
  • sloc: ansic: 7,735; ruby: 229; sh: 89; perl: 43; makefile: 39; python: 16
file content (55 lines) | stat: -rw-r--r-- 1,547 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

find_path ( ICONV_INCLUDE_DIR iconv.h )
mark_as_advanced ( ICONV_INCLUDE_DIR )

set ( ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR} )

if ( ICONV_INCLUDE_DIRS )
  include ( CheckFunctionExists )

  unset ( CMAKE_REQUIRED_FLAGS )
  unset ( CMAKE_REQUIRED_DEFINITIONS )
  set ( CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIRS} )
  unset ( CMAKE_REQUIRED_LIBRARIES )
  check_function_exists ( iconv_open ICONV_FOUND )

  if ( NOT ICONV_FOUND )
    find_library ( iconv_LIBRARY iconv )
    if ( iconv_LIBRARY )
      set ( CMAKE_REQUIRED_LIBRARIES ${iconv_LIBRARY} )
      check_function_exists ( iconv_open ICONV_FOUND )
      if ( ICONV_FOUND )
	set ( ICONV_LIBRARIES ${iconv_LIBRARY} )
      endif ( ICONV_FOUND )
    endif ( iconv_LIBRARY )
  endif ( NOT ICONV_FOUND )
endif ( ICONV_INCLUDE_DIRS )

if ( ICONV_FOUND )
  set ( ICONV_CONST_TEST_SOURCE "
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
\"C\"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, const char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif

int main(void) { return 0; }
")
  unset ( CMAKE_REQUIRED_FLAGS )
  unset ( CMAKE_REQUIRED_DEFINITIONS )
  set ( CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIRS} )
  unset ( CMAKE_REQUIRED_LIBRARIES )
  check_c_source_compiles ( "${ICONV_CONST_TEST_SOURCE}" ICONV_USES_CONST )
endif ( ICONV_FOUND )

if ( NOT ICONV_FOUND )
  if ( Iconv_REQUIRED )
    message ( FATAL_ERROR "Iconv not found" )
  endif ( Iconv_REQUIRED )
endif ( NOT ICONV_FOUND )