Mercurial > hg > orthanc
annotate Resources/CMake/LibIconvConfiguration.cmake @ 2366:26f3a346226f
more consistent handling of libiconv in cmake
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 21 Aug 2017 21:21:48 +0200 |
parents | 423d3b692bb9 |
children | 2aff870c2c58 |
rev | line source |
---|---|
2366
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
1 if (NOT USE_BOOST_ICONV) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
2 message("Not using libiconv") |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
3 |
2366
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
4 if (CMAKE_SYSTEM_NAME STREQUAL "Windows") |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
5 # Starting with release 0.8.2, Orthanc statically links against |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
6 # libiconv, even on Windows. Indeed, the "WCONV" library of |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
7 # Windows XP seems not to support properly several codepages |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
8 # (notably "Latin3", "Hebrew", and "Arabic"). The flag |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
9 # "USE_BOOST_ICONV" allows to force the use of "WCONV". |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
10 add_definitions(-DBOOST_LOCALE_WITH_WCONV=1) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
11 else() |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
12 message(FATAL_ERROR "Support your platform here") |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
13 endif() |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
14 |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
15 else() |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
16 message("Using libiconv") |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
17 |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
18 add_definitions( |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
19 -DBOOST_LOCALE_WITH_ICONV=1 |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
20 ) |
1094
1b905ad6c913
Replace wconv by iconv under Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
2366
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
22 if (STATIC_BUILD OR NOT USE_SYSTEM_LIBICONV) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
23 set(LIBICONV_SOURCES_DIR ${CMAKE_BINARY_DIR}/libiconv-1.15) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
24 set(LIBICONV_URL "http://www.orthanc-server.com/downloads/third-party/libiconv-1.15.tar.gz") |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
25 set(LIBICONV_MD5 "ace8b5f2db42f7b3b3057585e80d9808") |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
26 |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
27 DownloadPackage(${LIBICONV_MD5} ${LIBICONV_URL} "${LIBICONV_SOURCES_DIR}") |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
28 |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
29 # Disable the support of libiconv that is shipped by default with |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
30 # the C standard library on Linux. Setting this macro redirects |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
31 # calls from "iconv*()" to "libiconv*()" in the source code of |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
32 # "libiconv-1.15". |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
33 add_definitions(-DLIBICONV_PLUG=1) |
1094
1b905ad6c913
Replace wconv by iconv under Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
2366
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
35 # https://groups.google.com/d/msg/android-ndk/AS1nkxnk6m4/EQm09hD1tigJ |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
36 add_definitions( |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
37 -DBUILDING_LIBICONV=1 |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
38 -DIN_LIBRARY=1 |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
39 -DLIBDIR="" |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
40 -DICONV_CONST= |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
41 ) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
42 |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
43 configure_file( |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
44 ${LIBICONV_SOURCES_DIR}/srclib/localcharset.h |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
45 ${LIBICONV_SOURCES_DIR}/include |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
46 COPYONLY) |
1094
1b905ad6c913
Replace wconv by iconv under Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
2366
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
48 set(HAVE_VISIBILITY 0) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
49 set(ICONV_CONST ${ICONV_CONST}) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
50 set(USE_MBSTATE_T 1) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
51 set(BROKEN_WCHAR_H 0) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
52 set(EILSEQ) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
53 set(HAVE_WCHAR_T 1) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
54 configure_file( |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
55 ${LIBICONV_SOURCES_DIR}/include/iconv.h.build.in |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
56 ${LIBICONV_SOURCES_DIR}/include/iconv.h |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
57 ) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
58 unset(HAVE_VISIBILITY) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
59 unset(ICONV_CONST) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
60 unset(USE_MBSTATE_T) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
61 unset(BROKEN_WCHAR_H) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
62 unset(EILSEQ) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
63 unset(HAVE_WCHAR_T) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
64 |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
65 # Create an empty "config.h" for libiconv |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
66 file(WRITE ${LIBICONV_SOURCES_DIR}/include/config.h "") |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
67 |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
68 include_directories( |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
69 ${LIBICONV_SOURCES_DIR}/include |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
70 ) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
71 |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
72 set(LIBICONV_SOURCES |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
73 ${LIBICONV_SOURCES_DIR}/lib/iconv.c |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
74 ${LIBICONV_SOURCES_DIR}/lib/relocatable.c |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
75 ${LIBICONV_SOURCES_DIR}/libcharset/lib/localcharset.c |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
76 ${LIBICONV_SOURCES_DIR}/libcharset/lib/relocatable.c |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
77 ) |
1094
1b905ad6c913
Replace wconv by iconv under Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 |
2366
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
79 source_group(ThirdParty\\libiconv REGULAR_EXPRESSION ${LIBICONV_SOURCES_DIR}/.*) |
1494 | 80 |
2366
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
81 if (CMAKE_SYSTEM_NAME STREQUAL "Windows") |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
82 add_definitions(-DHAVE_WORKING_O_NOFOLLOW=0) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
83 else() |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
84 add_definitions(-DHAVE_WORKING_O_NOFOLLOW=1) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
85 endif() |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
86 |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
87 else() |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
88 CHECK_INCLUDE_FILE_CXX(iconv.h HAVE_ICONV_H) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
89 if (NOT HAVE_ICONV_H) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
90 message(FATAL_ERROR "Please install the libiconv-dev package") |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
91 endif() |
1094
1b905ad6c913
Replace wconv by iconv under Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
2366
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
93 # Check whether the support for libiconv is bundled within the |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
94 # standard library |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
95 CHECK_FUNCTION_EXISTS(iconv_open HAVE_ICONV_LIB) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
96 if (NOT HAVE_ICONV_LIB) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
97 # No builtin support for libiconv, try and find an external library. |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
98 # Open question: Does this make sense on any platform? |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
99 CHECK_LIBRARY_EXISTS(iconv iconv_open "" HAVE_ICONV_LIB_2) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
100 if (NOT HAVE_ICONV_LIB_2) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
101 message(FATAL_ERROR "Please install the libiconv-dev package") |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
102 else() |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
103 link_libraries(iconv) |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
104 endif() |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
105 endif() |
2113
0108ac01fc8e
added source_group directives for MSVC
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1537
diff
changeset
|
106 |
2366
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
107 endif() |
26f3a346226f
more consistent handling of libiconv in cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
108 endif() |