Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Utilities / cmcurl / CMakeLists.txt
bloba04b08cdfd32e0fa87619f2f446533091d735644
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
2 IF(COMMAND CMAKE_POLICY)
3   CMAKE_POLICY(SET CMP0003 NEW)
4 ENDIF(COMMAND CMAKE_POLICY)
5 PROJECT(LIBCURL C)
7 INCLUDE_REGULAR_EXPRESSION("^.*$")
9 # Setup package meta-data
10 SET(PACKAGE "curl")
11 SET(VERSION "7.16.1")
12 SET(PACKAGE_TARNAME "curl")
13 SET(PACKAGE_BUGREPORT " ")
14 SET(PACKAGE_NAME "curl")
15 SET(PACKAGE_VERSION "-")
16 SET(PACKAGE_STRING "curl-")
17 SET(PACKAGE_BUGREPORT "a suitable curl mailing list => http://curl.haxx.se/mail/")
18 SET(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}")
20 # We need ansi c-flags, especially on HP
21 SET(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
22 SET(CMAKE_REQUIRED_FLAGS ${CMAKE_ANSI_CFLAGS})
24 # Disable warnings on Borland to avoid changing 3rd party code.
25 IF(BORLAND)
26   SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")
27 ENDIF(BORLAND)
29 # If we are on AIX, do the _ALL_SOURCE magic
30 IF(${CMAKE_SYSTEM_NAME} MATCHES AIX)
31   SET(_ALL_SOURCE 1)
32 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES AIX)
34 # Include all the necessary files for macros
35 SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
36 INCLUDE (CheckFunctionExists)
37 INCLUDE (CheckIncludeFile)
38 INCLUDE (CheckIncludeFiles)
39 INCLUDE (CheckLibraryExists)
40 INCLUDE (CheckSymbolExists)
41 # if crosscompiling is on, the CHECK_TYPE_SIZE macro coming with cmake uses
42 # TRY_COMPILE instead of TRY_RUN which makes crosscompiling easier, Alex
43 IF(CMAKE_CROSSCOMPILING)  
44   INCLUDE ("${CMAKE_ROOT}/Modules/CheckTypeSize.cmake")
45 ELSE(CMAKE_CROSSCOMPILING)
46   INCLUDE (CheckTypeSize)
47 ENDIF(CMAKE_CROSSCOMPILING)
49 SET(libCurl_SRCS
50   #  amigaos.c - does not build on AmigaOS
51   base64.c
52   connect.c
53   content_encoding.c
54   cookie.c
55   dict.c
56   easy.c
57   escape.c
58   file.c
59   formdata.c
60   ftp.c
61   getenv.c
62   getinfo.c
63   gtls.c
64   hash.c
65   hostares.c
66   hostasyn.c
67   hostip4.c
68   hostip6.c
69   hostip.c
70   hostsyn.c
71   hostthre.c
72   http.c
73   http_chunks.c
74   http_digest.c
75   http_negotiate.c
76   http_ntlm.c
77   if2ip.c
78   inet_ntop.c
79   inet_pton.c
80   krb4.c
81   ldap.c
82   llist.c
83   md5.c
84 #  memdebug.c -not used
85   mprintf.c
86   multi.c
87   netrc.c
88   # nwlib.c - Not used
89   parsedate.c
90   progress.c
91   security.c
92   select.c
93   sendf.c
94   share.c
95   socks.c
96   speedcheck.c
97   splay.c
98   ssh.c
99   sslgen.c
100   ssluse.c
101   strdup.c
102   strequal.c
103   strerror.c
104   # strtok.c - specify later
105   # strtoofft.c - specify later
106   telnet.c
107   tftp.c
108   timeval.c
109   transfer.c
110   url.c
111   version.c
112   )
114 SET(CURL_DISABLE_LDAP 1)
115 IF(NOT CURL_DISABLE_LDAP)
116   SET(libCurl_SRCS
117     ${libCurl_SRCS}
118     ldap.c
119     )
120 ENDIF(NOT CURL_DISABLE_LDAP)
122 # if we have Kerberos 4, right now this is never on
123 #OPTION(CURL_KRB4 "Use Kerberos 4" OFF)
124 IF(CURL_KRB4)
125   SET(libCurl_SRCS ${libCurl_SRCS}
126     krb4.c
127     security.c
128     )
129 ENDIF(CURL_KRB4)
131 #OPTION(CURL_MALLOC_DEBUG "Debug mallocs in Curl" OFF)
132 MARK_AS_ADVANCED(CURL_MALLOC_DEBUG)
133 IF(CURL_MALLOC_DEBUG)
134   SET(libCurl_SRCS ${libCurl_SRCS}
135     memdebug.c
136     )
137 ENDIF(CURL_MALLOC_DEBUG)
139 # On windows preload settings
140 IF(WIN32)
141   INCLUDE(${LIBCURL_SOURCE_DIR}/Platforms/WindowsCache.cmake)
142 ENDIF(WIN32)
144 # This macro checks if the symbol exists in the library and if it
145 # does, it appends library to the list.
146 SET(CURL_LIBS "")
147 MACRO(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE)
148   CHECK_LIBRARY_EXISTS("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "" 
149     ${VARIABLE})
150   IF(${VARIABLE})
151     SET(CURL_LIBS ${CURL_LIBS} ${LIBRARY})
152   ENDIF(${VARIABLE})
153 ENDMACRO(CHECK_LIBRARY_EXISTS_CONCAT)
155 # Check for all needed libraries
156 # use the cmake defined dl libs as dl is should not be used
157 # on HPUX, but rather dld this avoids a warning
158 SET(CURL_LIBS ${CURL_LIBS} ${CMAKE_DL_LIBS})
159 #CHECK_LIBRARY_EXISTS_CONCAT("dl"     dlopen       HAVE_LIBDL)
160 #CHECK_LIBRARY_EXISTS_CONCAT("ucb"    gethostname  HAVE_LIBUCB)
161 CHECK_LIBRARY_EXISTS_CONCAT("socket" connect      HAVE_LIBSOCKET)
162 CHECK_LIBRARY_EXISTS("c" gethostbyname "" NOT_NEED_LIBNSL)
164 # Yellowtab Zeta needs different libraries than BeOS 5.
165 IF(BEOS)
166   SET(NOT_NEED_LIBNSL 1)
167   CHECK_LIBRARY_EXISTS_CONCAT("bind" gethostbyname HAVE_LIBBIND)
168   CHECK_LIBRARY_EXISTS_CONCAT("bnetapi" closesocket HAVE_LIBBNETAPI)
169 ENDIF(BEOS)
171 CHECK_LIBRARY_EXISTS_CONCAT("network" recv HAVE_LIBNETWORK)
173 IF(NOT NOT_NEED_LIBNSL)
174   CHECK_LIBRARY_EXISTS_CONCAT("nsl"    gethostbyname  HAVE_LIBNSL)
175 ENDIF(NOT NOT_NEED_LIBNSL)
177 CHECK_LIBRARY_EXISTS_CONCAT("ws2_32" getch        HAVE_LIBWS2_32)
178 CHECK_LIBRARY_EXISTS_CONCAT("winmm"  getch        HAVE_LIBWINMM)
179 IF(NOT CURL_SPECIAL_LIBZ)
180   CHECK_LIBRARY_EXISTS_CONCAT("z"      inflateEnd   HAVE_LIBZ)
181 ENDIF(NOT CURL_SPECIAL_LIBZ)
183 OPTION(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON)
184 MARK_AS_ADVANCED(CMAKE_USE_OPENSSL)
185 IF(CMAKE_USE_OPENSSL)
186   CHECK_LIBRARY_EXISTS_CONCAT("crypto" CRYPTO_lock  HAVE_LIBCRYPTO)
187   CHECK_LIBRARY_EXISTS_CONCAT("ssl"    SSL_connect  HAVE_LIBSSL)
188 ENDIF(CMAKE_USE_OPENSSL)
190 # Check for idn
191 CHECK_LIBRARY_EXISTS_CONCAT("idn" idna_to_ascii_lz HAVE_LIBIDN)
193 # Check for symbol dlopen (same as HAVE_LIBDL)
194 CHECK_LIBRARY_EXISTS("${CURL_LIBS}" dlopen "" HAVE_DLOPEN)
196 # For other tests to use the same libraries
197 SET(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBS})
199 IF(CURL_SPECIAL_LIBZ)
200   SET(CURL_LIBS ${CURL_LIBS} "${CURL_SPECIAL_LIBZ}")
201   INCLUDE_DIRECTORIES(${CURL_SPECIAL_LIBZ_INCLUDES})
202   SET(HAVE_LIBZ 0)
203   SET(HAVE_ZLIB_H 0)
204 ENDIF(CURL_SPECIAL_LIBZ)
206 # do we have process.h
207 CHECK_INCLUDE_FILE("process.h" HAVE_PROCESS_H)
209 # If we have features.h, then do the _BSD_SOURCE magic
210 CHECK_INCLUDE_FILE("features.h"       HAVE_FEATURES_H)
211 IF(HAVE_FEATURES_H)
212   SET_SOURCE_FILES_PROPERTIES(
213     cookie.c
214     easy.c
215     formdata.c
216     getenv.c
217     hash.c
218     http.c
219     if2ip.c 
220     mprintf.c
221     multi.c
222     sendf.c
223     telnet.c
224     transfer.c
225     url.c
226     COMPILE_FLAGS -D_BSD_SOURCE)
227 ENDIF(HAVE_FEATURES_H)
229 # Check if header file exists and add it to the list.
230 MACRO(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE)
231   CHECK_INCLUDE_FILES("${CURL_INCLUDES};${FILE}" ${VARIABLE})
232   IF(${VARIABLE})
233     SET(CURL_INCLUDES ${CURL_INCLUDES} ${FILE})
234   ENDIF(${VARIABLE})
235 ENDMACRO(CHECK_INCLUDE_FILE_CONCAT)
237 # Check for header files
238 IF(NOT UNIX)
239   CHECK_INCLUDE_FILE_CONCAT("ws2tcpip.h"     HAVE_WS2TCPIP_H)
240   CHECK_INCLUDE_FILE_CONCAT("winsock2.h"     HAVE_WINSOCK2_H)
241 ENDIF(NOT UNIX)
242 CHECK_INCLUDE_FILE_CONCAT("stdio.h"          HAVE_STDIO_H)
243 IF(NOT UNIX)
244   CHECK_INCLUDE_FILE_CONCAT("windows.h"      HAVE_WINDOWS_H)
245   CHECK_INCLUDE_FILE_CONCAT("winsock.h"      HAVE_WINSOCK_H)
246 ENDIF(NOT UNIX)
247 CHECK_INCLUDE_FILE_CONCAT("stddef.h"         HAVE_STDDEF_H)
248 CHECK_INCLUDE_FILE_CONCAT("sys/types.h"      HAVE_SYS_TYPES_H)
249 CHECK_INCLUDE_FILE_CONCAT("inttypes.h"       HAVE_INTTYPES_H)
250 CHECK_INCLUDE_FILE_CONCAT("alloca.h"         HAVE_ALLOCA_H)
251 CHECK_INCLUDE_FILE_CONCAT("arpa/inet.h"      HAVE_ARPA_INET_H)
252 CHECK_INCLUDE_FILE_CONCAT("dlfcn.h"          HAVE_DLFCN_H)
253 CHECK_INCLUDE_FILE_CONCAT("fcntl.h"          HAVE_FCNTL_H)
254 CHECK_INCLUDE_FILE_CONCAT("malloc.h"         HAVE_MALLOC_H)
255 CHECK_INCLUDE_FILE_CONCAT("memory.h"         HAVE_MEMORY_H)
256 CHECK_INCLUDE_FILE_CONCAT("netdb.h"          HAVE_NETDB_H)
257 CHECK_INCLUDE_FILE_CONCAT("sys/poll.h"       HAVE_SYS_POLL_H)
258 CHECK_INCLUDE_FILE_CONCAT("assert.h"         HAVE_ASSERT_H)
259 CHECK_INCLUDE_FILE_CONCAT("limits.h"         HAVE_LIMITS_H)
261 IF(CMAKE_USE_OPENSSL)
262   CHECK_INCLUDE_FILE_CONCAT("openssl/x509.h"   HAVE_OPENSSL_X509_H)
263   CHECK_INCLUDE_FILE_CONCAT("openssl/engine.h" HAVE_OPENSSL_ENGINE_H)
264   CHECK_INCLUDE_FILE_CONCAT("openssl/rsa.h"    HAVE_OPENSSL_RSA_H)
265   CHECK_INCLUDE_FILE_CONCAT("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H)
266   CHECK_INCLUDE_FILE_CONCAT("openssl/pem.h"    HAVE_OPENSSL_PEM_H)
267   CHECK_INCLUDE_FILE_CONCAT("openssl/ssl.h"    HAVE_OPENSSL_SSL_H)
268   CHECK_INCLUDE_FILE_CONCAT("openssl/err.h"    HAVE_OPENSSL_ERR_H)
269   CHECK_INCLUDE_FILE_CONCAT("openssl/rand.h"   HAVE_OPENSSL_RAND_H)
270   CHECK_INCLUDE_FILE_CONCAT("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H)
271 ENDIF(CMAKE_USE_OPENSSL)
273 IF(NOT CURL_SPECIAL_LIBZ)
274   CHECK_INCLUDE_FILE_CONCAT("zlib.h"           HAVE_ZLIB_H)
275 ENDIF(NOT CURL_SPECIAL_LIBZ)
276 CHECK_INCLUDE_FILE_CONCAT("sys/socket.h"     HAVE_SYS_SOCKET_H)
277 CHECK_INCLUDE_FILE_CONCAT("netinet/in.h"     HAVE_NETINET_IN_H)
278 CHECK_INCLUDE_FILE_CONCAT("net/if.h"         HAVE_NET_IF_H)
279 CHECK_INCLUDE_FILE_CONCAT("netinet/if_ether.h" 
280   HAVE_NETINET_IF_ETHER_H)
281 CHECK_INCLUDE_FILE_CONCAT("netinet/tcp.h" 
282   HAVE_NETINET_TCP_H)
283 CHECK_INCLUDE_FILE_CONCAT("sys/select.h"    HAVE_SYS_SELECT_H)
284 CHECK_INCLUDE_FILE_CONCAT("utime.h"         HAVE_UTIME_H)
285 CHECK_INCLUDE_FILE_CONCAT("netinet/in.h"    HAVE_NETINET_IN_H)
286 CHECK_INCLUDE_FILE_CONCAT("pwd.h"           HAVE_PWD_H)
287 CHECK_INCLUDE_FILE_CONCAT("sgtty.h"         HAVE_SGTTY_H)
288 CHECK_INCLUDE_FILE_CONCAT("stdint.h"        HAVE_STDINT_H)
289 CHECK_INCLUDE_FILE_CONCAT("stdlib.h"        HAVE_STDLIB_H)
290 CHECK_INCLUDE_FILE_CONCAT("string.h"        HAVE_STRING_H)
291 CHECK_INCLUDE_FILE_CONCAT("strings.h"       HAVE_STRINGS_H)
292 CHECK_INCLUDE_FILE_CONCAT("sys/param.h"     HAVE_SYS_PARAM_H)
293 CHECK_INCLUDE_FILE_CONCAT("sys/stat.h"      HAVE_SYS_STAT_H)
294 CHECK_INCLUDE_FILE_CONCAT("sys/time.h"      HAVE_SYS_TIME_H)
295 CHECK_INCLUDE_FILE_CONCAT("sys/resource.h"  HAVE_SYS_RESOURCE_H)
296 CHECK_INCLUDE_FILE_CONCAT("termios.h"       HAVE_TERMIOS_H)
297 CHECK_INCLUDE_FILE_CONCAT("termio.h"        HAVE_TERMIO_H)
298 CHECK_INCLUDE_FILE_CONCAT("io.h"            HAVE_IO_H)
299 CHECK_INCLUDE_FILE_CONCAT("time.h"          HAVE_TIME_H)
300 CHECK_INCLUDE_FILE_CONCAT("unistd.h"        HAVE_UNISTD_H)
301 CHECK_INCLUDE_FILE_CONCAT("sys/utime.h"     HAVE_SYS_UTIME_H)
302 CHECK_INCLUDE_FILE_CONCAT("sockio.h"        HAVE_SOCKIO_H)
303 CHECK_INCLUDE_FILE_CONCAT("sys/sockio.h"    HAVE_SYS_SOCKIO_H)
304 CHECK_INCLUDE_FILE_CONCAT("x509.h"          HAVE_X509_H)
305 CHECK_INCLUDE_FILE_CONCAT("locale.h"        HAVE_LOCALE_H)
306 CHECK_INCLUDE_FILE_CONCAT("setjmp.h"        HAVE_SETJMP_H)
307 CHECK_INCLUDE_FILE_CONCAT("signal.h"        HAVE_SIGNAL_H)
308 CHECK_INCLUDE_FILE_CONCAT("sys/ioctl.h"     HAVE_SYS_IOCTL_H)
309 CHECK_INCLUDE_FILE_CONCAT("sys/utsname.h"   HAVE_SYS_UTSNAME_H)
310 CHECK_INCLUDE_FILE_CONCAT("idn-free.h"      HAVE_IDN_FREE_H)
311 CHECK_INCLUDE_FILE_CONCAT("idna.h"          HAVE_IDNA_H)
312 CHECK_INCLUDE_FILE_CONCAT("tld.h"           HAVE_TLD_H)
313 CHECK_INCLUDE_FILE_CONCAT("arpa/tftp.h"     HAVE_ARPA_TFTP_H)
314 CHECK_INCLUDE_FILE_CONCAT("errno.h"         HAVE_ERRNO_H)
315 CHECK_INCLUDE_FILE_CONCAT("libgen.h"        HAVE_LIBGEN_H)
316 CHECK_INCLUDE_FILE_CONCAT("sys/filio.h"     HAVE_SYS_FILIO_H)
317 CHECK_TYPE_SIZE(size_t  SIZEOF_SIZE_T)
318 CHECK_TYPE_SIZE(ssize_t  SIZEOF_SSIZE_T)
319 CHECK_TYPE_SIZE("long long"  SIZEOF_LONG_LONG)
320 CHECK_TYPE_SIZE("long"  SIZEOF_LONG)
321 CHECK_TYPE_SIZE("__int64"  SIZEOF___INT64)
322 CHECK_TYPE_SIZE("long double"  SIZEOF_LONG_DOUBLE)
323 CHECK_TYPE_SIZE("time_t"  SIZEOF_TIME_T)
324 IF(NOT HAVE_SIZEOF_SSIZE_T)
325   IF(SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
326     SET(ssize_t long)
327   ENDIF(SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
328   IF(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
329     SET(ssize_t __int64)
330   ENDIF(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
331 ENDIF(NOT HAVE_SIZEOF_SSIZE_T)
333 IF(HAVE_SIZEOF_LONG_LONG)
334   SET(HAVE_LONGLONG 1)
335   SET(HAVE_LL 1)
336 ENDIF(HAVE_SIZEOF_LONG_LONG)
338 FIND_FILE(RANDOM_FILE urandom /dev)
339 MARK_AS_ADVANCED(RANDOM_FILE)
341 #strtoll \
342 #socket \
343 #select \
344 #strdup \
345 #strstr \
346 #strtok_r \
347 #uname \
348 #strcasecmp \
349 #stricmp \
350 #strcmpi \
351 #gethostbyaddr \
352 #gettimeofday \
353 #inet_addr \
354 #inet_ntoa \
355 #inet_pton \
356 #perror \
357 #closesocket \
358 #siginterrupt \
359 #sigaction \
360 #signal \
361 #getpass_r \
362 #strlcat \
363 #getpwuid \
364 #geteuid \
365 #dlopen \
366 #utime \
367 #sigsetjmp \
368 #basename \
369 #setlocale \
370 #ftruncate \
371 #pipe \
372 #poll \
373 #getprotobyname \
374 #getrlimit \
375 #setrlimit \
376 #fork
378 # Check for some functions that are used
379 CHECK_SYMBOL_EXISTS(basename      "${CURL_INCLUDES}" HAVE_BASENAME)
380 CHECK_SYMBOL_EXISTS(socket        "${CURL_INCLUDES}" HAVE_SOCKET)
381 CHECK_SYMBOL_EXISTS(poll          "${CURL_INCLUDES}" HAVE_POLL)
382 CHECK_SYMBOL_EXISTS(select        "${CURL_INCLUDES}" HAVE_SELECT)
383 CHECK_SYMBOL_EXISTS(strdup        "${CURL_INCLUDES}" HAVE_STRDUP)
384 CHECK_SYMBOL_EXISTS(strstr        "${CURL_INCLUDES}" HAVE_STRSTR)
385 CHECK_SYMBOL_EXISTS(strtok_r      "${CURL_INCLUDES}" HAVE_STRTOK_R)
386 CHECK_SYMBOL_EXISTS(strftime      "${CURL_INCLUDES}" HAVE_STRFTIME)
387 CHECK_SYMBOL_EXISTS(uname         "${CURL_INCLUDES}" HAVE_UNAME)
388 CHECK_SYMBOL_EXISTS(strcasecmp    "${CURL_INCLUDES}" HAVE_STRCASECMP)
389 CHECK_SYMBOL_EXISTS(stricmp       "${CURL_INCLUDES}" HAVE_STRICMP)
390 CHECK_SYMBOL_EXISTS(strcmpi       "${CURL_INCLUDES}" HAVE_STRCMPI)
391 CHECK_SYMBOL_EXISTS(strncmpi      "${CURL_INCLUDES}" HAVE_STRNCMPI)
392 CHECK_SYMBOL_EXISTS(basename      "${CURL_INCLUDES}" HAVE_BASENAME)
393 IF(NOT HAVE_STRNCMPI)
394   SET(HAVE_STRCMPI)
395 ENDIF(NOT HAVE_STRNCMPI)
396 CHECK_SYMBOL_EXISTS(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR)
397 CHECK_SYMBOL_EXISTS(gettimeofday  "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY)
398 CHECK_SYMBOL_EXISTS(inet_addr     "${CURL_INCLUDES}" HAVE_INET_ADDR)
399 CHECK_SYMBOL_EXISTS(inet_pton     "${CURL_INCLUDES}" HAVE_INET_PTON)
400 CHECK_SYMBOL_EXISTS(inet_ntoa     "${CURL_INCLUDES}" HAVE_INET_NTOA)
401 CHECK_SYMBOL_EXISTS(inet_ntoa_r   "${CURL_INCLUDES}" HAVE_INET_NTOA_R)
402 CHECK_SYMBOL_EXISTS(tcsetattr     "${CURL_INCLUDES}" HAVE_TCSETATTR)
403 CHECK_SYMBOL_EXISTS(tcgetattr     "${CURL_INCLUDES}" HAVE_TCGETATTR)
404 CHECK_SYMBOL_EXISTS(perror        "${CURL_INCLUDES}" HAVE_PERROR)
405 CHECK_SYMBOL_EXISTS(closesocket   "${CURL_INCLUDES}" HAVE_CLOSESOCKET)
406 CHECK_SYMBOL_EXISTS(setvbuf       "${CURL_INCLUDES}" HAVE_SETVBUF)
407 CHECK_SYMBOL_EXISTS(sigsetjmp     "${CURL_INCLUDES}" HAVE_SIGSETJMP)
408 CHECK_SYMBOL_EXISTS(getpass_r     "${CURL_INCLUDES}" HAVE_GETPASS_R)
409 CHECK_SYMBOL_EXISTS(strlcat       "${CURL_INCLUDES}" HAVE_STRLCAT)
410 CHECK_SYMBOL_EXISTS(getpwuid      "${CURL_INCLUDES}" HAVE_GETPWUID)
411 CHECK_SYMBOL_EXISTS(geteuid       "${CURL_INCLUDES}" HAVE_GETEUID)
412 CHECK_SYMBOL_EXISTS(utime         "${CURL_INCLUDES}" HAVE_UTIME)
413 IF(CMAKE_USE_OPENSSL)
414   CHECK_SYMBOL_EXISTS(RAND_status   "${CURL_INCLUDES}" HAVE_RAND_STATUS)
415   CHECK_SYMBOL_EXISTS(RAND_screen   "${CURL_INCLUDES}" HAVE_RAND_SCREEN)
416   CHECK_SYMBOL_EXISTS(RAND_egd      "${CURL_INCLUDES}" HAVE_RAND_EGD)
417   CHECK_SYMBOL_EXISTS(CRYPTO_cleanup_all_ex_data "${CURL_INCLUDES}" 
418     HAVE_CRYPTO_CLEANUP_ALL_EX_DATA)
419 ENDIF(CMAKE_USE_OPENSSL)
420 CHECK_SYMBOL_EXISTS(gmtime_r      "${CURL_INCLUDES}" HAVE_GMTIME_R)
421 CHECK_SYMBOL_EXISTS(localtime_r   "${CURL_INCLUDES}" HAVE_LOCALTIME_R)
423 CHECK_SYMBOL_EXISTS(gethostbyname   "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME)
424 CHECK_SYMBOL_EXISTS(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R)
425 CHECK_SYMBOL_EXISTS(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R)
427 CHECK_SYMBOL_EXISTS(signal        "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC)
428 CHECK_SYMBOL_EXISTS(SIGALRM       "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO)
429 IF(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
430   SET(HAVE_SIGNAL 1)
431 ENDIF(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
432 CHECK_SYMBOL_EXISTS(uname          "${CURL_INCLUDES}" HAVE_UNAME)
433 CHECK_SYMBOL_EXISTS(strtoll        "${CURL_INCLUDES}" HAVE_STRTOLL)
434 CHECK_SYMBOL_EXISTS(_strtoi64      "${CURL_INCLUDES}" HAVE__STRTOI64)
435 CHECK_SYMBOL_EXISTS(strerror_r     "${CURL_INCLUDES}" HAVE_STRERROR_R)
436 CHECK_SYMBOL_EXISTS(siginterrupt   "${CURL_INCLUDES}" HAVE_SIGINTERRUPT)
437 CHECK_SYMBOL_EXISTS(perror         "${CURL_INCLUDES}" HAVE_PERROR)
438 CHECK_SYMBOL_EXISTS(fork           "${CURL_INCLUDES}" HAVE_FORK)
439 CHECK_SYMBOL_EXISTS(pipe           "${CURL_INCLUDES}" HAVE_PIPE)
440 CHECK_SYMBOL_EXISTS(ftruncate      "${CURL_INCLUDES}" HAVE_FTRUNCATE)
441 CHECK_SYMBOL_EXISTS(getprotobyname "${CURL_INCLUDES}" HAVE_GETPROTOBYNAME)
442 CHECK_SYMBOL_EXISTS(getrlimit      "${CURL_INCLUDES}" HAVE_GETRLIMIT)
443 CHECK_SYMBOL_EXISTS(idn_free       "${CURL_INCLUDES}" HAVE_IDN_FREE)
444 CHECK_SYMBOL_EXISTS(idna_strerror  "${CURL_INCLUDES}" HAVE_IDNA_STRERROR)
445 CHECK_SYMBOL_EXISTS(tld_strerror   "${CURL_INCLUDES}" HAVE_TLD_STRERROR)
446 CHECK_SYMBOL_EXISTS(setlocale      "${CURL_INCLUDES}" HAVE_SETLOCALE)
447 CHECK_SYMBOL_EXISTS(setrlimit      "${CURL_INCLUDES}" HAVE_SETRLIMIT)
449 # only build compat strtok if we need to
450 IF (NOT HAVE_STRTOK_R)
451   SET(libCurl_SRCS ${libCurl_SRCS}
452     strtok.c
453     )
454 ENDIF (NOT HAVE_STRTOK_R)
456 # only build compat strtoofft if we need to
457 IF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64)
458   SET(libCurl_SRCS ${libCurl_SRCS}
459     strtoofft.c
460     )
461 ENDIF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64)
463 # sigaction and sigsetjmp are special. Use special mechanism for
464 # detecting those, but only if previous attempt failed.
465 IF(HAVE_SIGNAL_H)
466   CHECK_SYMBOL_EXISTS(sigaction "signal.h" HAVE_SIGACTION)
467 ENDIF(HAVE_SIGNAL_H)
469 IF(NOT HAVE_SIGSETJMP)
470   IF(HAVE_SETJMP_H)
471     CHECK_SYMBOL_EXISTS(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP)
472     IF(HAVE_MACRO_SIGSETJMP)
473       SET(HAVE_SIGSETJMP 1)
474     ENDIF(HAVE_MACRO_SIGSETJMP)
475   ENDIF(HAVE_SETJMP_H)
476 ENDIF(NOT HAVE_SIGSETJMP)
478 # For other curl specific tests, use this macro.
479 MACRO(CURL_INTERNAL_TEST CURL_TEST)
480   IF("${CURL_TEST}" MATCHES "^${CURL_TEST}$")
481     SET(MACRO_CHECK_FUNCTION_DEFINITIONS 
482       "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}")
483     IF(CMAKE_REQUIRED_LIBRARIES)
484       SET(CURL_TEST_ADD_LIBRARIES
485         "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
486     ENDIF(CMAKE_REQUIRED_LIBRARIES)
488     MESSAGE(STATUS "Performing Curl Test ${CURL_TEST}")
489     TRY_COMPILE(${CURL_TEST}
490       ${CMAKE_BINARY_DIR}
491       ${LIBCURL_SOURCE_DIR}/CMake/CurlTests.c
492       CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
493       "${CURL_TEST_ADD_LIBRARIES}"
494       OUTPUT_VARIABLE OUTPUT)
495     IF(${CURL_TEST})
496       SET(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
497       MESSAGE(STATUS "Performing Curl Test ${CURL_TEST} - Success")
498       FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
499         "Performing Curl Test ${CURL_TEST} passed with the following output:\n"
500         "${OUTPUT}\n")
501     ELSE(${CURL_TEST})
502       MESSAGE(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
503       SET(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
504       FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
505         "Performing Curl Test ${CURL_TEST} failed with the following output:\n"
506         "${OUTPUT}\n")
507     ENDIF(${CURL_TEST})
508   ENDIF("${CURL_TEST}" MATCHES "^${CURL_TEST}$")
509 ENDMACRO(CURL_INTERNAL_TEST) 
511 MACRO(CURL_INTERNAL_TEST_RUN CURL_TEST)
512   IF("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$")
513     SET(MACRO_CHECK_FUNCTION_DEFINITIONS 
514       "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}")
515     IF(CMAKE_REQUIRED_LIBRARIES)
516       SET(CURL_TEST_ADD_LIBRARIES
517         "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
518     ENDIF(CMAKE_REQUIRED_LIBRARIES)
520     MESSAGE(STATUS "Performing Curl Test ${CURL_TEST}")
521     TRY_RUN(${CURL_TEST} ${CURL_TEST}_COMPILE
522       ${CMAKE_BINARY_DIR}
523       ${LIBCURL_SOURCE_DIR}/CMake/CurlTests.c
524       CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
525       "${CURL_TEST_ADD_LIBRARIES}"
526       OUTPUT_VARIABLE OUTPUT)
527     IF(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
528       SET(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
529       MESSAGE(STATUS "Performing Curl Test ${CURL_TEST} - Success")
530     ELSE(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
531       MESSAGE(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
532       SET(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
533       FILE(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
534         "Performing Curl Test ${CURL_TEST} failed with the following output:\n"
535         "${OUTPUT}")
536       IF(${CURL_TEST}_COMPILE)
537         FILE(APPEND 
538           "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log" 
539           "There was a running problem of this test\n")
540       ENDIF(${CURL_TEST}_COMPILE)
541       FILE(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log" 
542         "\n\n")
543     ENDIF(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
544   ENDIF("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$")
545 ENDMACRO(CURL_INTERNAL_TEST_RUN) 
547 # Do curl specific tests
548 #OPTION(CURL_HAVE_DISABLED_NONBLOCKING "Disable non-blocking socket detection" OFF)
549 SET(CURL_NONBLOCKING_TESTS)
550 IF(NOT CURL_HAVE_DISABLED_NONBLOCKING)
551   SET(CURL_NONBLOCKING_TESTS
552     HAVE_FIONBIO
553     HAVE_IOCTLSOCKET
554     HAVE_IOCTLSOCKET_CASE
555     HAVE_O_NONBLOCK
556     HAVE_SO_NONBLOCK
557     )
558 ENDIF(NOT CURL_HAVE_DISABLED_NONBLOCKING)
559 FOREACH(CURL_TEST 
560     ${CURL_NONBLOCKING_TESTS}
561     TIME_WITH_SYS_TIME
562     HAVE_O_NONBLOCKHAVE_GETHOSTBYADDR_R_5
563     HAVE_GETHOSTBYADDR_R_7
564     HAVE_GETHOSTBYADDR_R_8
565     HAVE_GETHOSTBYADDR_R_5_REENTRANT
566     HAVE_GETHOSTBYADDR_R_7_REENTRANT
567     HAVE_GETHOSTBYADDR_R_8_REENTRANT
568     HAVE_GETHOSTBYNAME_R_3
569     HAVE_GETHOSTBYNAME_R_5
570     HAVE_GETHOSTBYNAME_R_6
571     HAVE_GETHOSTBYNAME_R_3_REENTRANT
572     HAVE_GETHOSTBYNAME_R_5_REENTRANT
573     HAVE_GETHOSTBYNAME_R_6_REENTRANT
574     HAVE_SOCKLEN_T
575     HAVE_IN_ADDR_T
576     STDC_HEADERS
577     RETSIGTYPE_TEST
578     HAVE_INET_NTOA_R_DECL
579     HAVE_INET_NTOA_R_DECL_REENTRANT
580     HAVE_GETADDRINFO
581     HAVE_FILE_OFFSET_BITS
582     )
583   CURL_INTERNAL_TEST(${CURL_TEST})
584 ENDFOREACH(CURL_TEST)
585 IF(HAVE_FILE_OFFSET_BITS)
586   SET(_FILE_OFFSET_BITS 64)
587 ENDIF(HAVE_FILE_OFFSET_BITS)
589 FOREACH(CURL_TEST 
590     HAVE_GLIBC_STRERROR_R
591     HAVE_POSIX_STRERROR_R
592     )
593   CURL_INTERNAL_TEST_RUN(${CURL_TEST})
594 ENDFOREACH(CURL_TEST)
596 # Check for reentrant
597 FOREACH(CURL_TEST
598     HAVE_GETHOSTBYADDR_R_5
599     HAVE_GETHOSTBYADDR_R_7
600     HAVE_GETHOSTBYADDR_R_8
601     HAVE_GETHOSTBYNAME_R_3
602     HAVE_GETHOSTBYNAME_R_5
603     HAVE_GETHOSTBYNAME_R_6
604     HAVE_INET_NTOA_R_DECL_REENTRANT)
605   IF(NOT ${CURL_TEST})
606     IF(${CURL_TEST}_REENTRANT)
607       SET(NEED_REENTRANT 1)
608     ENDIF(${CURL_TEST}_REENTRANT)
609   ENDIF(NOT ${CURL_TEST})
610 ENDFOREACH(CURL_TEST)
612 IF(NEED_REENTRANT)
613   FOREACH(CURL_TEST
614       HAVE_GETHOSTBYADDR_R_5
615       HAVE_GETHOSTBYADDR_R_7
616       HAVE_GETHOSTBYADDR_R_8
617       HAVE_GETHOSTBYNAME_R_3
618       HAVE_GETHOSTBYNAME_R_5
619       HAVE_GETHOSTBYNAME_R_6)
620     SET(${CURL_TEST} 0)
621     IF(${CURL_TEST}_REENTRANT)
622       SET(${CURL_TEST} 1)
623     ENDIF(${CURL_TEST}_REENTRANT)
624   ENDFOREACH(CURL_TEST)
625 ENDIF(NEED_REENTRANT)
627 IF(HAVE_INET_NTOA_R_DECL_REENTRANT)
628   SET(HAVE_INET_NTOA_R_DECL 1)
629   SET(NEED_REENTRANT 1)
630 ENDIF(HAVE_INET_NTOA_R_DECL_REENTRANT)
632 # Some other minor tests
634 IF(NOT HAVE_SOCKLEN_T)
635   SET(socklen_t "int")
636 ENDIF(NOT HAVE_SOCKLEN_T)
638 IF(NOT HAVE_IN_ADDR_T)
639   SET(in_addr_t "unsigned long")
640 ENDIF(NOT HAVE_IN_ADDR_T)
642 # Fix libz / zlib.h
644 IF(NOT CURL_SPECIAL_LIBZ)
645   IF(NOT HAVE_LIBZ)
646     SET(HAVE_ZLIB_H 0)
647   ENDIF(NOT HAVE_LIBZ)
649   IF(NOT HAVE_ZLIB_H)
650     SET(HAVE_LIBZ 0)
651   ENDIF(NOT HAVE_ZLIB_H)
652 ENDIF(NOT CURL_SPECIAL_LIBZ)
654 IF(_FILE_OFFSET_BITS)
655   SET(_FILE_OFFSET_BITS 64)
656 ENDIF(_FILE_OFFSET_BITS)
657 SET(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64")
658 SET(CMAKE_EXTRA_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/curl/curl.h")
659 CHECK_TYPE_SIZE("curl_off_t" SIZEOF_CURL_OFF_T)
660 SET(CMAKE_EXTRA_INCLUDE_FILES)
661 SET(CMAKE_REQUIRED_FLAGS)
664 # Check for nonblocking
665 SET(HAVE_DISABLED_NONBLOCKING 1)
666 IF(HAVE_FIONBIO OR 
667     HAVE_IOCTLSOCKET OR
668     HAVE_IOCTLSOCKET_CASE OR
669     HAVE_O_NONBLOCK)
670   SET(HAVE_DISABLED_NONBLOCKING)
671 ENDIF(HAVE_FIONBIO OR 
672   HAVE_IOCTLSOCKET OR
673   HAVE_IOCTLSOCKET_CASE OR
674   HAVE_O_NONBLOCK)
676 IF(RETSIGTYPE_TEST)
677   SET(RETSIGTYPE void)
678 ELSE(RETSIGTYPE_TEST)
679   SET(RETSIGTYPE int)
680 ENDIF(RETSIGTYPE_TEST)
682 IF(CMAKE_COMPILER_IS_GNUCC AND APPLE)
683   INCLUDE(CheckCCompilerFlag)
684   CHECK_C_COMPILER_FLAG(-Wno-long-double HAVE_C_FLAG_Wno_long_double)
685   IF(HAVE_C_FLAG_Wno_long_double)
686     # The Mac version of GCC warns about use of long double.  Disable it.
687     GET_SOURCE_FILE_PROPERTY(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS)
688     IF(MPRINTF_COMPILE_FLAGS)
689       SET(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double")
690     ELSE(MPRINTF_COMPILE_FLAGS)
691       SET(MPRINTF_COMPILE_FLAGS "-Wno-long-double")
692     ENDIF(MPRINTF_COMPILE_FLAGS)
693     SET_SOURCE_FILES_PROPERTIES(mprintf.c PROPERTIES
694       COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS})
695   ENDIF(HAVE_C_FLAG_Wno_long_double)
696 ENDIF(CMAKE_COMPILER_IS_GNUCC AND APPLE)
698 INCLUDE(CMake/OtherTests.cmake)
700 # The rest of the build
702 INCLUDE_DIRECTORIES(${LIBCURL_SOURCE_DIR})
703 INCLUDE_DIRECTORIES(${LIBCURL_BINARY_DIR})
704 ADD_DEFINITIONS(-DHAVE_CONFIG_H
705   -DCURL_STATICLIB)
706 CONFIGURE_FILE(${LIBCURL_SOURCE_DIR}/config.h.in
707   ${LIBCURL_BINARY_DIR}/config.h)
709 ADD_LIBRARY(cmcurl ${libCurl_SRCS})
710 TARGET_LINK_LIBRARIES(cmcurl ${CURL_LIBS})
712 OPTION(CURL_TESTING "Do libCurl testing" OFF)
713 IF(CURL_TESTING)
714   SUBDIRS(Testing)
715 ENDIF(CURL_TESTING)
717 ADD_EXECUTABLE(LIBCURL Testing/curltest.c)
718 TARGET_LINK_LIBRARIES(LIBCURL cmcurl ${CMAKE_DL_LIBS})
719 ADD_TEST(curl "${EXECUTABLE_OUTPUT_PATH}/LIBCURL")