Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Utilities / cmcurl-7.19.0 / lib / CMakeLists.txt
blob4b01adb9d109afa174d5a8dce086d951b198b372
1 # Include all the necessary files for macros
2 set(CMAKE_MODULE_PATH "${CURL_SOURCE_DIR}/CMake")
3 include (CheckFunctionExists)
4 include (CheckIncludeFile)
5 include (CheckIncludeFiles)
6 include (CheckLibraryExists)
7 include (CheckSymbolExists)
8 include (CheckCSourceCompiles)
9 # if crosscompiling is on, the CHECK_TYPE_SIZE macro coming with cmake uses
10 # TRY_COMPILE instead of TRY_RUN which makes crosscompiling easier, Alex
11 if(CMAKE_CROSSCOMPILING)  
12   include ("${CMAKE_ROOT}/Modules/CheckTypeSize.cmake")
13 else(CMAKE_CROSSCOMPILING)
14   include (CheckTypeSize)
15 endif(CMAKE_CROSSCOMPILING)
18 set(libCurl_SRCS 
19   file.c timeval.c base64.c hostip.c progress.c formdata.c      
20   cookie.c http.c sendf.c ftp.c url.c dict.c if2ip.c speedcheck.c
21   ldap.c ssluse.c version.c getenv.c escape.c mprintf.c telnet.c
22   netrc.c getinfo.c transfer.c strequal.c easy.c security.c krb4.c
23   krb5.c memdebug.c http_chunks.c strtok.c connect.c llist.c hash.c
24   multi.c content_encoding.c share.c http_digest.c md5.c
25   http_negotiate.c http_ntlm.c inet_pton.c strtoofft.c strerror.c
26   hostares.c hostasyn.c hostip4.c hostip6.c hostsyn.c hostthre.c
27   inet_ntop.c parsedate.c select.c gtls.c sslgen.c tftp.c splay.c
28   strdup.c socks.c ssh.c nss.c qssl.c
29   arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h        
30   progress.h formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h
31   if2ip.h speedcheck.h urldata.h curl_ldap.h ssluse.h escape.h telnet.h
32   getinfo.h strequal.h krb4.h memdebug.h inet_ntoa_r.h http_chunks.h
33   strtok.h connect.h llist.h hash.h content_encoding.h share.h
34   curl_md5.h http_digest.h http_negotiate.h http_ntlm.h inet_pton.h
35   strtoofft.h strerror.h inet_ntop.h curlx.h memory.h setup.h   
36   transfer.h select.h easyif.h multiif.h parsedate.h sslgen.h gtls.h
37   tftp.h sockaddr.h splay.h strdup.h setup_once.h socks.h ssh.h nssg.h
38   curl_base64.h
41 set(CURL_DISABLE_LDAP 1)
42 if(NOT CURL_DISABLE_LDAP)
43   set(libCurl_SRCS
44     ${libCurl_SRCS}
45     ldap.c
46     )
47 endif(NOT CURL_DISABLE_LDAP)
49 # if we have Kerberos 4, right now this is never on
50 #OPTION(CURL_KRB4 "Use Kerberos 4" OFF)
51 if(CURL_KRB4)
52   set(libCurl_SRCS ${libCurl_SRCS}
53     krb4.c
54     security.c
55     )
56 endif(CURL_KRB4)
58 #OPTION(CURL_MALLOC_DEBUG "Debug mallocs in Curl" OFF)
59 mark_as_advanced(CURL_MALLOC_DEBUG)
60 if(CURL_MALLOC_DEBUG)
61   set(libCurl_SRCS ${libCurl_SRCS}
62     memdebug.c
63     )
64 endif(CURL_MALLOC_DEBUG)
66 # On windows preload settings
67 if(WIN32)
68   include(${CURL_SOURCE_DIR}/CMake/WindowsCache.cmake)
69 endif(WIN32)
71 # This macro checks if the symbol exists in the library and if it
72 # does, it appends library to the list.
73 set(CURL_LIBS "")
74 macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE)
75   check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "" 
76     ${VARIABLE})
77   if(${VARIABLE})
78     set(CURL_LIBS ${CURL_LIBS} ${LIBRARY})
79   endif(${VARIABLE})
80 endmacro(CHECK_LIBRARY_EXISTS_CONCAT)
82 # Check for all needed libraries
83 check_library_exists_concat("dl"     dlopen       HAVE_LIBDL)
84 #CHECK_LIBRARY_EXISTS_CONCAT("ucb"    gethostname  HAVE_LIBUCB)
85 check_library_exists_concat("socket" connect      HAVE_LIBSOCKET)
86 check_library_exists("c" gethostbyname "" NOT_NEED_LIBNSL)
88 # Yellowtab Zeta needs different libraries than BeOS 5.
89 if(BEOS)
90   set(NOT_NEED_LIBNSL 1)
91   check_library_exists_concat("bind" gethostbyname HAVE_LIBBIND)
92   check_library_exists_concat("bnetapi" closesocket HAVE_LIBBNETAPI)
93 endif(BEOS)
95 check_library_exists_concat("network" recv HAVE_LIBNETWORK)
97 if(NOT NOT_NEED_LIBNSL)
98   check_library_exists_concat("nsl"    gethostbyname  HAVE_LIBNSL)
99 endif(NOT NOT_NEED_LIBNSL)
101 check_library_exists_concat("ws2_32" getch        HAVE_LIBWS2_32)
102 check_library_exists_concat("winmm"  getch        HAVE_LIBWINMM)
103 if(NOT CURL_SPECIAL_LIBZ)
104   check_library_exists_concat("z"      inflateEnd   HAVE_LIBZ)
105 endif(NOT CURL_SPECIAL_LIBZ)
107 option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON)
108 mark_as_advanced(CMAKE_USE_OPENSSL)
109 if(CMAKE_USE_OPENSSL)
110   check_library_exists_concat("crypto" CRYPTO_lock  HAVE_LIBCRYPTO)
111   check_library_exists_concat("ssl"    SSL_connect  HAVE_LIBSSL)
112 endif(CMAKE_USE_OPENSSL)
114 # Check for idn
115 check_library_exists_concat("idn" idna_to_ascii_lz HAVE_LIBIDN)
117 # Check for symbol dlopen (same as HAVE_LIBDL)
118 check_library_exists("${CURL_LIBS}" dlopen "" HAVE_DLOPEN)
120 # For other tests to use the same libraries
121 set(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBS})
123 if(CURL_SPECIAL_LIBZ)
124   set(CURL_LIBS ${CURL_LIBS} "${CURL_SPECIAL_LIBZ}")
125   include_directories(${CURL_SPECIAL_LIBZ_INCLUDES})
126   set(HAVE_LIBZ 0)
127   set(HAVE_ZLIB_H 0)
128 endif(CURL_SPECIAL_LIBZ)
130 # do we have process.h
131 check_include_file("process.h" HAVE_PROCESS_H)
133 # Check if header file exists and add it to the list.
134 macro(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE)
135   check_include_files("${CURL_INCLUDES};${FILE}" ${VARIABLE})
136   if(${VARIABLE})
137     set(CURL_INCLUDES ${CURL_INCLUDES} ${FILE})
138   endif(${VARIABLE})
139 endmacro(CHECK_INCLUDE_FILE_CONCAT)
141 # Check for header files
142 if(NOT UNIX)
143   check_include_file_concat("ws2tcpip.h"     HAVE_WS2TCPIP_H)
144   check_include_file_concat("winsock2.h"     HAVE_WINSOCK2_H)
145 endif(NOT UNIX)
146 check_include_file_concat("stdio.h"          HAVE_STDIO_H)
147 if(NOT UNIX)
148   check_include_file_concat("windows.h"      HAVE_WINDOWS_H)
149   check_include_file_concat("winsock.h"      HAVE_WINSOCK_H)
150 endif(NOT UNIX)
151 check_include_file_concat("stddef.h"         HAVE_STDDEF_H)
152 check_include_file_concat("sys/types.h"      HAVE_SYS_TYPES_H)
153 check_include_file_concat("inttypes.h"       HAVE_INTTYPES_H)
154 check_include_file_concat("alloca.h"         HAVE_ALLOCA_H)
155 check_include_file_concat("arpa/inet.h"      HAVE_ARPA_INET_H)
156 check_include_file_concat("dlfcn.h"          HAVE_DLFCN_H)
157 check_include_file_concat("fcntl.h"          HAVE_FCNTL_H)
158 check_include_file_concat("malloc.h"         HAVE_MALLOC_H)
159 check_include_file_concat("memory.h"         HAVE_MEMORY_H)
160 check_include_file_concat("netdb.h"          HAVE_NETDB_H)
161 check_include_file_concat("sys/poll.h"       HAVE_SYS_POLL_H)
162 check_include_file_concat("assert.h"         HAVE_ASSERT_H)
163 check_include_file_concat("limits.h"         HAVE_LIMITS_H)
165 if(CMAKE_USE_OPENSSL)
166   check_include_file_concat("openssl/x509.h"   HAVE_OPENSSL_X509_H)
167   check_include_file_concat("openssl/engine.h" HAVE_OPENSSL_ENGINE_H)
168   check_include_file_concat("openssl/rsa.h"    HAVE_OPENSSL_RSA_H)
169   check_include_file_concat("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H)
170   check_include_file_concat("openssl/pem.h"    HAVE_OPENSSL_PEM_H)
171   check_include_file_concat("openssl/ssl.h"    HAVE_OPENSSL_SSL_H)
172   check_include_file_concat("openssl/err.h"    HAVE_OPENSSL_ERR_H)
173   check_include_file_concat("openssl/rand.h"   HAVE_OPENSSL_RAND_H)
174   check_include_file_concat("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H)
175 endif(CMAKE_USE_OPENSSL)
177 if(NOT CURL_SPECIAL_LIBZ)
178   check_include_file_concat("zlib.h"           HAVE_ZLIB_H)
179 endif(NOT CURL_SPECIAL_LIBZ)
180 check_include_file_concat("sys/socket.h"     HAVE_SYS_SOCKET_H)
181 check_include_file_concat("netinet/in.h"     HAVE_NETINET_IN_H)
182 check_include_file_concat("net/if.h"         HAVE_NET_IF_H)
183 check_include_file_concat("netinet/if_ether.h" 
184   HAVE_NETINET_IF_ETHER_H)
185 check_include_file_concat("netinet/tcp.h" 
186   HAVE_NETINET_TCP_H)
187 check_include_file_concat("sys/select.h"    HAVE_SYS_SELECT_H)
188 check_include_file_concat("utime.h"         HAVE_UTIME_H)
189 check_include_file_concat("netinet/in.h"    HAVE_NETINET_IN_H)
190 check_include_file_concat("pwd.h"           HAVE_PWD_H)
191 check_include_file_concat("sgtty.h"         HAVE_SGTTY_H)
192 check_include_file_concat("stdint.h"        HAVE_STDINT_H)
193 check_include_file_concat("stdlib.h"        HAVE_STDLIB_H)
194 check_include_file_concat("string.h"        HAVE_STRING_H)
195 check_include_file_concat("strings.h"       HAVE_STRINGS_H)
196 check_include_file_concat("sys/param.h"     HAVE_SYS_PARAM_H)
197 check_include_file_concat("sys/stat.h"      HAVE_SYS_STAT_H)
198 check_include_file_concat("sys/time.h"      HAVE_SYS_TIME_H)
199 check_include_file_concat("sys/resource.h"  HAVE_SYS_RESOURCE_H)
200 check_include_file_concat("termios.h"       HAVE_TERMIOS_H)
201 check_include_file_concat("termio.h"        HAVE_TERMIO_H)
202 check_include_file_concat("io.h"            HAVE_IO_H)
203 check_include_file_concat("time.h"          HAVE_TIME_H)
204 check_include_file_concat("unistd.h"        HAVE_UNISTD_H)
205 check_include_file_concat("sys/utime.h"     HAVE_SYS_UTIME_H)
206 check_include_file_concat("sockio.h"        HAVE_SOCKIO_H)
207 check_include_file_concat("sys/sockio.h"    HAVE_SYS_SOCKIO_H)
208 check_include_file_concat("x509.h"          HAVE_X509_H)
209 check_include_file_concat("locale.h"        HAVE_LOCALE_H)
210 check_include_file_concat("setjmp.h"        HAVE_SETJMP_H)
211 check_include_file_concat("signal.h"        HAVE_SIGNAL_H)
212 check_include_file_concat("sys/ioctl.h"     HAVE_SYS_IOCTL_H)
213 check_include_file_concat("sys/utsname.h"   HAVE_SYS_UTSNAME_H)
214 check_include_file_concat("idn-free.h"      HAVE_IDN_FREE_H)
215 check_include_file_concat("idna.h"          HAVE_IDNA_H)
216 check_include_file_concat("tld.h"           HAVE_TLD_H)
217 check_include_file_concat("arpa/tftp.h"     HAVE_ARPA_TFTP_H)
218 check_include_file_concat("errno.h"         HAVE_ERRNO_H)
219 check_include_file_concat("libgen.h"        HAVE_LIBGEN_H)
220 check_include_file_concat("sys/filio.h"     HAVE_SYS_FILIO_H)
221 check_type_size(size_t  SIZEOF_SIZE_T)
222 check_type_size(ssize_t  SIZEOF_SSIZE_T)
223 check_type_size("long long"  SIZEOF_LONG_LONG)
224 check_type_size("long"  SIZEOF_LONG)
225 check_type_size("__int64"  SIZEOF___INT64)
226 check_type_size("long double"  SIZEOF_LONG_DOUBLE)
227 check_type_size("time_t"  SIZEOF_TIME_T)
228 if(NOT HAVE_SIZEOF_SSIZE_T)
229   if(SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
230     set(ssize_t long)
231   endif(SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
232   if(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
233     set(ssize_t __int64)
234   endif(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
235 endif(NOT HAVE_SIZEOF_SSIZE_T)
237 if(HAVE_SIZEOF_LONG_LONG)
238   set(HAVE_LONGLONG 1)
239   set(HAVE_LL 1)
240 endif(HAVE_SIZEOF_LONG_LONG)
242 find_file(RANDOM_FILE urandom /dev)
243 mark_as_advanced(RANDOM_FILE)
245 # Check for some functions that are used
246 check_symbol_exists(basename      "${CURL_INCLUDES}" HAVE_BASENAME)
247 check_symbol_exists(socket        "${CURL_INCLUDES}" HAVE_SOCKET)
248 check_symbol_exists(poll          "${CURL_INCLUDES}" HAVE_POLL)
249 check_symbol_exists(select        "${CURL_INCLUDES}" HAVE_SELECT)
250 check_symbol_exists(strdup        "${CURL_INCLUDES}" HAVE_STRDUP)
251 check_symbol_exists(strstr        "${CURL_INCLUDES}" HAVE_STRSTR)
252 check_symbol_exists(strtok_r      "${CURL_INCLUDES}" HAVE_STRTOK_R)
253 check_symbol_exists(strftime      "${CURL_INCLUDES}" HAVE_STRFTIME)
254 check_symbol_exists(uname         "${CURL_INCLUDES}" HAVE_UNAME)
255 check_symbol_exists(strcasecmp    "${CURL_INCLUDES}" HAVE_STRCASECMP)
256 check_symbol_exists(stricmp       "${CURL_INCLUDES}" HAVE_STRICMP)
257 check_symbol_exists(strcmpi       "${CURL_INCLUDES}" HAVE_STRCMPI)
258 check_symbol_exists(strncmpi      "${CURL_INCLUDES}" HAVE_STRNCMPI)
259 check_symbol_exists(basename      "${CURL_INCLUDES}" HAVE_BASENAME)
260 if(NOT HAVE_STRNCMPI)
261   set(HAVE_STRCMPI)
262 endif(NOT HAVE_STRNCMPI)
263 check_symbol_exists(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR)
264 check_symbol_exists(gettimeofday  "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY)
265 check_symbol_exists(inet_addr     "${CURL_INCLUDES}" HAVE_INET_ADDR)
266 check_symbol_exists(inet_pton     "${CURL_INCLUDES}" HAVE_INET_PTON)
267 check_symbol_exists(inet_ntoa     "${CURL_INCLUDES}" HAVE_INET_NTOA)
268 check_symbol_exists(inet_ntoa_r   "${CURL_INCLUDES}" HAVE_INET_NTOA_R)
269 check_symbol_exists(tcsetattr     "${CURL_INCLUDES}" HAVE_TCSETATTR)
270 check_symbol_exists(tcgetattr     "${CURL_INCLUDES}" HAVE_TCGETATTR)
271 check_symbol_exists(perror        "${CURL_INCLUDES}" HAVE_PERROR)
272 check_symbol_exists(closesocket   "${CURL_INCLUDES}" HAVE_CLOSESOCKET)
273 check_symbol_exists(setvbuf       "${CURL_INCLUDES}" HAVE_SETVBUF)
274 check_symbol_exists(sigsetjmp     "${CURL_INCLUDES}" HAVE_SIGSETJMP)
275 check_symbol_exists(getpass_r     "${CURL_INCLUDES}" HAVE_GETPASS_R)
276 check_symbol_exists(strlcat       "${CURL_INCLUDES}" HAVE_STRLCAT)
277 check_symbol_exists(getpwuid      "${CURL_INCLUDES}" HAVE_GETPWUID)
278 check_symbol_exists(geteuid       "${CURL_INCLUDES}" HAVE_GETEUID)
279 check_symbol_exists(utime         "${CURL_INCLUDES}" HAVE_UTIME)
280 if(CMAKE_USE_OPENSSL)
281   check_symbol_exists(RAND_status   "${CURL_INCLUDES}" HAVE_RAND_STATUS)
282   check_symbol_exists(RAND_screen   "${CURL_INCLUDES}" HAVE_RAND_SCREEN)
283   check_symbol_exists(RAND_egd      "${CURL_INCLUDES}" HAVE_RAND_EGD)
284   check_symbol_exists(CRYPTO_cleanup_all_ex_data "${CURL_INCLUDES}" 
285     HAVE_CRYPTO_CLEANUP_ALL_EX_DATA)
286 endif(CMAKE_USE_OPENSSL)
287 check_symbol_exists(gmtime_r      "${CURL_INCLUDES}" HAVE_GMTIME_R)
288 check_symbol_exists(localtime_r   "${CURL_INCLUDES}" HAVE_LOCALTIME_R)
290 check_symbol_exists(gethostbyname   "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME)
291 check_symbol_exists(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R)
292 check_symbol_exists(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R)
294 check_symbol_exists(signal        "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC)
295 check_symbol_exists(SIGALRM       "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO)
296 if(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
297   set(HAVE_SIGNAL 1)
298 endif(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
299 check_symbol_exists(uname          "${CURL_INCLUDES}" HAVE_UNAME)
300 check_symbol_exists(strtoll        "${CURL_INCLUDES}" HAVE_STRTOLL)
301 check_symbol_exists(_strtoi64      "${CURL_INCLUDES}" HAVE__STRTOI64)
302 check_symbol_exists(strerror_r     "${CURL_INCLUDES}" HAVE_STRERROR_R)
303 check_symbol_exists(siginterrupt   "${CURL_INCLUDES}" HAVE_SIGINTERRUPT)
304 check_symbol_exists(perror         "${CURL_INCLUDES}" HAVE_PERROR)
305 check_symbol_exists(fork           "${CURL_INCLUDES}" HAVE_FORK)
306 check_symbol_exists(pipe           "${CURL_INCLUDES}" HAVE_PIPE)
307 check_symbol_exists(ftruncate      "${CURL_INCLUDES}" HAVE_FTRUNCATE)
308 check_symbol_exists(getprotobyname "${CURL_INCLUDES}" HAVE_GETPROTOBYNAME)
309 check_symbol_exists(getrlimit      "${CURL_INCLUDES}" HAVE_GETRLIMIT)
310 check_symbol_exists(idn_free       "${CURL_INCLUDES}" HAVE_IDN_FREE)
311 check_symbol_exists(idna_strerror  "${CURL_INCLUDES}" HAVE_IDNA_STRERROR)
312 check_symbol_exists(tld_strerror   "${CURL_INCLUDES}" HAVE_TLD_STRERROR)
313 check_symbol_exists(setlocale      "${CURL_INCLUDES}" HAVE_SETLOCALE)
314 check_symbol_exists(setrlimit      "${CURL_INCLUDES}" HAVE_SETRLIMIT)
317 # sigaction and sigsetjmp are special. Use special mechanism for
318 # detecting those, but only if previous attempt failed.
319 if(HAVE_SIGNAL_H)
320   check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
321 endif(HAVE_SIGNAL_H)
323 if(NOT HAVE_SIGSETJMP)
324   if(HAVE_SETJMP_H)
325     check_symbol_exists(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP)
326     if(HAVE_MACRO_SIGSETJMP)
327       set(HAVE_SIGSETJMP 1)
328     endif(HAVE_MACRO_SIGSETJMP)
329   endif(HAVE_SETJMP_H)
330 endif(NOT HAVE_SIGSETJMP)
332 # For other curl specific tests, use this macro.
333 macro(CURL_INTERNAL_TEST CURL_TEST)
334   if("${CURL_TEST}" MATCHES "^${CURL_TEST}$")
335     set(MACRO_CHECK_FUNCTION_DEFINITIONS 
336       "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}")
337     if(CMAKE_REQUIRED_LIBRARIES)
338       set(CURL_TEST_ADD_LIBRARIES
339         "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
340     endif(CMAKE_REQUIRED_LIBRARIES)
342     message(STATUS "Performing Curl Test ${CURL_TEST}")
343     try_compile(${CURL_TEST}
344       ${CMAKE_BINARY_DIR}
345       ${CURL_SOURCE_DIR}/CMake/CurlTests.c
346       CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
347       "${CURL_TEST_ADD_LIBRARIES}"
348       OUTPUT_VARIABLE OUTPUT)
349     if(${CURL_TEST})
350       set(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
351       message(STATUS "Performing Curl Test ${CURL_TEST} - Success")
352       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
353         "Performing Curl Test ${CURL_TEST} passed with the following output:\n"
354         "${OUTPUT}\n")
355     else(${CURL_TEST})
356       message(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
357       set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
358       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
359         "Performing Curl Test ${CURL_TEST} failed with the following output:\n"
360         "${OUTPUT}\n")
361     endif(${CURL_TEST})
362   endif("${CURL_TEST}" MATCHES "^${CURL_TEST}$")
363 endmacro(CURL_INTERNAL_TEST) 
365 macro(CURL_INTERNAL_TEST_RUN CURL_TEST)
366   if("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$")
367     set(MACRO_CHECK_FUNCTION_DEFINITIONS 
368       "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}")
369     if(CMAKE_REQUIRED_LIBRARIES)
370       set(CURL_TEST_ADD_LIBRARIES
371         "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
372     endif(CMAKE_REQUIRED_LIBRARIES)
374     message(STATUS "Performing Curl Test ${CURL_TEST}")
375     try_run(${CURL_TEST} ${CURL_TEST}_COMPILE
376       ${CMAKE_BINARY_DIR}
377       ${CURL_SOURCE_DIR}/CMake/CurlTests.c
378       CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
379       "${CURL_TEST_ADD_LIBRARIES}"
380       OUTPUT_VARIABLE OUTPUT)
381     if(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
382       set(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
383       message(STATUS "Performing Curl Test ${CURL_TEST} - Success")
384     else(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
385       message(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
386       set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
387       file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
388         "Performing Curl Test ${CURL_TEST} failed with the following output:\n"
389         "${OUTPUT}")
390       if(${CURL_TEST}_COMPILE)
391         file(APPEND 
392           "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log" 
393           "There was a running problem of this test\n")
394       endif(${CURL_TEST}_COMPILE)
395       file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log" 
396         "\n\n")
397     endif(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
398   endif("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$")
399 endmacro(CURL_INTERNAL_TEST_RUN) 
401 # Do curl specific tests
402 #OPTION(CURL_HAVE_DISABLED_NONBLOCKING "Disable non-blocking socket detection" OFF)
403 set(CURL_NONBLOCKING_TESTS)
404 if(NOT CURL_HAVE_DISABLED_NONBLOCKING)
405   set(CURL_NONBLOCKING_TESTS
406     HAVE_FIONBIO
407     HAVE_IOCTLSOCKET
408     HAVE_IOCTLSOCKET_CASE
409     HAVE_O_NONBLOCK
410     HAVE_SO_NONBLOCK
411     )
412 endif(NOT CURL_HAVE_DISABLED_NONBLOCKING)
413 foreach(CURL_TEST 
414     ${CURL_NONBLOCKING_TESTS}
415     TIME_WITH_SYS_TIME
416     HAVE_O_NONBLOCKHAVE_GETHOSTBYADDR_R_5
417     HAVE_GETHOSTBYADDR_R_7
418     HAVE_GETHOSTBYADDR_R_8
419     HAVE_GETHOSTBYADDR_R_5_REENTRANT
420     HAVE_GETHOSTBYADDR_R_7_REENTRANT
421     HAVE_GETHOSTBYADDR_R_8_REENTRANT
422     HAVE_GETHOSTBYNAME_R_3
423     HAVE_GETHOSTBYNAME_R_5
424     HAVE_GETHOSTBYNAME_R_6
425     HAVE_GETHOSTBYNAME_R_3_REENTRANT
426     HAVE_GETHOSTBYNAME_R_5_REENTRANT
427     HAVE_GETHOSTBYNAME_R_6_REENTRANT
428     HAVE_SOCKLEN_T
429     HAVE_IN_ADDR_T
430     STDC_HEADERS
431     RETSIGTYPE_TEST
432     HAVE_INET_NTOA_R_DECL
433     HAVE_INET_NTOA_R_DECL_REENTRANT
434     HAVE_GETADDRINFO
435     HAVE_FILE_OFFSET_BITS
436     )
437   curl_internal_test(${CURL_TEST})
438 endforeach(CURL_TEST)
439 if(HAVE_FILE_OFFSET_BITS)
440   set(_FILE_OFFSET_BITS 64)
441 endif(HAVE_FILE_OFFSET_BITS)
443 foreach(CURL_TEST 
444     HAVE_GLIBC_STRERROR_R
445     HAVE_POSIX_STRERROR_R
446     )
447   curl_internal_test_run(${CURL_TEST})
448 endforeach(CURL_TEST)
450 # Check for reentrant
451 foreach(CURL_TEST
452     HAVE_GETHOSTBYADDR_R_5
453     HAVE_GETHOSTBYADDR_R_7
454     HAVE_GETHOSTBYADDR_R_8
455     HAVE_GETHOSTBYNAME_R_3
456     HAVE_GETHOSTBYNAME_R_5
457     HAVE_GETHOSTBYNAME_R_6
458     HAVE_INET_NTOA_R_DECL_REENTRANT)
459   if(NOT ${CURL_TEST})
460     if(${CURL_TEST}_REENTRANT)
461       set(NEED_REENTRANT 1)
462     endif(${CURL_TEST}_REENTRANT)
463   endif(NOT ${CURL_TEST})
464 endforeach(CURL_TEST)
466 if(NEED_REENTRANT)
467   foreach(CURL_TEST
468       HAVE_GETHOSTBYADDR_R_5
469       HAVE_GETHOSTBYADDR_R_7
470       HAVE_GETHOSTBYADDR_R_8
471       HAVE_GETHOSTBYNAME_R_3
472       HAVE_GETHOSTBYNAME_R_5
473       HAVE_GETHOSTBYNAME_R_6)
474     set(${CURL_TEST} 0)
475     if(${CURL_TEST}_REENTRANT)
476       set(${CURL_TEST} 1)
477     endif(${CURL_TEST}_REENTRANT)
478   endforeach(CURL_TEST)
479 endif(NEED_REENTRANT)
481 if(HAVE_INET_NTOA_R_DECL_REENTRANT)
482   set(HAVE_INET_NTOA_R_DECL 1)
483   set(NEED_REENTRANT 1)
484 endif(HAVE_INET_NTOA_R_DECL_REENTRANT)
486 # Some other minor tests
488 if(NOT HAVE_SOCKLEN_T)
489   set(socklen_t "int")
490 endif(NOT HAVE_SOCKLEN_T)
492 if(NOT HAVE_IN_ADDR_T)
493   set(in_addr_t "unsigned long")
494 endif(NOT HAVE_IN_ADDR_T)
496 # Fix libz / zlib.h
498 if(NOT CURL_SPECIAL_LIBZ)
499   if(NOT HAVE_LIBZ)
500     set(HAVE_ZLIB_H 0)
501   endif(NOT HAVE_LIBZ)
503   if(NOT HAVE_ZLIB_H)
504     set(HAVE_LIBZ 0)
505   endif(NOT HAVE_ZLIB_H)
506 endif(NOT CURL_SPECIAL_LIBZ)
508 if(_FILE_OFFSET_BITS)
509   set(_FILE_OFFSET_BITS 64)
510 endif(_FILE_OFFSET_BITS)
511 set(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64")
512 set(CMAKE_EXTRA_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/curl/curl.h")
513 check_type_size("curl_off_t" SIZEOF_CURL_OFF_T)
514 set(CMAKE_EXTRA_INCLUDE_FILES)
515 set(CMAKE_REQUIRED_FLAGS)
518 # Check for nonblocking
519 set(HAVE_DISABLED_NONBLOCKING 1)
520 if(HAVE_FIONBIO OR 
521     HAVE_IOCTLSOCKET OR
522     HAVE_IOCTLSOCKET_CASE OR
523     HAVE_O_NONBLOCK)
524   set(HAVE_DISABLED_NONBLOCKING)
525 endif(HAVE_FIONBIO OR 
526   HAVE_IOCTLSOCKET OR
527   HAVE_IOCTLSOCKET_CASE OR
528   HAVE_O_NONBLOCK)
530 if(RETSIGTYPE_TEST)
531   set(RETSIGTYPE void)
532 else(RETSIGTYPE_TEST)
533   set(RETSIGTYPE int)
534 endif(RETSIGTYPE_TEST)
536 if(CMAKE_COMPILER_IS_GNUCC AND APPLE)
537   include(CheckCCompilerFlag)
538   check_c_compiler_flag(-Wno-long-double HAVE_C_FLAG_Wno_long_double)
539   if(HAVE_C_FLAG_Wno_long_double)
540     # The Mac version of GCC warns about use of long double.  Disable it.
541     get_source_file_property(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS)
542     if(MPRINTF_COMPILE_FLAGS)
543       set(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double")
544     else(MPRINTF_COMPILE_FLAGS)
545       set(MPRINTF_COMPILE_FLAGS "-Wno-long-double")
546     endif(MPRINTF_COMPILE_FLAGS)
547     set_source_files_properties(mprintf.c PROPERTIES
548       COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS})
549   endif(HAVE_C_FLAG_Wno_long_double)
550 endif(CMAKE_COMPILER_IS_GNUCC AND APPLE)
551 include(${CURL_SOURCE_DIR}/CMake/OtherTests.cmake)
554 # The rest of the build
556 include_directories(${CURL_SOURCE_DIR})
557 include_directories(${CURL_BINARY_DIR})
558 if(WIN32)
559   set(WIN32_LEAN_AND_MEAN TRUE)
560 endif(WIN32)
562 configure_file(${CURL_SOURCE_DIR}/lib/config.cmake.h.in
563   ${CURL_BINARY_DIR}/lib/config.h)
564 set(CURL_SIZEOF_LONG ${SIZEOF_LONG})
565 configure_file(${CURL_SOURCE_DIR}/include/curl/curlbuild.cmake.h.in
566   ${CURL_BINARY_DIR}/include/curl/curlbuild.h)
567 add_library(cmcurl ${libCurl_SRCS})
568 target_link_libraries(cmcurl ${CURL_LIBS})
570 option(CURL_TESTING "Do libCurl testing" OFF)
571 if(CURL_TESTING)
572   subdirs(Testing)
573 endif(CURL_TESTING)
575 #add_executable(LIBCURL Testing/curltest.c)
576 #target_link_libraries(LIBCURL cmcurl ${CMAKE_DL_LIBS})
577 #add_test(curl "${EXECUTABLE_OUTPUT_PATH}/LIBCURL")