comparison OrthancFramework/Resources/CMake/LibIconvConfiguration.cmake @ 4044:d25f4c0fa160 framework

splitting code into OrthancFramework and OrthancServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 20:30:34 +0200
parents Resources/CMake/LibIconvConfiguration.cmake@32596919d729
children 304842a0d152
comparison
equal deleted inserted replaced
4043:6c6239aec462 4044:d25f4c0fa160
1 message("Using libiconv")
2
3 if (STATIC_BUILD OR NOT USE_SYSTEM_LIBICONV)
4 set(LIBICONV_SOURCES_DIR ${CMAKE_BINARY_DIR}/libiconv-1.15)
5 set(LIBICONV_URL "http://orthanc.osimis.io/ThirdPartyDownloads/libiconv-1.15.tar.gz")
6 set(LIBICONV_MD5 "ace8b5f2db42f7b3b3057585e80d9808")
7
8 DownloadPackage(${LIBICONV_MD5} ${LIBICONV_URL} "${LIBICONV_SOURCES_DIR}")
9
10 # Disable the support of libiconv that is shipped by default with
11 # the C standard library on Linux. Setting this macro redirects
12 # calls from "iconv*()" to "libiconv*()" by defining macros in the
13 # C headers of "libiconv-1.15".
14 add_definitions(-DLIBICONV_PLUG=1)
15
16 # https://groups.google.com/d/msg/android-ndk/AS1nkxnk6m4/EQm09hD1tigJ
17 add_definitions(
18 -DBUILDING_LIBICONV=1
19 -DIN_LIBRARY=1
20 -DLIBDIR=""
21 -DICONV_CONST=
22 #-DENABLE_EXTRA=1
23 )
24
25 configure_file(
26 ${LIBICONV_SOURCES_DIR}/srclib/localcharset.h
27 ${LIBICONV_SOURCES_DIR}/include
28 COPYONLY)
29
30 set(HAVE_VISIBILITY 0)
31 set(ICONV_CONST ${ICONV_CONST})
32 set(USE_MBSTATE_T 1)
33 set(BROKEN_WCHAR_H 0)
34 set(EILSEQ)
35 set(HAVE_WCHAR_T 1)
36 configure_file(
37 ${LIBICONV_SOURCES_DIR}/include/iconv.h.build.in
38 ${LIBICONV_SOURCES_DIR}/include/iconv.h
39 )
40 unset(HAVE_VISIBILITY)
41 unset(ICONV_CONST)
42 unset(USE_MBSTATE_T)
43 unset(BROKEN_WCHAR_H)
44 unset(EILSEQ)
45 unset(HAVE_WCHAR_T)
46
47 if (NOT EXISTS ${LIBICONV_SOURCES_DIR}/include/config.h)
48 # Create an empty "config.h" for libiconv
49 file(WRITE ${LIBICONV_SOURCES_DIR}/include/config.h "")
50 endif()
51
52 include_directories(
53 ${LIBICONV_SOURCES_DIR}/include
54 )
55
56 set(LIBICONV_SOURCES
57 ${LIBICONV_SOURCES_DIR}/lib/iconv.c
58 ${LIBICONV_SOURCES_DIR}/lib/relocatable.c
59 ${LIBICONV_SOURCES_DIR}/libcharset/lib/localcharset.c
60 ${LIBICONV_SOURCES_DIR}/libcharset/lib/relocatable.c
61 )
62
63 source_group(ThirdParty\\libiconv REGULAR_EXPRESSION ${LIBICONV_SOURCES_DIR}/.*)
64
65 if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
66 add_definitions(-DHAVE_WORKING_O_NOFOLLOW=0)
67 else()
68 add_definitions(-DHAVE_WORKING_O_NOFOLLOW=1)
69 endif()
70
71 else()
72 CHECK_INCLUDE_FILE_CXX(iconv.h HAVE_ICONV_H)
73 if (NOT HAVE_ICONV_H)
74 message(FATAL_ERROR "Please install the libiconv-dev package")
75 endif()
76
77 # Check whether the support for libiconv is bundled within the
78 # standard C library
79 CHECK_FUNCTION_EXISTS(iconv_open HAVE_ICONV_LIB)
80 if (NOT HAVE_ICONV_LIB)
81 # No builtin support for libiconv, try and find an external library.
82 # Open question: Does this make sense on any platform?
83 CHECK_LIBRARY_EXISTS(iconv iconv_open "" HAVE_ICONV_LIB_2)
84 if (NOT HAVE_ICONV_LIB_2)
85 message(FATAL_ERROR "Please install the libiconv-dev package")
86 else()
87 link_libraries(iconv)
88 endif()
89 endif()
90 endif()