comparison Resources/CMake/LibCurlConfiguration.cmake @ 2450:ade8b4ddd8a6

Static linking against libuuid
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Jan 2018 11:02:59 +0100
parents 862d943115f9
children 292bd85d4532
comparison
equal deleted inserted replaced
2449:e779c11c8eb2 2450:ade8b4ddd8a6
1 macro(CHECK_CURL_TYPE_EXISTS TYPE VARIABLE)
2 check_type_size("${TYPE}" SIZEOF_TYPE) # LANGUAGE CXX)
3
4 if (SIZEOF_TYPE)
5 set(${VARIABLE} ON)
6 else()
7 set(${VARIABLE} OFF)
8 endif()
9 endmacro()
10
11
12 if (STATIC_BUILD OR NOT USE_SYSTEM_CURL) 1 if (STATIC_BUILD OR NOT USE_SYSTEM_CURL)
13 SET(CURL_SOURCES_DIR ${CMAKE_BINARY_DIR}/curl-7.57.0) 2 SET(CURL_SOURCES_DIR ${CMAKE_BINARY_DIR}/curl-7.57.0)
14 SET(CURL_URL "http://www.orthanc-server.com/downloads/third-party/curl-7.57.0.tar.gz") 3 SET(CURL_URL "http://www.orthanc-server.com/downloads/third-party/curl-7.57.0.tar.gz")
15 SET(CURL_MD5 "c7aab73aaf5e883ca1d7518f93649dc2") 4 SET(CURL_MD5 "c7aab73aaf5e883ca1d7518f93649dc2")
16 5
6 if (IS_DIRECTORY "${CURL_SOURCES_DIR}")
7 set(FirstRun OFF)
8 else()
9 set(FirstRun ON)
10 endif()
11
17 DownloadPackage(${CURL_MD5} ${CURL_URL} "${CURL_SOURCES_DIR}") 12 DownloadPackage(${CURL_MD5} ${CURL_URL} "${CURL_SOURCES_DIR}")
18 13
14 if (FirstRun)
15 execute_process(
16 COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
17 ${ORTHANC_ROOT}/Resources/Patches/curl-7.57.0-cmake.patch
18 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
19 RESULT_VARIABLE Failure
20 )
21
22 if (Failure)
23 message(FATAL_ERROR "Error while patching a file")
24 endif()
25 endif()
26
19 include_directories( 27 include_directories(
20 ${CURL_SOURCES_DIR}/include 28 ${CURL_SOURCES_DIR}/include
21 ) 29 )
22 30
23 AUX_SOURCE_DIRECTORY(${CURL_SOURCES_DIR}/lib CURL_SOURCES) 31 AUX_SOURCE_DIRECTORY(${CURL_SOURCES_DIR}/lib CURL_SOURCES)
81 89
82 set_property( 90 set_property(
83 SOURCE ${CURL_SOURCES} 91 SOURCE ${CURL_SOURCES}
84 PROPERTY COMPILE_DEFINITIONS "HAVE_CONFIG_H=1;OS=\"${TMP_OS}\"" 92 PROPERTY COMPILE_DEFINITIONS "HAVE_CONFIG_H=1;OS=\"${TMP_OS}\""
85 ) 93 )
86 94
87 include(CheckTypeSize) 95 include(${CURL_SOURCES_DIR}/CMake/Macros.cmake)
88 include(CheckIncludeFile) 96
89 include(CheckSymbolExists) 97 check_include_file_concat("alloca.h" HAVE_ALLOCA_H)
90 98 check_include_file_concat("arpa/inet.h" HAVE_ARPA_INET_H)
91 CHECK_INCLUDE_FILE(time.h HAVE_TIME_H) 99 check_include_file_concat("arpa/tftp.h" HAVE_ARPA_TFTP_H)
92 CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H) 100 check_include_file_concat("assert.h" HAVE_ASSERT_H)
93 CHECK_INCLUDE_FILE(sys/socket.h HAVE_SYS_SOCKET_H) 101 check_include_file_concat("crypto.h" HAVE_CRYPTO_H)
94 CHECK_INCLUDE_FILE(netinet/in.h HAVE_NETINET_IN_H) 102 check_include_file_concat("des.h" HAVE_DES_H)
95 CHECK_INCLUDE_FILE(netdb.h HAVE_NETDB_H) 103 check_include_file_concat("dlfcn.h" HAVE_DLFCN_H)
96 CHECK_INCLUDE_FILE(fcntl.h HAVE_FCNTL_H) 104 check_include_file_concat("err.h" HAVE_ERR_H)
97 CHECK_INCLUDE_FILE(errno.h HAVE_ERRNO_H) 105 check_include_file_concat("errno.h" HAVE_ERRNO_H)
98 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H) 106 check_include_file_concat("fcntl.h" HAVE_FCNTL_H)
99 CHECK_INCLUDE_FILE(stdio.h HAVE_STDIO_H) 107 check_include_file_concat("idn2.h" HAVE_IDN2_H)
100 CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) 108 check_include_file_concat("ifaddrs.h" HAVE_IFADDRS_H)
101 109 check_include_file_concat("inttypes.h" HAVE_INTTYPES_H)
102 CHECK_CURL_TYPE_EXISTS("long long" HAVE_LONGLONG) 110 check_include_file_concat("io.h" HAVE_IO_H)
103 111 check_include_file_concat("krb.h" HAVE_KRB_H)
104 check_symbol_exists(socket "sys/socket.h" HAVE_SOCKET) 112 check_include_file_concat("libgen.h" HAVE_LIBGEN_H)
105 check_symbol_exists(recv "sys/socket.h" HAVE_RECV) 113 check_include_file_concat("limits.h" HAVE_LIMITS_H)
106 check_symbol_exists(send "sys/socket.h" HAVE_SEND) 114 check_include_file_concat("locale.h" HAVE_LOCALE_H)
107 check_symbol_exists(select "sys/select.h" HAVE_SELECT) 115 check_include_file_concat("malloc.h" HAVE_MALLOC_H)
116 check_include_file_concat("memory.h" HAVE_MEMORY_H)
117 check_include_file_concat("net/if.h" HAVE_NET_IF_H)
118 check_include_file_concat("netdb.h" HAVE_NETDB_H)
119 check_include_file_concat("netinet/if_ether.h" HAVE_NETINET_IF_ETHER_H)
120 check_include_file_concat("netinet/in.h" HAVE_NETINET_IN_H)
121 check_include_file_concat("netinet/tcp.h" HAVE_NETINET_TCP_H)
122 check_include_file_concat("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H)
123 check_include_file_concat("openssl/engine.h" HAVE_OPENSSL_ENGINE_H)
124 check_include_file_concat("openssl/err.h" HAVE_OPENSSL_ERR_H)
125 check_include_file_concat("openssl/pem.h" HAVE_OPENSSL_PEM_H)
126 check_include_file_concat("openssl/rand.h" HAVE_OPENSSL_RAND_H)
127 check_include_file_concat("openssl/rsa.h" HAVE_OPENSSL_RSA_H)
128 check_include_file_concat("openssl/ssl.h" HAVE_OPENSSL_SSL_H)
129 check_include_file_concat("openssl/x509.h" HAVE_OPENSSL_X509_H)
130 check_include_file_concat("pem.h" HAVE_PEM_H)
131 check_include_file_concat("poll.h" HAVE_POLL_H)
132 check_include_file_concat("process.h" HAVE_PROCESS_H)
133 check_include_file_concat("pwd.h" HAVE_PWD_H)
134 check_include_file_concat("rsa.h" HAVE_RSA_H)
135 check_include_file_concat("setjmp.h" HAVE_SETJMP_H)
136 check_include_file_concat("sgtty.h" HAVE_SGTTY_H)
137 check_include_file_concat("signal.h" HAVE_SIGNAL_H)
138 check_include_file_concat("sockio.h" HAVE_SOCKIO_H)
139 check_include_file_concat("ssl.h" HAVE_SSL_H)
140 check_include_file_concat("stdbool.h" HAVE_STDBOOL_H)
141 check_include_file_concat("stddef.h" HAVE_STDDEF_H)
142 check_include_file_concat("stdint.h" HAVE_STDINT_H)
143 check_include_file_concat("stdint.h" HAVE_STDINT_H)
144 check_include_file_concat("stdio.h" HAVE_STDIO_H)
145 check_include_file_concat("stdio.h" HAVE_STDIO_H)
146 check_include_file_concat("stdlib.h" HAVE_STDLIB_H)
147 check_include_file_concat("string.h" HAVE_STRING_H)
148 check_include_file_concat("strings.h" HAVE_STRINGS_H)
149 check_include_file_concat("stropts.h" HAVE_STROPTS_H)
150 check_include_file_concat("sys/filio.h" HAVE_SYS_FILIO_H)
151 check_include_file_concat("sys/ioctl.h" HAVE_SYS_IOCTL_H)
152 check_include_file_concat("sys/param.h" HAVE_SYS_PARAM_H)
153 check_include_file_concat("sys/poll.h" HAVE_SYS_POLL_H)
154 check_include_file_concat("sys/resource.h" HAVE_SYS_RESOURCE_H)
155 check_include_file_concat("sys/select.h" HAVE_SYS_SELECT_H)
156 check_include_file_concat("sys/socket.h" HAVE_SYS_SOCKET_H)
157 check_include_file_concat("sys/sockio.h" HAVE_SYS_SOCKIO_H)
158 check_include_file_concat("sys/stat.h" HAVE_SYS_STAT_H)
159 check_include_file_concat("sys/time.h" HAVE_SYS_TIME_H)
160 check_include_file_concat("sys/types.h" HAVE_SYS_TYPES_H)
161 check_include_file_concat("sys/uio.h" HAVE_SYS_UIO_H)
162 check_include_file_concat("sys/un.h" HAVE_SYS_UN_H)
163 check_include_file_concat("sys/utime.h" HAVE_SYS_UTIME_H)
164 check_include_file_concat("sys/utsname.h" HAVE_SYS_UTSNAME_H)
165 check_include_file_concat("sys/xattr.h" HAVE_SYS_XATTR_H)
166 check_include_file_concat("termio.h" HAVE_TERMIO_H)
167 check_include_file_concat("termios.h" HAVE_TERMIOS_H)
168 check_include_file_concat("time.h" HAVE_TIME_H)
169 check_include_file_concat("unistd.h" HAVE_UNISTD_H)
170 check_include_file_concat("utime.h" HAVE_UTIME_H)
171 check_include_file_concat("x509.h" HAVE_X509_H)
108 172
109 check_type_size("size_t" SIZEOF_SIZE_T) 173 check_type_size("size_t" SIZEOF_SIZE_T)
110 check_type_size("ssize_t" SIZEOF_SSIZE_T) 174 check_type_size("ssize_t" SIZEOF_SSIZE_T)
111 check_type_size("long long" SIZEOF_LONG_LONG) 175 check_type_size("long long" SIZEOF_LONG_LONG)
112 check_type_size("long" SIZEOF_LONG) 176 check_type_size("long" SIZEOF_LONG)
116 check_type_size("long double" SIZEOF_LONG_DOUBLE) 180 check_type_size("long double" SIZEOF_LONG_DOUBLE)
117 check_type_size("time_t" SIZEOF_TIME_T) 181 check_type_size("time_t" SIZEOF_TIME_T)
118 check_type_size("off_t" SIZEOF_OFF_T) 182 check_type_size("off_t" SIZEOF_OFF_T)
119 check_type_size("socklen_t" CURL_SIZEOF_CURL_SOCKLEN_T) 183 check_type_size("socklen_t" CURL_SIZEOF_CURL_SOCKLEN_T)
120 184
185 check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME)
186 check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET)
187 # poll on macOS is unreliable, it first did not exist, then was broken until
188 # fixed in 10.9 only to break again in 10.12.
189 if(NOT APPLE)
190 check_symbol_exists(poll "${CURL_INCLUDES}" HAVE_POLL)
191 endif()
192 check_symbol_exists(select "${CURL_INCLUDES}" HAVE_SELECT)
193 check_symbol_exists(strdup "${CURL_INCLUDES}" HAVE_STRDUP)
194 check_symbol_exists(strstr "${CURL_INCLUDES}" HAVE_STRSTR)
195 check_symbol_exists(strtok_r "${CURL_INCLUDES}" HAVE_STRTOK_R)
196 check_symbol_exists(strftime "${CURL_INCLUDES}" HAVE_STRFTIME)
197 check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME)
198 check_symbol_exists(strcasecmp "${CURL_INCLUDES}" HAVE_STRCASECMP)
199 check_symbol_exists(stricmp "${CURL_INCLUDES}" HAVE_STRICMP)
200 check_symbol_exists(strcmpi "${CURL_INCLUDES}" HAVE_STRCMPI)
201 check_symbol_exists(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI)
202 check_symbol_exists(alarm "${CURL_INCLUDES}" HAVE_ALARM)
203 if(NOT HAVE_STRNCMPI)
204 set(HAVE_STRCMPI)
205 endif(NOT HAVE_STRNCMPI)
206
207 check_symbol_exists(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR)
208 check_symbol_exists(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R)
209 check_symbol_exists(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY)
210 check_symbol_exists(inet_addr "${CURL_INCLUDES}" HAVE_INET_ADDR)
211 check_symbol_exists(inet_ntoa "${CURL_INCLUDES}" HAVE_INET_NTOA)
212 check_symbol_exists(inet_ntoa_r "${CURL_INCLUDES}" HAVE_INET_NTOA_R)
213 check_symbol_exists(tcsetattr "${CURL_INCLUDES}" HAVE_TCSETATTR)
214 check_symbol_exists(tcgetattr "${CURL_INCLUDES}" HAVE_TCGETATTR)
215 check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR)
216 check_symbol_exists(closesocket "${CURL_INCLUDES}" HAVE_CLOSESOCKET)
217 check_symbol_exists(setvbuf "${CURL_INCLUDES}" HAVE_SETVBUF)
218 check_symbol_exists(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP)
219 check_symbol_exists(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R)
220 check_symbol_exists(strlcat "${CURL_INCLUDES}" HAVE_STRLCAT)
221 check_symbol_exists(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID)
222 check_symbol_exists(geteuid "${CURL_INCLUDES}" HAVE_GETEUID)
223 check_symbol_exists(utime "${CURL_INCLUDES}" HAVE_UTIME)
224 check_symbol_exists(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R)
225 check_symbol_exists(localtime_r "${CURL_INCLUDES}" HAVE_LOCALTIME_R)
226
227 check_symbol_exists(gethostbyname "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME)
228 check_symbol_exists(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R)
229
230 check_symbol_exists(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC)
231 check_symbol_exists(SIGALRM "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO)
232 if(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
233 set(HAVE_SIGNAL 1)
234 endif(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
235 check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME)
236 check_symbol_exists(strtoll "${CURL_INCLUDES}" HAVE_STRTOLL)
237 check_symbol_exists(_strtoi64 "${CURL_INCLUDES}" HAVE__STRTOI64)
238 check_symbol_exists(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R)
239 check_symbol_exists(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT)
240 check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR)
241 check_symbol_exists(fork "${CURL_INCLUDES}" HAVE_FORK)
242 check_symbol_exists(getaddrinfo "${CURL_INCLUDES}" HAVE_GETADDRINFO)
243 check_symbol_exists(freeaddrinfo "${CURL_INCLUDES}" HAVE_FREEADDRINFO)
244 check_symbol_exists(freeifaddrs "${CURL_INCLUDES}" HAVE_FREEIFADDRS)
245 check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE)
246 check_symbol_exists(ftruncate "${CURL_INCLUDES}" HAVE_FTRUNCATE)
247 check_symbol_exists(getprotobyname "${CURL_INCLUDES}" HAVE_GETPROTOBYNAME)
248 check_symbol_exists(getrlimit "${CURL_INCLUDES}" HAVE_GETRLIMIT)
249 check_symbol_exists(setlocale "${CURL_INCLUDES}" HAVE_SETLOCALE)
250 check_symbol_exists(setmode "${CURL_INCLUDES}" HAVE_SETMODE)
251 check_symbol_exists(setrlimit "${CURL_INCLUDES}" HAVE_SETRLIMIT)
252 check_symbol_exists(fcntl "${CURL_INCLUDES}" HAVE_FCNTL)
253 check_symbol_exists(ioctl "${CURL_INCLUDES}" HAVE_IOCTL)
254 check_symbol_exists(setsockopt "${CURL_INCLUDES}" HAVE_SETSOCKOPT)
255
256 if(HAVE_SIZEOF_LONG_LONG)
257 set(HAVE_LONGLONG 1)
258 set(HAVE_LL 1)
259 endif(HAVE_SIZEOF_LONG_LONG)
260
261 check_function_exists(mach_absolute_time HAVE_MACH_ABSOLUTE_TIME)
262 check_function_exists(gethostname HAVE_GETHOSTNAME)
263
264 check_include_file_concat("pthread.h" HAVE_PTHREAD_H)
265 check_symbol_exists(recv "sys/socket.h" HAVE_RECV)
266 check_symbol_exists(send "sys/socket.h" HAVE_SEND)
267
268 check_struct_has_member("struct sockaddr_un" sun_path "sys/un.h" USE_UNIX_SOCKETS)
269
121 set(CMAKE_REQUIRED_INCLUDES "${CURL_SOURCES_DIR}/include") 270 set(CMAKE_REQUIRED_INCLUDES "${CURL_SOURCES_DIR}/include")
122 set(CMAKE_EXTRA_INCLUDE_FILES "curl/system.h") 271 set(CMAKE_EXTRA_INCLUDE_FILES "curl/system.h")
123 check_type_size("curl_off_t" SIZEOF_CURL_OFF_T) 272 check_type_size("curl_off_t" SIZEOF_CURL_OFF_T)
124 273
274 add_definitions(-DHAVE_GLIBC_STRERROR_R=1)
275
125 include(${CURL_SOURCES_DIR}/CMake/OtherTests.cmake) 276 include(${CURL_SOURCES_DIR}/CMake/OtherTests.cmake)
126 set(HAVE_STRUCT_TIMEVAL ON) # TODO WHY IS THIS NECESSARY? 277
127 set(HAVE_FCNTL_O_NONBLOCK ON) # TODO WHY IS THIS NECESSARY? 278 foreach(CURL_TEST
279 HAVE_FCNTL_O_NONBLOCK
280 HAVE_IOCTLSOCKET
281 HAVE_IOCTLSOCKET_CAMEL
282 HAVE_IOCTLSOCKET_CAMEL_FIONBIO
283 HAVE_IOCTLSOCKET_FIONBIO
284 HAVE_IOCTL_FIONBIO
285 HAVE_IOCTL_SIOCGIFADDR
286 HAVE_SETSOCKOPT_SO_NONBLOCK
287 HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
288 TIME_WITH_SYS_TIME
289 HAVE_O_NONBLOCK
290 HAVE_GETHOSTBYADDR_R_5
291 HAVE_GETHOSTBYADDR_R_7
292 HAVE_GETHOSTBYADDR_R_8
293 HAVE_GETHOSTBYADDR_R_5_REENTRANT
294 HAVE_GETHOSTBYADDR_R_7_REENTRANT
295 HAVE_GETHOSTBYADDR_R_8_REENTRANT
296 HAVE_GETHOSTBYNAME_R_3
297 HAVE_GETHOSTBYNAME_R_5
298 HAVE_GETHOSTBYNAME_R_6
299 HAVE_GETHOSTBYNAME_R_3_REENTRANT
300 HAVE_GETHOSTBYNAME_R_5_REENTRANT
301 HAVE_GETHOSTBYNAME_R_6_REENTRANT
302 HAVE_SOCKLEN_T
303 HAVE_IN_ADDR_T
304 HAVE_BOOL_T
305 STDC_HEADERS
306 RETSIGTYPE_TEST
307 HAVE_INET_NTOA_R_DECL
308 HAVE_INET_NTOA_R_DECL_REENTRANT
309 HAVE_GETADDRINFO
310 HAVE_FILE_OFFSET_BITS
311 )
312 curl_internal_test(${CURL_TEST})
313 endforeach(CURL_TEST)
128 314
129 configure_file( 315 configure_file(
130 ${CURL_SOURCES_DIR}/lib/curl_config.h.cmake 316 ${CURL_SOURCES_DIR}/lib/curl_config.h.cmake
131 ${CURL_SOURCES_DIR}/lib/curl_config.h 317 ${CURL_SOURCES_DIR}/lib/curl_config.h
132 ) 318 )