[Repository Listing] / [Slicer3-lib-mirrors] / trunk / cmcurl / CMakeLists.txt
 

View of /trunk/cmcurl/CMakeLists.txt

Parent Directory Parent Directory Revision Log Revision Log


Revision 185  Download Blame
File MIME type: text/plain
File size: 26719 byte(s)
COMP: cmcurl - Optionnally include CTestUseLaunchers
1 # Code in this directory is identical to the code in the CURL library that
2 # is included with CMake. This CMakeLists.txt file has been extended
3 # to support the external use of the library via CMake and to support the
4 # integration with Slicer. These changes have not been committed back to
5 # the CMake project.
6
7
8 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
9 IF(COMMAND CMAKE_POLICY)
10 CMAKE_POLICY(SET CMP0003 NEW)
11 ENDIF(COMMAND CMAKE_POLICY)
12
13 PROJECT(SLICERLIBCURL C)
14
15 INCLUDE(CTestUseLaunchers OPTIONAL)
16
17 #-----------------------------------------------------------------------------
18 # Disable MSVC 8 warnings
19 IF(WIN32)
20 OPTION(DISABLE_MSVC8_DEPRECATED_WARNINGS
21 "Disable Visual Studio 8 deprecated warnings" ON)
22 MARK_AS_ADVANCED(FORCE DISABLE_MSVC8_DEPRECATED_WARNINGS)
23 IF(DISABLE_MSVC8_DEPRECATED_WARNINGS)
24 ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
25 ENDIF(DISABLE_MSVC8_DEPRECATED_WARNINGS)
26 ENDIF(WIN32)
27
28 #-----------------------------------------------------------------------------
29 # CMakeLists.txt custom to Slicer...
30
31 IF(NOT LIBRARY_OUTPUT_PATH)
32 SET(LIBRARY_OUTPUT_PATH "${SLICERLIBCURL_BINARY_DIR}/bin" CACHE PATH
33 "Single output directory for building all libraries.")
34 ENDIF(NOT LIBRARY_OUTPUT_PATH)
35 MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH)
36
37 SET(SLICERLIBCURL_LIBRARY_DIR "${LIBRARY_OUTPUT_PATH}")
38
39 SET(SLICERLIBCURL_RUNTIME_DIR "${LIBRARY_OUTPUT_PATH}")
40
41 SET(SLICERLIBCURL_INCLUDE_PATH "${SLICERLIBCURL_SOURCE_DIR}/slicerlibcurl")
42
43
44 IF(WIN32)
45 SET(SLICERLIBCURL_LIBRARIES slicerlibcurl Winmm.lib)
46 ELSE(WIN32)
47 SET(SLICERLIBCURL_LIBRARIES slicerlibcurl)
48 ENDIF(WIN32)
49
50 IF(NOT EXECUTABLE_OUTPUT_PATH)
51 SET(EXECUTABLE_OUTPUT_PATH ${SLICERLIBCURL_BINARY_DIR}/bin CACHE PATH
52 "Single output directory for building all executables.")
53 ENDIF(NOT EXECUTABLE_OUTPUT_PATH)
54 MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH)
55
56 # More CMakeLists.txt custom to Slicer at end of file
57 #-----------------------------------------------------------------------------
58
59 #-----------------------------------------------------------------------------
60 # CMakeLists.txt from CMake's curl library...
61
62 INCLUDE_REGULAR_EXPRESSION("^.*$")
63
64 # Setup package meta-data
65 SET(PACKAGE "slicerlibcurl")
66 SET(VERSION "7.12.1")
67 SET(PACKAGE_TARNAME "slicerlibcurl")
68 SET(PACKAGE_BUGREPORT " ")
69 SET(PACKAGE_NAME "slicerlibcurl")
70 SET(PACKAGE_VERSION "-")
71 SET(PACKAGE_STRING "slicerlibcurl-")
72 SET(PACKAGE_BUGREPORT "a suitable curl mailing list => http://curl.haxx.se/mail/")
73 SET(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}")
74
75 # We need ansi c-flags, especially on HP
76 SET(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
77 SET(CMAKE_REQUIRED_FLAGS ${CMAKE_ANSI_CFLAGS})
78
79 # Disable warnings on Borland to avoid changing 3rd party code.
80 IF(BORLAND)
81 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")
82 ENDIF(BORLAND)
83
84 # If we are on AIX, do the _ALL_SOURCE magic
85 IF(${CMAKE_SYSTEM_NAME} MATCHES AIX)
86 SET(_ALL_SOURCE 1)
87 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES AIX)
88
89 # Include all the necessary files for macros
90 SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
91 INCLUDE (CheckFunctionExists)
92 INCLUDE (CheckIncludeFile)
93 INCLUDE (CheckIncludeFiles)
94 INCLUDE (CheckLibraryExists)
95 INCLUDE (CheckSymbolExists)
96 INCLUDE (CheckTypeSize)
97 INCLUDE (curlCheckCAcceptsFlags)
98
99 SET(libCurl_SRCS
100 base64.c
101 connect.c
102 content_encoding.c
103 cookie.c
104 dict.c
105 easy.c
106 escape.c
107 file.c
108 formdata.c
109 ftp.c
110 getdate.c
111 getenv.c
112 getinfo.c
113 hash.c
114 hostares.c
115 hostasyn.c
116 hostip.c
117 hostip4.c
118 hostip6.c
119 hostsyn.c
120 hostthre.c
121 http.c
122 http_chunks.c
123 http_digest.c
124 http_negotiate.c
125 http_ntlm.c
126 if2ip.c
127 inet_ntop.c
128 inet_pton.c
129 krb4.c
130 llist.c
131 md5.c
132 memdebug.c
133 mprintf.c
134 multi.c
135 netrc.c
136 progress.c
137 sendf.c
138 share.c
139 speedcheck.c
140 ssluse.c
141 strequal.c
142 strerror.c
143 telnet.c
144 timeval.c
145 transfer.c
146 url.c
147 version.c
148 )
149
150 SET(CURL_DISABLE_LDAP 1)
151 IF(NOT CURL_DISABLE_LDAP)
152 SET(libCurl_SRCS
153 ${libCurl_SRCS}
154 ldap.c
155 )
156 ENDIF(NOT CURL_DISABLE_LDAP)
157
158 # if we have Kerberos 4, right now this is never on
159 #OPTION(CURL_KRB4 "Use Kerberos 4" OFF)
160 IF(CURL_KRB4)
161 SET(libCurl_SRCS ${libCurl_SRCS}
162 krb4.c
163 security.c
164 )
165 ENDIF(CURL_KRB4)
166
167 #OPTION(CURL_MALLOC_DEBUG "Debug mallocs in Curl" OFF)
168 MARK_AS_ADVANCED(CURL_MALLOC_DEBUG)
169 IF(CURL_MALLOC_DEBUG)
170 SET(libCurl_SRCS ${libCurl_SRCS}
171 memdebug.c
172 )
173 ENDIF(CURL_MALLOC_DEBUG)
174
175 # On windows preload settings
176 IF(WIN32)
177 INCLUDE(${SLICERLIBCURL_SOURCE_DIR}/Platforms/WindowsCache.cmake)
178 ENDIF(WIN32)
179
180 # This macro checks if the symbol exists in the library and if it
181 # does, it appends library to the list.
182 SET(CURL_LIBS "")
183 MACRO(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE)
184 CHECK_LIBRARY_EXISTS("${LIBRARY};${CURL_LIBS}" ${SYMBOL} ""
185 ${VARIABLE})
186 IF(${VARIABLE})
187 SET(CURL_LIBS ${CURL_LIBS} ${LIBRARY})
188 ENDIF(${VARIABLE})
189 ENDMACRO(CHECK_LIBRARY_EXISTS_CONCAT)
190
191 # Check for all needed libraries
192 CHECK_LIBRARY_EXISTS_CONCAT("dl" dlopen HAVE_LIBDL)
193 CHECK_LIBRARY_EXISTS_CONCAT("ucb" gethostname HAVE_LIBUCB)
194 CHECK_LIBRARY_EXISTS_CONCAT("socket" connect HAVE_LIBSOCKET)
195 CHECK_LIBRARY_EXISTS("c" gethostbyname "" NOT_NEED_LIBNSL)
196
197 IF(NOT NOT_NEED_LIBNSL)
198 CHECK_LIBRARY_EXISTS_CONCAT("nsl" gethostbyname HAVE_LIBNSL)
199 ENDIF(NOT NOT_NEED_LIBNSL)
200
201 CHECK_LIBRARY_EXISTS_CONCAT("ws2_32" getch HAVE_LIBWS2_32)
202 CHECK_LIBRARY_EXISTS_CONCAT("winmm" getch HAVE_LIBWINMM)
203 IF(NOT CURL_SPECIAL_LIBZ)
204 CHECK_LIBRARY_EXISTS_CONCAT("z" inflateEnd HAVE_LIBZ)
205 ENDIF(NOT CURL_SPECIAL_LIBZ)
206
207 option(CURL_USE_OPENSSL "Use OpenSSL code. Experimental" OFF)
208 mark_as_advanced(CURL_USE_OPENSSL)
209 IF(CURL_USE_OPENSSL)
210 ADD_DEFINITIONS(-DUSE_OPENSSL)
211 ADD_DEFINITIONS(-DUSE_SSLEAY)
212 if ( WIN32 )
213 set (SLICERLIBCURL_INCLUDE_PATH ${SLICERLIBCURL_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/openssl-0.9.8g_win32/include )
214 set (SLICERLIBCURL_LIBRARY_DIR ${SLICERLIBCURL_LIBRARY_DIR} ${CMAKE_SOURCE_DIR}/openssl-0.9.8g_win32/lib )
215 include_directories ( ${CMAKE_SOURCE_DIR}/openssl-0.9.8g_win32/include )
216 link_directories ( ${CMAKE_SOURCE_DIR}/openssl-0.9.8g_win32/lib )
217 link_libraries ( libeay32 ssleay32 )
218 set(SLICERLIBCURL_LIBRARIES ${SLICERLIBCURL_LIBRARIES} libeay32 ssleay32)
219 else ( WIN32 )
220 # Build it
221 SUBDIRS(openssl)
222 set (SLICERLIBCURL_INCLUDE_PATH ${SLICERLIBCURL_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/openssl/include )
223 set (SLICERLIBCURL_INCLUDE_PATH ${SLICERLIBCURL_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/openssl/ )
224 set (SLICERLIBCURL_INCLUDE_PATH ${SLICERLIBCURL_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/openssl/include )
225 set (SLICERLIBCURL_INCLUDE_PATH ${SLICERLIBCURL_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/openssl/src/include )
226 INCLUDE_DIRECTORIES ( openssl )
227 INCLUDE_DIRECTORIES ( openssl/include )
228 INCLUDE_DIRECTORIES ( ${CURL_BINARY_DIR}/openssl )
229 INCLUDE_DIRECTORIES ( ${CURL_BINARY_DIR}/openssl/src/include )
230 link_libraries(openssl)
231 set(SLICERLIBCURL_LIBRARIES ${SLICERLIBCURL_LIBRARIES} openssl)
232 endif ( WIN32 )
233 ENDIF(CURL_USE_OPENSSL)
234
235 # Check for symbol dlopen (same as HAVE_LIBDL)
236 CHECK_LIBRARY_EXISTS("${CURL_LIBS}" dlopen "" HAVE_DLOPEN)
237
238 # For other tests to use the same libraries
239 SET(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBS})
240
241 IF(CURL_SPECIAL_LIBZ)
242 SET(CURL_LIBS ${CURL_LIBS} "${CURL_SPECIAL_LIBZ}")
243 INCLUDE_DIRECTORIES(${CURL_SPECIAL_LIBZ_INCLUDES})
244 SET(HAVE_LIBZ 0)
245 SET(HAVE_ZLIB_H 0)
246 ENDIF(CURL_SPECIAL_LIBZ)
247
248
249 # If we have features.h, then do the _BSD_SOURCE magic
250 CHECK_INCLUDE_FILE("features.h" HAVE_FEATURES_H)
251 IF(HAVE_FEATURES_H)
252 SET_SOURCE_FILES_PROPERTIES(
253 cookie.c
254 easy.c
255 formdata.c
256 getenv.c
257 hash.c
258 http.c
259 if2ip.c
260 mprintf.c
261 multi.c
262 sendf.c
263 telnet.c
264 transfer.c
265 url.c
266 COMPILE_FLAGS -D_BSD_SOURCE)
267 ENDIF(HAVE_FEATURES_H)
268
269 # Check if header file exists and add it to the list.
270 MACRO(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE)
271 CHECK_INCLUDE_FILES("${CURL_INCLUDES};${FILE}" ${VARIABLE})
272 IF(${VARIABLE})
273 SET(CURL_INCLUDES ${CURL_INCLUDES} ${FILE})
274 ENDIF(${VARIABLE})
275 ENDMACRO(CHECK_INCLUDE_FILE_CONCAT)
276
277 # Check for header files
278 CHECK_INCLUDE_FILE_CONCAT("stdio.h" HAVE_STDIO_H)
279 CHECK_INCLUDE_FILE_CONCAT("stddef.h" HAVE_STDDEF_H)
280 CHECK_INCLUDE_FILE_CONCAT("sys/types.h" HAVE_SYS_TYPES_H)
281 CHECK_INCLUDE_FILE_CONCAT("inttypes.h" HAVE_INTTYPES_H)
282 CHECK_INCLUDE_FILE_CONCAT("alloca.h" HAVE_ALLOCA_H)
283 CHECK_INCLUDE_FILE_CONCAT("arpa/inet.h" HAVE_ARPA_INET_H)
284 CHECK_INCLUDE_FILE_CONCAT("dlfcn.h" HAVE_DLFCN_H)
285 CHECK_INCLUDE_FILE_CONCAT("fcntl.h" HAVE_FCNTL_H)
286 CHECK_INCLUDE_FILE_CONCAT("malloc.h" HAVE_MALLOC_H)
287 CHECK_INCLUDE_FILE_CONCAT("memory.h" HAVE_MEMORY_H)
288 CHECK_INCLUDE_FILE_CONCAT("netdb.h" HAVE_NETDB_H)
289 CHECK_INCLUDE_FILE_CONCAT("sys/poll.h" HAVE_SYS_POLL_H)
290 CHECK_INCLUDE_FILE_CONCAT("assert.h" HAVE_ASSERT_H)
291 CHECK_INCLUDE_FILE_CONCAT("limits.h" HAVE_LIMITS_H)
292
293 IF(CMAKE_USE_OPENSSL)
294 CHECK_INCLUDE_FILE_CONCAT("openssl/x509.h" HAVE_OPENSSL_X509_H)
295 CHECK_INCLUDE_FILE_CONCAT("openssl/engine.h" HAVE_OPENSSL_ENGINE_H)
296 CHECK_INCLUDE_FILE_CONCAT("openssl/rsa.h" HAVE_OPENSSL_RSA_H)
297 CHECK_INCLUDE_FILE_CONCAT("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H)
298 CHECK_INCLUDE_FILE_CONCAT("openssl/pem.h" HAVE_OPENSSL_PEM_H)
299 CHECK_INCLUDE_FILE_CONCAT("openssl/ssl.h" HAVE_OPENSSL_SSL_H)
300 CHECK_INCLUDE_FILE_CONCAT("openssl/err.h" HAVE_OPENSSL_ERR_H)
301 CHECK_INCLUDE_FILE_CONCAT("openssl/rand.h" HAVE_OPENSSL_RAND_H)
302 ENDIF(CMAKE_USE_OPENSSL)
303
304 IF(NOT CURL_SPECIAL_LIBZ)
305 CHECK_INCLUDE_FILE_CONCAT("zlib.h" HAVE_ZLIB_H)
306 ENDIF(NOT CURL_SPECIAL_LIBZ)
307 CHECK_INCLUDE_FILE_CONCAT("sys/socket.h" HAVE_SYS_SOCKET_H)
308 CHECK_INCLUDE_FILE_CONCAT("netinet/in.h" HAVE_NETINET_IN_H)
309 CHECK_INCLUDE_FILE_CONCAT("net/if.h" HAVE_NET_IF_H)
310 CHECK_INCLUDE_FILE_CONCAT("netinet/if_ether.h"
311 HAVE_NETINET_IF_ETHER_H)
312 CHECK_INCLUDE_FILE_CONCAT("netinet/tcp.h"
313 HAVE_NETINET_TCP_H)
314 CHECK_INCLUDE_FILE_CONCAT("sys/select.h" HAVE_SYS_SELECT_H)
315 CHECK_INCLUDE_FILE_CONCAT("utime.h" HAVE_UTIME_H)
316 CHECK_INCLUDE_FILE_CONCAT("netinet/in.h" HAVE_NETINET_IN_H)
317 CHECK_INCLUDE_FILE_CONCAT("pwd.h" HAVE_PWD_H)
318 CHECK_INCLUDE_FILE_CONCAT("sgtty.h" HAVE_SGTTY_H)
319 CHECK_INCLUDE_FILE_CONCAT("stdint.h" HAVE_STDINT_H)
320 CHECK_INCLUDE_FILE_CONCAT("stdlib.h" HAVE_STDLIB_H)
321 CHECK_INCLUDE_FILE_CONCAT("string.h" HAVE_STRING_H)
322 CHECK_INCLUDE_FILE_CONCAT("strings.h" HAVE_STRINGS_H)
323 CHECK_INCLUDE_FILE_CONCAT("sys/param.h" HAVE_SYS_PARAM_H)
324 CHECK_INCLUDE_FILE_CONCAT("sys/stat.h" HAVE_SYS_STAT_H)
325 CHECK_INCLUDE_FILE_CONCAT("sys/time.h" HAVE_SYS_TIME_H)
326 CHECK_INCLUDE_FILE_CONCAT("termios.h" HAVE_TERMIOS_H)
327 CHECK_INCLUDE_FILE_CONCAT("termio.h" HAVE_TERMIO_H)
328 CHECK_INCLUDE_FILE_CONCAT("io.h" HAVE_IO_H)
329 CHECK_INCLUDE_FILE_CONCAT("time.h" HAVE_TIME_H)
330 CHECK_INCLUDE_FILE_CONCAT("unistd.h" HAVE_UNISTD_H)
331 CHECK_INCLUDE_FILE_CONCAT("sys/utime.h" HAVE_SYS_UTIME_H)
332 CHECK_INCLUDE_FILE_CONCAT("winsock.h" HAVE_WINSOCK_H)
333 CHECK_INCLUDE_FILE_CONCAT("sockio.h" HAVE_SOCKIO_H)
334 CHECK_INCLUDE_FILE_CONCAT("sys/sockio.h" HAVE_SYS_SOCKIO_H)
335 CHECK_INCLUDE_FILE_CONCAT("x509.h" HAVE_X509_H)
336 CHECK_INCLUDE_FILE_CONCAT("setjmp.h" HAVE_SETJMP_H)
337 CHECK_INCLUDE_FILE_CONCAT("signal.h" HAVE_SIGNAL_H)
338 CHECK_INCLUDE_FILE_CONCAT("sys/ioctl.h" HAVE_SYS_IOCTL_H)
339 CHECK_INCLUDE_FILE_CONCAT("sys/utsname.h" HAVE_SYS_UTSNAME_H)
340 CHECK_TYPE_SIZE(size_t SIZEOF_SIZE_T)
341 CHECK_TYPE_SIZE(ssize_t SIZEOF_SSIZE_T)
342 CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
343 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
344 CHECK_TYPE_SIZE("__int64" SIZEOF___INT64)
345 CHECK_TYPE_SIZE("long double" SIZEOF_LONG_DOUBLE)
346 IF(NOT HAVE_SIZEOF_SSIZE_T)
347 IF(SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
348 SET(ssize_t long)
349 ENDIF(SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
350 IF(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
351 SET(ssize_t __int64)
352 ENDIF(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
353 ENDIF(NOT HAVE_SIZEOF_SSIZE_T)
354
355 IF(HAVE_SIZEOF_LONG_LONG)
356 SET(HAVE_LONGLONG 1)
357 ENDIF(HAVE_SIZEOF_LONG_LONG)
358
359 FIND_FILE(RANDOM_FILE urandom /dev)
360 MARK_AS_ADVANCED(RANDOM_FILE)
361
362 # Check for some functions that are used
363 CHECK_SYMBOL_EXISTS(socket "${CURL_INCLUDES}" HAVE_SOCKET)
364 CHECK_SYMBOL_EXISTS(poll "${CURL_INCLUDES}" HAVE_POLL)
365 CHECK_SYMBOL_EXISTS(select "${CURL_INCLUDES}" HAVE_SELECT)
366 CHECK_SYMBOL_EXISTS(strdup "${CURL_INCLUDES}" HAVE_STRDUP)
367 CHECK_SYMBOL_EXISTS(strstr "${CURL_INCLUDES}" HAVE_STRSTR)
368 CHECK_SYMBOL_EXISTS(strtok_r "${CURL_INCLUDES}" HAVE_STRTOK_R)
369 CHECK_SYMBOL_EXISTS(strftime "${CURL_INCLUDES}" HAVE_STRFTIME)
370 CHECK_SYMBOL_EXISTS(uname "${CURL_INCLUDES}" HAVE_UNAME)
371 CHECK_SYMBOL_EXISTS(strcasecmp "${CURL_INCLUDES}" HAVE_STRCASECMP)
372 CHECK_SYMBOL_EXISTS(stricmp "${CURL_INCLUDES}" HAVE_STRICMP)
373 CHECK_SYMBOL_EXISTS(strcmpi "${CURL_INCLUDES}" HAVE_STRCMPI)
374 CHECK_SYMBOL_EXISTS(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI)
375 IF(NOT HAVE_STRNCMPI)
376 SET(HAVE_STRCMPI)
377 ENDIF(NOT HAVE_STRNCMPI)
378 CHECK_SYMBOL_EXISTS(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR)
379 CHECK_SYMBOL_EXISTS(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY)
380 CHECK_SYMBOL_EXISTS(inet_addr "${CURL_INCLUDES}" HAVE_INET_ADDR)
381 CHECK_SYMBOL_EXISTS(inet_pton "${CURL_INCLUDES}" HAVE_INET_PTON)
382 CHECK_SYMBOL_EXISTS(inet_ntoa "${CURL_INCLUDES}" HAVE_INET_NTOA)
383 CHECK_SYMBOL_EXISTS(inet_ntoa_r "${CURL_INCLUDES}" HAVE_INET_NTOA_R)
384 CHECK_SYMBOL_EXISTS(tcsetattr "${CURL_INCLUDES}" HAVE_TCSETATTR)
385 CHECK_SYMBOL_EXISTS(tcgetattr "${CURL_INCLUDES}" HAVE_TCGETATTR)
386 CHECK_SYMBOL_EXISTS(perror "${CURL_INCLUDES}" HAVE_PERROR)
387 CHECK_SYMBOL_EXISTS(closesocket "${CURL_INCLUDES}" HAVE_CLOSESOCKET)
388 CHECK_SYMBOL_EXISTS(setvbuf "${CURL_INCLUDES}" HAVE_SETVBUF)
389 CHECK_SYMBOL_EXISTS(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP)
390 CHECK_SYMBOL_EXISTS(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R)
391 CHECK_SYMBOL_EXISTS(strlcat "${CURL_INCLUDES}" HAVE_STRLCAT)
392 CHECK_SYMBOL_EXISTS(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID)
393 CHECK_SYMBOL_EXISTS(geteuid "${CURL_INCLUDES}" HAVE_GETEUID)
394 CHECK_SYMBOL_EXISTS(utime "${CURL_INCLUDES}" HAVE_UTIME)
395 IF(CMAKE_USE_OPENSSL)
396 CHECK_SYMBOL_EXISTS(RAND_status "${CURL_INCLUDES}" HAVE_RAND_STATUS)
397 CHECK_SYMBOL_EXISTS(RAND_screen "${CURL_INCLUDES}" HAVE_RAND_SCREEN)
398 CHECK_SYMBOL_EXISTS(RAND_egd "${CURL_INCLUDES}" HAVE_RAND_EGD)
399 CHECK_SYMBOL_EXISTS(CRYPTO_cleanup_all_ex_data "${CURL_INCLUDES}"
400 HAVE_CRYPTO_CLEANUP_ALL_EX_DATA)
401 ENDIF(CMAKE_USE_OPENSSL)
402 CHECK_SYMBOL_EXISTS(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R)
403 CHECK_SYMBOL_EXISTS(localtime_r "${CURL_INCLUDES}" HAVE_LOCALTIME_R)
404
405 CHECK_SYMBOL_EXISTS(gethostbyname "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME)
406 CHECK_SYMBOL_EXISTS(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R)
407 CHECK_SYMBOL_EXISTS(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R)
408
409 CHECK_SYMBOL_EXISTS(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC)
410 CHECK_SYMBOL_EXISTS(SIGALRM "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO)
411 IF(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
412 SET(HAVE_SIGNAL 1)
413 ENDIF(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
414 CHECK_SYMBOL_EXISTS(uname "${CURL_INCLUDES}" HAVE_UNAME)
415 CHECK_SYMBOL_EXISTS(strtoll "${CURL_INCLUDES}" HAVE_STRTOLL)
416 CHECK_SYMBOL_EXISTS(_strtoi64 "${CURL_INCLUDES}" HAVE__STRTOI64)
417 CHECK_SYMBOL_EXISTS(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R)
418 CHECK_SYMBOL_EXISTS(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT)
419 CHECK_SYMBOL_EXISTS(perror "${CURL_INCLUDES}" HAVE_PERROR)
420
421 # only build compat strtok if we need to
422 IF (NOT HAVE_STRTOK_R)
423 SET(libCurl_SRCS ${libCurl_SRCS}
424 strtok.c
425 )
426 ENDIF (NOT HAVE_STRTOK_R)
427 IF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64)
428 SET(libCurl_SRCS ${libCurl_SRCS}
429 strtoofft.c
430 )
431 ENDIF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64)
432
433 # sigaction and sigsetjmp are special. Use special mechanism for
434 # detecting those, but only if previous attempt failed.
435 IF(HAVE_SIGNAL_H)
436 CHECK_SYMBOL_EXISTS(sigaction "signal.h" HAVE_SIGACTION)
437 ENDIF(HAVE_SIGNAL_H)
438
439 IF(NOT HAVE_SIGSETJMP)
440 IF(HAVE_SETJMP_H)
441 CHECK_SYMBOL_EXISTS(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP)
442 IF(HAVE_MACRO_SIGSETJMP)
443 SET(HAVE_SIGSETJMP 1)
444 ENDIF(HAVE_MACRO_SIGSETJMP)
445 ENDIF(HAVE_SETJMP_H)
446 ENDIF(NOT HAVE_SIGSETJMP)
447
448 # For other curl specific tests, use this macro.
449 MACRO(CURL_INTERNAL_TEST CURL_TEST)
450 IF("${CURL_TEST}" MATCHES "^${CURL_TEST}$")
451 SET(MACRO_CHECK_FUNCTION_DEFINITIONS
452 "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}")
453 IF(CMAKE_REQUIRED_LIBRARIES)
454 SET(CURL_TEST_ADD_LIBRARIES
455 "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
456 ENDIF(CMAKE_REQUIRED_LIBRARIES)
457
458 MESSAGE(STATUS "Performing Curl Test ${CURL_TEST}")
459 TRY_COMPILE(${CURL_TEST}
460 ${CMAKE_BINARY_DIR}
461 ${SLICERLIBCURL_SOURCE_DIR}/CMake/CurlTests.c
462 CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
463 "${CURL_TEST_ADD_LIBRARIES}"
464 OUTPUT_VARIABLE OUTPUT)
465 IF(${CURL_TEST})
466 SET(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
467 MESSAGE(STATUS "Performing Curl Test ${CURL_TEST} - Success")
468 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
469 "Performing Curl Test ${CURL_TEST} passed with the following output:\n"
470 "${OUTPUT}\n")
471 ELSE(${CURL_TEST})
472 MESSAGE(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
473 SET(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
474 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
475 "Performing Curl Test ${CURL_TEST} failed with the following output:\n"
476 "${OUTPUT}\n")
477 ENDIF(${CURL_TEST})
478 ENDIF("${CURL_TEST}" MATCHES "^${CURL_TEST}$")
479 ENDMACRO(CURL_INTERNAL_TEST)
480 MACRO(CURL_INTERNAL_TEST_RUN CURL_TEST)
481 IF("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$")
482 SET(MACRO_CHECK_FUNCTION_DEFINITIONS
483 "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}")
484 IF(CMAKE_REQUIRED_LIBRARIES)
485 SET(CURL_TEST_ADD_LIBRARIES
486 "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
487 ENDIF(CMAKE_REQUIRED_LIBRARIES)
488
489 MESSAGE(STATUS "Performing Curl Test ${CURL_TEST}")
490 TRY_RUN(${CURL_TEST} ${CURL_TEST}_COMPILE
491 ${CMAKE_BINARY_DIR}
492 ${SLICERLIBCURL_SOURCE_DIR}/CMake/CurlTests.c
493 CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
494 "${CURL_TEST_ADD_LIBRARIES}"
495 OUTPUT_VARIABLE OUTPUT)
496 IF(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
497 SET(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
498 MESSAGE(STATUS "Performing Curl Test ${CURL_TEST} - Success")
499 ELSE(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
500 MESSAGE(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
501 SET(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
502 FILE(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
503 "Performing Curl Test ${CURL_TEST} failed with the following output:\n"
504 "${OUTPUT}")
505 IF(${CURL_TEST}_COMPILE)
506 FILE(APPEND
507 "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
508 "There was a running problem of this test\n")
509 ENDIF(${CURL_TEST}_COMPILE)
510 FILE(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
511 "\n\n")
512 ENDIF(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
513 ENDIF("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$")
514 ENDMACRO(CURL_INTERNAL_TEST_RUN)
515
516 # Do curl specific tests
517 #OPTION(CURL_HAVE_DISABLED_NONBLOCKING "Disable non-blocking socket detection" OFF)
518 SET(CURL_NONBLOCKING_TESTS)
519 IF(NOT CURL_HAVE_DISABLED_NONBLOCKING)
520 SET(CURL_NONBLOCKING_TESTS
521 HAVE_FIONBIO
522 HAVE_IOCTLSOCKET
523 HAVE_IOCTLSOCKET_CASE
524 HAVE_O_NONBLOCK
525 HAVE_SO_NONBLOCK
526 )
527 ENDIF(NOT CURL_HAVE_DISABLED_NONBLOCKING)
528 FOREACH(CURL_TEST
529 ${CURL_NONBLOCKING_TESTS}
530 TIME_WITH_SYS_TIME
531 HAVE_O_NONBLOCKHAVE_GETHOSTBYADDR_R_5
532 HAVE_GETHOSTBYADDR_R_7
533 HAVE_GETHOSTBYADDR_R_8
534 HAVE_GETHOSTBYADDR_R_5_REENTRANT
535 HAVE_GETHOSTBYADDR_R_7_REENTRANT
536 HAVE_GETHOSTBYADDR_R_8_REENTRANT
537 HAVE_GETHOSTBYNAME_R_3
538 HAVE_GETHOSTBYNAME_R_5
539 HAVE_GETHOSTBYNAME_R_6
540 HAVE_GETHOSTBYNAME_R_3_REENTRANT
541 HAVE_GETHOSTBYNAME_R_5_REENTRANT
542 HAVE_GETHOSTBYNAME_R_6_REENTRANT
543 HAVE_SOCKLEN_T
544 HAVE_IN_ADDR_T
545 STDC_HEADERS
546 RETSIGTYPE_TEST
547 HAVE_INET_NTOA_R_DECL
548 HAVE_INET_NTOA_R_DECL_REENTRANT
549 HAVE_GETADDRINFO
550 HAVE_FILE_OFFSET_BITS
551 )
552 CURL_INTERNAL_TEST(${CURL_TEST})
553 ENDFOREACH(CURL_TEST)
554 IF(HAVE_FILE_OFFSET_BITS)
555 SET(_FILE_OFFSET_BITS 64)
556 ENDIF(HAVE_FILE_OFFSET_BITS)
557
558 FOREACH(CURL_TEST
559 HAVE_GLIBC_STRERROR_R
560 HAVE_POSIX_STRERROR_R
561 HAVE_LONG_LONG_CONSTANT
562 )
563 CURL_INTERNAL_TEST_RUN(${CURL_TEST})
564 ENDFOREACH(CURL_TEST)
565
566 # Check for reentrant
567 FOREACH(CURL_TEST
568 HAVE_GETHOSTBYADDR_R_5
569 HAVE_GETHOSTBYADDR_R_7
570 HAVE_GETHOSTBYADDR_R_8
571 HAVE_GETHOSTBYNAME_R_3
572 HAVE_GETHOSTBYNAME_R_5
573 HAVE_GETHOSTBYNAME_R_6
574 HAVE_INET_NTOA_R_DECL_REENTRANT)
575 IF(NOT ${CURL_TEST})
576 IF(${CURL_TEST}_REENTRANT)
577 SET(NEED_REENTRANT 1)
578 ENDIF(${CURL_TEST}_REENTRANT)
579 ENDIF(NOT ${CURL_TEST})
580 ENDFOREACH(CURL_TEST)
581
582 IF(NEED_REENTRANT)
583 FOREACH(CURL_TEST
584 HAVE_GETHOSTBYADDR_R_5
585 HAVE_GETHOSTBYADDR_R_7
586 HAVE_GETHOSTBYADDR_R_8
587 HAVE_GETHOSTBYNAME_R_3
588 HAVE_GETHOSTBYNAME_R_5
589 HAVE_GETHOSTBYNAME_R_6)
590 SET(${CURL_TEST} 0)
591 IF(${CURL_TEST}_REENTRANT)
592 SET(${CURL_TEST} 1)
593 ENDIF(${CURL_TEST}_REENTRANT)
594 ENDFOREACH(CURL_TEST)
595 ENDIF(NEED_REENTRANT)
596
597 IF(HAVE_INET_NTOA_R_DECL_REENTRANT)
598 SET(HAVE_INET_NTOA_R_DECL 1)
599 SET(NEED_REENTRANT 1)
600 ENDIF(HAVE_INET_NTOA_R_DECL_REENTRANT)
601
602 # Some other minor tests
603
604 IF(NOT HAVE_SOCKLEN_T)
605 SET(socklen_t "int")
606 ENDIF(NOT HAVE_SOCKLEN_T)
607
608 IF(NOT HAVE_IN_ADDR_T)
609 SET(in_addr_t "unsigned long")
610 ENDIF(NOT HAVE_IN_ADDR_T)
611
612 # Fix libz / zlib.h
613
614 IF(NOT CURL_SPECIAL_LIBZ)
615 IF(NOT HAVE_LIBZ)
616 SET(HAVE_ZLIB_H 0)
617 ENDIF(NOT HAVE_LIBZ)
618
619 IF(NOT HAVE_ZLIB_H)
620 SET(HAVE_LIBZ 0)
621 ENDIF(NOT HAVE_ZLIB_H)
622 ENDIF(NOT CURL_SPECIAL_LIBZ)
623
624 IF(_FILE_OFFSET_BITS)
625 SET(_FILE_OFFSET_BITS 64)
626 ENDIF(_FILE_OFFSET_BITS)
627 SET(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64")
628 SET(CMAKE_EXTRA_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/slicerlibcurl/slicerlibcurl.h")
629 CHECK_TYPE_SIZE("curl_off_t" SIZEOF_CURL_OFF_T)
630 SET(CMAKE_EXTRA_INCLUDE_FILES)
631 SET(CMAKE_REQUIRED_FLAGS)
632
633
634 # Check for nonblocking
635 SET(HAVE_DISABLED_NONBLOCKING 1)
636 IF(HAVE_FIONBIO OR
637 HAVE_IOCTLSOCKET OR
638 HAVE_IOCTLSOCKET_CASE OR
639 HAVE_O_NONBLOCK)
640 SET(HAVE_DISABLED_NONBLOCKING)
641 ENDIF(HAVE_FIONBIO OR
642 HAVE_IOCTLSOCKET OR
643 HAVE_IOCTLSOCKET_CASE OR
644 HAVE_O_NONBLOCK)
645
646 IF(RETSIGTYPE_TEST)
647 SET(RETSIGTYPE void)
648 ELSE(RETSIGTYPE_TEST)
649 SET(RETSIGTYPE int)
650 ENDIF(RETSIGTYPE_TEST)
651
652 IF(CMAKE_COMPILER_IS_GNUCC AND APPLE)
653 # -no-cpp-precomp and -Wno-long-double were compiler flags present
654 # only in Apple's gcc and not in the FSF gcc. The flags are obsolete
655 # and totally removed in gcc 4.2 and later. I believe they are only
656 # needed with gcc 3.3 and earlier.
657
658 # The Mac version of GCC warns about use of long double. Disable it.
659 curlCHECK_C_ACCEPTS_FLAGS("-Wno-long-double" C_HAS_LONGDOUBLE_FLAG)
660 IF(C_HAS_LONGDOUBLE_FLAG)
661 GET_SOURCE_FILE_PROPERTY(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS)
662 IF(MPRINTF_COMPILE_FLAGS)
663 SET(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double")
664 ELSE(MPRINTF_COMPILE_FLAGS)
665 SET(MPRINTF_COMPILE_FLAGS "-Wno-long-double")
666 ENDIF(MPRINTF_COMPILE_FLAGS)
667 SET_SOURCE_FILES_PROPERTIES(mprintf.c PROPERTIES COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS})
668 ENDIF(C_HAS_LONGDOUBLE_FLAG)
669 ENDIF(CMAKE_COMPILER_IS_GNUCC AND APPLE)
670
671 # The rest of the build
672
673 INCLUDE_DIRECTORIES(${SLICERLIBCURL_SOURCE_DIR})
674 INCLUDE_DIRECTORIES(${SLICERLIBCURL_SOURCE_DIR}/slicerlibcurl)
675 INCLUDE_DIRECTORIES(${SLICERLIBCURL_BINARY_DIR})
676 ADD_DEFINITIONS(-DSLICERLIBCURL_HAVE_CONFIG_H)
677 CONFIGURE_FILE(${SLICERLIBCURL_SOURCE_DIR}/config.h.in
678 ${SLICERLIBCURL_BINARY_DIR}/SLICERLIBCURLConfig.h)
679
680 IF (CMAKE_SYSTEM_NAME MATCHES SunOS)
681 ADD_LIBRARY(slicerlibcurl ${libCurl_SRCS})
682 ELSE (CMAKE_SYSTEM_NAME MATCHES SunOS)
683 ADD_LIBRARY(slicerlibcurl STATIC ${libCurl_SRCS})
684 ENDIF (CMAKE_SYSTEM_NAME MATCHES SunOS)
685
686 TARGET_LINK_LIBRARIES(slicerlibcurl ${CURL_LIBS})
687 IF(APPLE)
688 SET_TARGET_PROPERTIES(slicerlibcurl PROPERTIES COMPILE_FLAGS -fno-common)
689 ENDIF(APPLE)
690 IF(CMAKE_SYSTEM_NAME MATCHES Linux)
691 IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
692 SET_TARGET_PROPERTIES(slicerlibcurl PROPERTIES COMPILE_FLAGS -fPIC)
693 ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
694 ENDIF(CMAKE_SYSTEM_NAME MATCHES Linux)
695
696 OPTION(SLICERLIBCURL_TESTING "Do libCurl testing" OFF)
697 IF(SLICERLIBCURL_TESTING)
698 SUBDIRS(Testing)
699
700 ADD_EXECUTABLE(slicerlibcurlTest Testing/curltest.c)
701 TARGET_LINK_LIBRARIES(slicerlibcurlTest slicerlibcurl ${CMAKE_DL_LIBS})
702 ADD_TEST(slicerlibcurlTest "${EXECUTABLE_OUTPUT_PATH}/slicerlibcurlTest")
703 ENDIF(SLICERLIBCURL_TESTING)
704
705
706 #-----------------------------------------------------------------------------
707 # CMakeLists.txt custom to using SLICERLIBCURL as an external project
708
709 #INCLUDE(${CMAKE_ROOT}/Modules/CMakeExportBuildSettings.cmake)
710 #CMAKE_EXPORT_BUILD_SETTINGS(${SLICERLIBCURL_BINARY_DIR}/LIBCURLBuildSettings.cmake)
711
712 #EXPORT_LIBRARY_DEPENDENCIES(
713 #${SLICERLIBCURL_BINARY_DIR}/LIBCURLLibraryDepends.cmake)
714
715 #SET(SLICERLIBCURL_BUILD_SETTINGS_FILE_CONFIG
716 #${SLICERLIBCURL_BINARY_DIR}/LIBCURLBuildSettings.cmake)
717
718 #SET(SLICERLIBCURL_LIBRARY_DEPENDS_FILE
719 #${SLICERLIBCURL_BINARY_DIR}/LIBCURLLibraryDepends.cmake)
720
721 SET(SLICERLIBCURL_CONFIG_INSTALL_ONLY)
722
723 SET(SLICERLIBCURL_USE_FILE_CONFIG ${SLICERLIBCURL_SOURCE_DIR}/CMake/UseSLICERLIBCURL.cmake)
724
725 # The library directories.
726 SET(SLICERLIBCURL_LIBRARY_DIRS_CONFIG ${SLICERLIBCURL_LIBRARY_DIR})
727
728 # The runtime directories.
729 SET(SLICERLIBCURL_RUNTIME_DIRS_CONFIG ${SLICERLIBCURL_RUNTIME_DIR})
730
731 # The include directories.
732 SET(SLICERLIBCURL_INCLUDE_DIRS_CONFIG ${SLICERLIBCURL_INCLUDE_PATH})
733
734 SET(SLICERLIBCURL_LIBRARIES_CONFIG ${SLICERLIBCURL_LIBRARIES} ${CURL_LIBS})
735
736 # The build configuration information.
737 SET(SLICERLIBCURL_CONFIGURATION_TYPES_CONFIG ${CMAKE_CONFIGURATION_TYPES})
738
739 SET(SLICERLIBCURL_BUILD_TYPE_CONFIG ${CMAKE_BUILD_TYPE})
740
741 # Configure SLICERLIBCURLConfig.cmake for the build tree.
742 CONFIGURE_FILE(
743 ${SLICERLIBCURL_SOURCE_DIR}/CMake/SLICERLIBCURLConfig.cmake.in
744 ${SLICERLIBCURL_BINARY_DIR}/SLICERLIBCURLConfig.cmake @ONLY IMMEDIATE
745 )
746

  Subversion  TortoiseSVN  ViewVC