1 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
2 IF(COMMAND CMAKE_POLICY)
3 CMAKE_POLICY(SET CMP0003 NEW)
4 ENDIF(COMMAND CMAKE_POLICY)
7 INCLUDE_REGULAR_EXPRESSION("^.*$")
9 # Setup package meta-data
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.
26 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")
29 # If we are on AIX, do the _ALL_SOURCE magic
30 IF(${CMAKE_SYSTEM_NAME} MATCHES AIX)
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)
50 # amigaos.c - does not build on AmigaOS
84 # memdebug.c -not used
104 # strtok.c - specify later
105 # strtoofft.c - specify later
114 SET(CURL_DISABLE_LDAP 1)
115 IF(NOT CURL_DISABLE_LDAP)
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)
125 SET(libCurl_SRCS ${libCurl_SRCS}
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}
137 ENDIF(CURL_MALLOC_DEBUG)
139 # On windows preload settings
141 INCLUDE(${LIBCURL_SOURCE_DIR}/Platforms/WindowsCache.cmake)
144 # This macro checks if the symbol exists in the library and if it
145 # does, it appends library to the list.
147 MACRO(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE)
148 CHECK_LIBRARY_EXISTS("${LIBRARY};${CURL_LIBS}" ${SYMBOL} ""
151 SET(CURL_LIBS ${CURL_LIBS} ${LIBRARY})
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.
166 SET(NOT_NEED_LIBNSL 1)
167 CHECK_LIBRARY_EXISTS_CONCAT("bind" gethostbyname HAVE_LIBBIND)
168 CHECK_LIBRARY_EXISTS_CONCAT("bnetapi" closesocket HAVE_LIBBNETAPI)
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)
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})
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)
212 SET_SOURCE_FILES_PROPERTIES(
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})
233 SET(CURL_INCLUDES ${CURL_INCLUDES} ${FILE})
235 ENDMACRO(CHECK_INCLUDE_FILE_CONCAT)
237 # Check for header files
239 CHECK_INCLUDE_FILE_CONCAT("ws2tcpip.h" HAVE_WS2TCPIP_H)
240 CHECK_INCLUDE_FILE_CONCAT("winsock2.h" HAVE_WINSOCK2_H)
242 CHECK_INCLUDE_FILE_CONCAT("stdio.h" HAVE_STDIO_H)
244 CHECK_INCLUDE_FILE_CONCAT("windows.h" HAVE_WINDOWS_H)
245 CHECK_INCLUDE_FILE_CONCAT("winsock.h" HAVE_WINSOCK_H)
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"
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)
327 ENDIF(SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
328 IF(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
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)
336 ENDIF(HAVE_SIZEOF_LONG_LONG)
338 FIND_FILE(RANDOM_FILE urandom /dev)
339 MARK_AS_ADVANCED(RANDOM_FILE)
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)
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)
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}
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}
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.
466 CHECK_SYMBOL_EXISTS(sigaction "signal.h" HAVE_SIGACTION)
469 IF(NOT HAVE_SIGSETJMP)
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)
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}
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)
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"
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"
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
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"
536 IF(${CURL_TEST}_COMPILE)
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"
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
554 HAVE_IOCTLSOCKET_CASE
558 ENDIF(NOT CURL_HAVE_DISABLED_NONBLOCKING)
560 ${CURL_NONBLOCKING_TESTS}
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
578 HAVE_INET_NTOA_R_DECL
579 HAVE_INET_NTOA_R_DECL_REENTRANT
581 HAVE_FILE_OFFSET_BITS
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)
590 HAVE_GLIBC_STRERROR_R
591 HAVE_POSIX_STRERROR_R
593 CURL_INTERNAL_TEST_RUN(${CURL_TEST})
594 ENDFOREACH(CURL_TEST)
596 # Check for reentrant
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)
606 IF(${CURL_TEST}_REENTRANT)
607 SET(NEED_REENTRANT 1)
608 ENDIF(${CURL_TEST}_REENTRANT)
609 ENDIF(NOT ${CURL_TEST})
610 ENDFOREACH(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)
621 IF(${CURL_TEST}_REENTRANT)
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)
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)
644 IF(NOT CURL_SPECIAL_LIBZ)
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)
668 HAVE_IOCTLSOCKET_CASE OR
670 SET(HAVE_DISABLED_NONBLOCKING)
671 ENDIF(HAVE_FIONBIO OR
673 HAVE_IOCTLSOCKET_CASE OR
678 ELSE(RETSIGTYPE_TEST)
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
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)
717 ADD_EXECUTABLE(LIBCURL Testing/curltest.c)
718 TARGET_LINK_LIBRARIES(LIBCURL cmcurl ${CMAKE_DL_LIBS})
719 ADD_TEST(curl "${EXECUTABLE_OUTPUT_PATH}/LIBCURL")