诸暨麻将添加redis
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

865 řádky
33 KiB

  1. # cURL/libcurl CMake script
  2. # by Tetetest and Sukender (Benoit Neil)
  3. # TODO:
  4. # The output .so file lacks the soname number which we currently have within the lib/Makefile.am file
  5. # Add full (4 or 5 libs) SSL support
  6. # Add INSTALL target (EXTRA_DIST variables in Makefile.am may be moved to Makefile.inc so that CMake/CPack is aware of what's to include).
  7. # Add CTests(?)
  8. # Check on all possible platforms
  9. # Test with as many configurations possible (With or without any option)
  10. # Create scripts that help keeping the CMake build system up to date (to reduce maintenance). According to Tetetest:
  11. # - lists of headers that 'configure' checks for;
  12. # - curl-specific tests (the ones that are in m4/curl-*.m4 files);
  13. # - (most obvious thing:) curl version numbers.
  14. # Add documentation subproject
  15. #
  16. # To check:
  17. # (From Daniel Stenberg) The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not.
  18. # (From Daniel Stenberg) The gcc command line use neither -g nor any -O options. As a developer, I also treasure our configure scripts's --enable-debug option that sets a long range of "picky" compiler options.
  19. cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR)
  20. set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
  21. include(Utilities)
  22. project( CURL C )
  23. file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS)
  24. string (REGEX MATCH "LIBCURL_VERSION_MAJOR[ \t]+([0-9]+)"
  25. LIBCURL_VERSION_MJ ${CURL_VERSION_H_CONTENTS})
  26. string (REGEX MATCH "([0-9]+)"
  27. LIBCURL_VERSION_MJ ${LIBCURL_VERSION_MJ})
  28. string (REGEX MATCH
  29. "LIBCURL_VERSION_MINOR[ \t]+([0-9]+)"
  30. LIBCURL_VERSION_MI ${CURL_VERSION_H_CONTENTS})
  31. string (REGEX MATCH "([0-9]+)" LIBCURL_VERSION_MI ${LIBCURL_VERSION_MI})
  32. string (REGEX MATCH
  33. "LIBCURL_VERSION_PATCH[ \t]+([0-9]+)"
  34. LIBCURL_VERSION_PT ${CURL_VERSION_H_CONTENTS})
  35. string (REGEX MATCH "([0-9]+)" LIBCURL_VERSION_PT ${LIBCURL_VERSION_PT})
  36. set (CURL_MAJOR_VERSION ${LIBCURL_VERSION_MJ})
  37. set (CURL_MINOR_VERSION ${LIBCURL_VERSION_MI})
  38. set (CURL_PATCH_VERSION ${LIBCURL_VERSION_PT})
  39. include_regular_expression("^.*$") # Sukender: Is it necessary?
  40. # Setup package meta-data
  41. # SET(PACKAGE "curl")
  42. set(CURL_VERSION ${CURL_MAJOR_VERSION}.${CURL_MINOR_VERSION}.${CURL_PATCH_VERSION})
  43. message(STATUS "curl version=[${CURL_VERSION}]")
  44. # SET(PACKAGE_TARNAME "curl")
  45. # SET(PACKAGE_NAME "curl")
  46. # SET(PACKAGE_VERSION "-")
  47. # SET(PACKAGE_STRING "curl-")
  48. # SET(PACKAGE_BUGREPORT "a suitable curl mailing list => http://curl.haxx.se/mail/")
  49. set(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}")
  50. set(OS "\"${CMAKE_SYSTEM_NAME}\"")
  51. include_directories(${PROJECT_BINARY_DIR}/include/curl)
  52. include_directories( ${CURL_SOURCE_DIR}/include )
  53. option(BUILD_CURL_EXE "Set to ON to build cURL executable." ON)
  54. option(BUILD_CURL_TESTS "Set to ON to build cURL tests." ON)
  55. option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF)
  56. option(CURL_USE_ARES "Set to ON to enable c-ares support" OFF)
  57. # initialize CURL_LIBS
  58. set(CURL_LIBS "")
  59. if(CURL_USE_ARES)
  60. set(USE_ARES ${CURL_USE_ARES})
  61. find_package(CARES REQUIRED)
  62. list(APPEND CURL_LIBS ${CARES_LIBRARY} )
  63. set(CURL_LIBS ${CURL_LIBS} ${CARES_LIBRARY})
  64. endif()
  65. option(BUILD_DASHBOARD_REPORTS "Set to ON to activate reporting of cURL builds here http://www.cdash.org/CDashPublic/index.php?project=CURL" OFF)
  66. if(BUILD_DASHBOARD_REPORTS)
  67. #INCLUDE(Dart)
  68. include(CTest)
  69. endif(BUILD_DASHBOARD_REPORTS)
  70. if(MSVC)
  71. option(BUILD_RELEASE_DEBUG_DIRS "Set OFF to build each configuration to a separate directory" OFF)
  72. mark_as_advanced(BUILD_RELEASE_DEBUG_DIRS)
  73. endif()
  74. option(CURL_HIDDEN_SYMBOLS "Set to ON to hide libcurl internal symbols (=hide all symbols that aren't officially external)." ON)
  75. mark_as_advanced(CURL_HIDDEN_SYMBOLS)
  76. # IF(WIN32)
  77. # OPTION(CURL_WINDOWS_SSPI "Use windows libraries to allow NTLM authentication without openssl" ON)
  78. # MARK_AS_ADVANCED(CURL_WINDOWS_SSPI)
  79. # ENDIF()
  80. option(HTTP_ONLY "disables all protocols except HTTP (This overrides all CURL_DISABLE_* options)" OFF)
  81. mark_as_advanced(HTTP_ONLY)
  82. option(CURL_DISABLE_FTP "disables FTP" OFF)
  83. mark_as_advanced(CURL_DISABLE_FTP)
  84. option(CURL_DISABLE_LDAP "disables LDAP" OFF)
  85. mark_as_advanced(CURL_DISABLE_LDAP)
  86. option(CURL_DISABLE_TELNET "disables Telnet" OFF)
  87. mark_as_advanced(CURL_DISABLE_TELNET)
  88. option(CURL_DISABLE_DICT "disables DICT" OFF)
  89. mark_as_advanced(CURL_DISABLE_DICT)
  90. option(CURL_DISABLE_FILE "disables FILE" OFF)
  91. mark_as_advanced(CURL_DISABLE_FILE)
  92. option(CURL_DISABLE_TFTP "disables TFTP" OFF)
  93. mark_as_advanced(CURL_DISABLE_TFTP)
  94. option(CURL_DISABLE_HTTP "disables HTTP" OFF)
  95. mark_as_advanced(CURL_DISABLE_HTTP)
  96. option(CURL_DISABLE_LDAPS "to disable LDAPS" OFF)
  97. mark_as_advanced(CURL_DISABLE_LDAPS)
  98. if(HTTP_ONLY)
  99. set(CURL_DISABLE_FTP ON)
  100. set(CURL_DISABLE_LDAP ON)
  101. set(CURL_DISABLE_LDAPS ON)
  102. set(CURL_DISABLE_TELNET ON)
  103. set(CURL_DISABLE_DICT ON)
  104. set(CURL_DISABLE_FILE ON)
  105. set(CURL_DISABLE_TFTP ON)
  106. endif()
  107. option(CURL_DISABLE_COOKIES "to disable cookies support" OFF)
  108. mark_as_advanced(CURL_DISABLE_COOKIES)
  109. option(CURL_DISABLE_CRYPTO_AUTH "to disable cryptographic authentication" OFF)
  110. mark_as_advanced(CURL_DISABLE_CRYPTO_AUTH)
  111. option(CURL_DISABLE_VERBOSE_STRINGS "to disable verbose strings" OFF)
  112. mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS)
  113. option(DISABLED_THREADSAFE "Set to explicitly specify we don't want to use thread-safe functions" OFF)
  114. mark_as_advanced(DISABLED_THREADSAFE)
  115. option(ENABLE_IPV6 "Define if you want to enable IPv6 support" OFF)
  116. mark_as_advanced(ENABLE_IPV6)
  117. # We need ansi c-flags, especially on HP
  118. set(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
  119. set(CMAKE_REQUIRED_FLAGS ${CMAKE_ANSI_CFLAGS})
  120. # Disable warnings on Borland to avoid changing 3rd party code.
  121. if(BORLAND)
  122. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")
  123. endif(BORLAND)
  124. # If we are on AIX, do the _ALL_SOURCE magic
  125. if(${CMAKE_SYSTEM_NAME} MATCHES AIX)
  126. set(_ALL_SOURCE 1)
  127. endif(${CMAKE_SYSTEM_NAME} MATCHES AIX)
  128. # Include all the necessary files for macros
  129. include (CheckFunctionExists)
  130. include (CheckIncludeFile)
  131. include (CheckIncludeFiles)
  132. include (CheckLibraryExists)
  133. include (CheckSymbolExists)
  134. include (CheckTypeSize)
  135. # On windows preload settings
  136. if(WIN32)
  137. include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Platforms/WindowsCache.cmake)
  138. endif(WIN32)
  139. # This macro checks if the symbol exists in the library and if it
  140. # does, it prepends library to the list.
  141. macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE)
  142. check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "${CMAKE_LIBRARY_PATH}"
  143. ${VARIABLE})
  144. if(${VARIABLE})
  145. set(CURL_LIBS ${LIBRARY} ${CURL_LIBS})
  146. endif(${VARIABLE})
  147. endmacro(CHECK_LIBRARY_EXISTS_CONCAT)
  148. # Check for all needed libraries
  149. check_library_exists_concat("dl" dlopen HAVE_LIBDL)
  150. check_library_exists_concat("socket" connect HAVE_LIBSOCKET)
  151. check_library_exists("c" gethostbyname "" NOT_NEED_LIBNSL)
  152. # Yellowtab Zeta needs different libraries than BeOS 5.
  153. if(BEOS)
  154. set(NOT_NEED_LIBNSL 1)
  155. check_library_exists_concat("bind" gethostbyname HAVE_LIBBIND)
  156. check_library_exists_concat("bnetapi" closesocket HAVE_LIBBNETAPI)
  157. endif(BEOS)
  158. if(NOT NOT_NEED_LIBNSL)
  159. check_library_exists_concat("nsl" gethostbyname HAVE_LIBNSL)
  160. endif(NOT NOT_NEED_LIBNSL)
  161. check_library_exists_concat("ws2_32" getch HAVE_LIBWS2_32)
  162. check_library_exists_concat("winmm" getch HAVE_LIBWINMM)
  163. check_library_exists("wldap32" cldap_open "" HAVE_WLDAP32)
  164. if(WIN32)
  165. set(CURL_DEFAULT_DISABLE_LDAP OFF)
  166. # some windows compilers do not have wldap32
  167. if(NOT HAVE_WLDAP32)
  168. set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
  169. message(STATUS "wldap32 not found CURL_DISABLE_LDAP set ON")
  170. option(CURL_LDAP_WIN "Use Windows LDAP implementation" OFF)
  171. else()
  172. option(CURL_LDAP_WIN "Use Windows LDAP implementation" ON)
  173. endif()
  174. mark_as_advanced(CURL_LDAP_WIN)
  175. endif()
  176. # IF(NOT CURL_SPECIAL_LIBZ)
  177. # CHECK_LIBRARY_EXISTS_CONCAT("z" inflateEnd HAVE_LIBZ)
  178. # ENDIF(NOT CURL_SPECIAL_LIBZ)
  179. # Check for idn
  180. check_library_exists_concat("idn" idna_to_ascii_lz HAVE_LIBIDN)
  181. # Check for LDAP
  182. check_library_exists_concat("ldap" ldap_init HAVE_LIBLDAP)
  183. # if(NOT HAVE_LIBLDAP)
  184. # SET(CURL_DISABLE_LDAP ON)
  185. # endif(NOT HAVE_LIBLDAP)
  186. # Check for symbol dlopen (same as HAVE_LIBDL)
  187. check_library_exists("${CURL_LIBS}" dlopen "" HAVE_DLOPEN)
  188. # For other tests to use the same libraries
  189. set(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBS})
  190. option(CURL_ZLIB "Set to ON to enable building cURL with zlib support." ON)
  191. set(HAVE_LIBZ OFF)
  192. set(HAVE_ZLIB_H OFF)
  193. set(HAVE_ZLIB OFF)
  194. if(CURL_ZLIB) # AND CURL_CONFIG_HAS_BEEN_RUN_BEFORE
  195. find_package(ZLIB QUIET)
  196. if(ZLIB_FOUND)
  197. set(HAVE_ZLIB_H ON)
  198. set(HAVE_ZLIB ON)
  199. set(HAVE_LIBZ ON)
  200. list(APPEND CURL_LIBS ${ZLIB_LIBRARIES})
  201. endif()
  202. endif()
  203. option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON)
  204. mark_as_advanced(CMAKE_USE_OPENSSL)
  205. if(CMAKE_USE_OPENSSL)
  206. set(USE_SSLEAY OFF)
  207. set(USE_OPENSSL OFF)
  208. set(HAVE_LIBCRYPTO OFF)
  209. set(HAVE_LIBSSL OFF)
  210. find_package(OpenSSL)
  211. if(OPENSSL_FOUND)
  212. list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})
  213. list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
  214. set(USE_SSLEAY ON)
  215. set(USE_OPENSSL ON)
  216. set(HAVE_LIBCRYPTO ON)
  217. set(HAVE_LIBSSL ON)
  218. endif(OPENSSL_FOUND)
  219. endif(CMAKE_USE_OPENSSL)
  220. # If we have features.h, then do the _BSD_SOURCE magic
  221. check_include_file("features.h" HAVE_FEATURES_H)
  222. # Check if header file exists and add it to the list.
  223. macro(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE)
  224. check_include_files("${CURL_INCLUDES};${FILE}" ${VARIABLE})
  225. if(${VARIABLE})
  226. set(CURL_INCLUDES ${CURL_INCLUDES} ${FILE})
  227. set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -D${VARIABLE}")
  228. endif(${VARIABLE})
  229. endmacro(CHECK_INCLUDE_FILE_CONCAT)
  230. # Check for header files
  231. if(NOT UNIX)
  232. check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H)
  233. check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H)
  234. endif(NOT UNIX)
  235. check_include_file_concat("stdio.h" HAVE_STDIO_H)
  236. if(NOT UNIX)
  237. check_include_file_concat("windows.h" HAVE_WINDOWS_H)
  238. check_include_file_concat("winsock.h" HAVE_WINSOCK_H)
  239. endif(NOT UNIX)
  240. check_include_file_concat("inttypes.h" HAVE_INTTYPES_H)
  241. check_include_file_concat("sys/filio.h" HAVE_SYS_FILIO_H)
  242. check_include_file_concat("sys/ioctl.h" HAVE_SYS_IOCTL_H)
  243. check_include_file_concat("sys/param.h" HAVE_SYS_PARAM_H)
  244. check_include_file_concat("sys/poll.h" HAVE_SYS_POLL_H)
  245. check_include_file_concat("sys/resource.h" HAVE_SYS_RESOURCE_H)
  246. check_include_file_concat("sys/select.h" HAVE_SYS_SELECT_H)
  247. check_include_file_concat("sys/socket.h" HAVE_SYS_SOCKET_H)
  248. check_include_file_concat("sys/sockio.h" HAVE_SYS_SOCKIO_H)
  249. check_include_file_concat("sys/stat.h" HAVE_SYS_STAT_H)
  250. check_include_file_concat("sys/time.h" HAVE_SYS_TIME_H)
  251. check_include_file_concat("sys/types.h" HAVE_SYS_TYPES_H)
  252. check_include_file_concat("sys/uio.h" HAVE_SYS_UIO_H)
  253. check_include_file_concat("sys/un.h" HAVE_SYS_UN_H)
  254. check_include_file_concat("sys/utime.h" HAVE_SYS_UTIME_H)
  255. check_include_file_concat("alloca.h" HAVE_ALLOCA_H)
  256. check_include_file_concat("arpa/inet.h" HAVE_ARPA_INET_H)
  257. check_include_file_concat("arpa/tftp.h" HAVE_ARPA_TFTP_H)
  258. check_include_file_concat("assert.h" HAVE_ASSERT_H)
  259. check_include_file_concat("crypto.h" HAVE_CRYPTO_H)
  260. check_include_file_concat("des.h" HAVE_DES_H)
  261. check_include_file_concat("err.h" HAVE_ERR_H)
  262. check_include_file_concat("errno.h" HAVE_ERRNO_H)
  263. check_include_file_concat("fcntl.h" HAVE_FCNTL_H)
  264. check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H)
  265. check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H)
  266. check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H)
  267. check_include_file_concat("idn-free.h" HAVE_IDN_FREE_H)
  268. check_include_file_concat("ifaddrs.h" HAVE_IFADDRS_H)
  269. check_include_file_concat("io.h" HAVE_IO_H)
  270. check_include_file_concat("krb.h" HAVE_KRB_H)
  271. check_include_file_concat("libgen.h" HAVE_LIBGEN_H)
  272. check_include_file_concat("libssh2.h" HAVE_LIBSSH2_H)
  273. check_include_file_concat("limits.h" HAVE_LIMITS_H)
  274. check_include_file_concat("locale.h" HAVE_LOCALE_H)
  275. check_include_file_concat("net/if.h" HAVE_NET_IF_H)
  276. check_include_file_concat("netdb.h" HAVE_NETDB_H)
  277. check_include_file_concat("netinet/in.h" HAVE_NETINET_IN_H)
  278. check_include_file_concat("netinet/tcp.h" HAVE_NETINET_TCP_H)
  279. if(CMAKE_USE_OPENSSL AND OPENSSL_FOUND)
  280. check_include_file_concat("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H)
  281. check_include_file_concat("openssl/engine.h" HAVE_OPENSSL_ENGINE_H)
  282. check_include_file_concat("openssl/err.h" HAVE_OPENSSL_ERR_H)
  283. check_include_file_concat("openssl/pem.h" HAVE_OPENSSL_PEM_H)
  284. check_include_file_concat("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H)
  285. check_include_file_concat("openssl/rsa.h" HAVE_OPENSSL_RSA_H)
  286. check_include_file_concat("openssl/ssl.h" HAVE_OPENSSL_SSL_H)
  287. check_include_file_concat("openssl/x509.h" HAVE_OPENSSL_X509_H)
  288. check_include_file_concat("openssl/rand.h" HAVE_OPENSSL_RAND_H)
  289. endif(CMAKE_USE_OPENSSL AND OPENSSL_FOUND)
  290. check_include_file_concat("pem.h" HAVE_PEM_H)
  291. check_include_file_concat("poll.h" HAVE_POLL_H)
  292. check_include_file_concat("pwd.h" HAVE_PWD_H)
  293. check_include_file_concat("rsa.h" HAVE_RSA_H)
  294. check_include_file_concat("setjmp.h" HAVE_SETJMP_H)
  295. check_include_file_concat("sgtty.h" HAVE_SGTTY_H)
  296. check_include_file_concat("signal.h" HAVE_SIGNAL_H)
  297. check_include_file_concat("ssl.h" HAVE_SSL_H)
  298. check_include_file_concat("stdbool.h" HAVE_STDBOOL_H)
  299. check_include_file_concat("stdint.h" HAVE_STDINT_H)
  300. check_include_file_concat("stdio.h" HAVE_STDIO_H)
  301. check_include_file_concat("stdlib.h" HAVE_STDLIB_H)
  302. check_include_file_concat("string.h" HAVE_STRING_H)
  303. check_include_file_concat("strings.h" HAVE_STRINGS_H)
  304. check_include_file_concat("stropts.h" HAVE_STROPTS_H)
  305. check_include_file_concat("termio.h" HAVE_TERMIO_H)
  306. check_include_file_concat("termios.h" HAVE_TERMIOS_H)
  307. check_include_file_concat("time.h" HAVE_TIME_H)
  308. check_include_file_concat("tld.h" HAVE_TLD_H)
  309. check_include_file_concat("unistd.h" HAVE_UNISTD_H)
  310. check_include_file_concat("utime.h" HAVE_UTIME_H)
  311. check_include_file_concat("x509.h" HAVE_X509_H)
  312. check_include_file_concat("process.h" HAVE_PROCESS_H)
  313. check_include_file_concat("stddef.h" HAVE_STDDEF_H)
  314. check_include_file_concat("dlfcn.h" HAVE_DLFCN_H)
  315. check_include_file_concat("malloc.h" HAVE_MALLOC_H)
  316. check_include_file_concat("memory.h" HAVE_MEMORY_H)
  317. check_include_file_concat("ldap.h" HAVE_LDAP_H)
  318. check_include_file_concat("netinet/if_ether.h" HAVE_NETINET_IF_ETHER_H)
  319. check_include_file_concat("stdint.h" HAVE_STDINT_H)
  320. check_include_file_concat("sockio.h" HAVE_SOCKIO_H)
  321. check_include_file_concat("sys/utsname.h" HAVE_SYS_UTSNAME_H)
  322. check_include_file_concat("idna.h" HAVE_IDNA_H)
  323. if(NOT HAVE_LDAP_H)
  324. message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON")
  325. set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
  326. endif()
  327. # No ldap, no ldaps.
  328. if(CURL_DISABLE_LDAP)
  329. if(NOT CURL_DISABLE_LDAPS)
  330. message(STATUS "LDAP needs to be enabled to support LDAPS")
  331. set(CURL_DISABLE_LDAPS ON CACHE BOOL "" FORCE)
  332. endif()
  333. endif()
  334. check_type_size(size_t SIZEOF_SIZE_T)
  335. check_type_size(ssize_t SIZEOF_SSIZE_T)
  336. check_type_size("long long" SIZEOF_LONG_LONG)
  337. check_type_size("long" SIZEOF_LONG)
  338. check_type_size("short" SIZEOF_SHORT)
  339. check_type_size("int" SIZEOF_INT)
  340. check_type_size("__int64" SIZEOF___INT64)
  341. check_type_size("long double" SIZEOF_LONG_DOUBLE)
  342. check_type_size("time_t" SIZEOF_TIME_T)
  343. if(NOT HAVE_SIZEOF_SSIZE_T)
  344. if(SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
  345. set(ssize_t long)
  346. endif(SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
  347. if(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
  348. set(ssize_t __int64)
  349. endif(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
  350. endif(NOT HAVE_SIZEOF_SSIZE_T)
  351. # Different sizeofs, etc.
  352. # define CURL_SIZEOF_LONG 4
  353. # define CURL_TYPEOF_CURL_OFF_T long long
  354. # define CURL_FORMAT_CURL_OFF_T "lld"
  355. # define CURL_FORMAT_CURL_OFF_TU "llu"
  356. # define CURL_FORMAT_OFF_T "%lld"
  357. # define CURL_SIZEOF_CURL_OFF_T 8
  358. # define CURL_SUFFIX_CURL_OFF_T LL
  359. # define CURL_SUFFIX_CURL_OFF_TU ULL
  360. set(CURL_SIZEOF_LONG ${SIZEOF_LONG})
  361. if(SIZEOF_LONG EQUAL 8)
  362. set(CURL_TYPEOF_CURL_OFF_T long)
  363. set(CURL_SIZEOF_CURL_OFF_T 8)
  364. set(CURL_FORMAT_CURL_OFF_T "ld")
  365. set(CURL_FORMAT_CURL_OFF_TU "lu")
  366. set(CURL_FORMAT_OFF_T "%ld")
  367. set(CURL_SUFFIX_CURL_OFF_T L)
  368. set(CURL_SUFFIX_CURL_OFF_TU UL)
  369. endif(SIZEOF_LONG EQUAL 8)
  370. if(SIZEOF_LONG_LONG EQUAL 8)
  371. set(CURL_TYPEOF_CURL_OFF_T "long long")
  372. set(CURL_SIZEOF_CURL_OFF_T 8)
  373. set(CURL_FORMAT_CURL_OFF_T "lld")
  374. set(CURL_FORMAT_CURL_OFF_TU "llu")
  375. set(CURL_FORMAT_OFF_T "%lld")
  376. set(CURL_SUFFIX_CURL_OFF_T LL)
  377. set(CURL_SUFFIX_CURL_OFF_TU ULL)
  378. endif(SIZEOF_LONG_LONG EQUAL 8)
  379. if(NOT CURL_TYPEOF_CURL_OFF_T)
  380. set(CURL_TYPEOF_CURL_OFF_T ${ssize_t})
  381. set(CURL_SIZEOF_CURL_OFF_T ${SIZEOF_SSIZE_T})
  382. # TODO: need adjustment here.
  383. set(CURL_FORMAT_CURL_OFF_T "ld")
  384. set(CURL_FORMAT_CURL_OFF_TU "lu")
  385. set(CURL_FORMAT_OFF_T "%ld")
  386. set(CURL_SUFFIX_CURL_OFF_T L)
  387. set(CURL_SUFFIX_CURL_OFF_TU LU)
  388. endif(NOT CURL_TYPEOF_CURL_OFF_T)
  389. if(HAVE_SIZEOF_LONG_LONG)
  390. set(HAVE_LONGLONG 1)
  391. set(HAVE_LL 1)
  392. endif(HAVE_SIZEOF_LONG_LONG)
  393. find_file(RANDOM_FILE urandom /dev)
  394. mark_as_advanced(RANDOM_FILE)
  395. # Check for some functions that are used
  396. check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME)
  397. check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET)
  398. check_symbol_exists(poll "${CURL_INCLUDES}" HAVE_POLL)
  399. check_symbol_exists(select "${CURL_INCLUDES}" HAVE_SELECT)
  400. check_symbol_exists(strdup "${CURL_INCLUDES}" HAVE_STRDUP)
  401. check_symbol_exists(strstr "${CURL_INCLUDES}" HAVE_STRSTR)
  402. check_symbol_exists(strtok_r "${CURL_INCLUDES}" HAVE_STRTOK_R)
  403. check_symbol_exists(strftime "${CURL_INCLUDES}" HAVE_STRFTIME)
  404. check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME)
  405. check_symbol_exists(strcasecmp "${CURL_INCLUDES}" HAVE_STRCASECMP)
  406. check_symbol_exists(stricmp "${CURL_INCLUDES}" HAVE_STRICMP)
  407. check_symbol_exists(strcmpi "${CURL_INCLUDES}" HAVE_STRCMPI)
  408. check_symbol_exists(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI)
  409. check_symbol_exists(alarm "${CURL_INCLUDES}" HAVE_ALARM)
  410. if(NOT HAVE_STRNCMPI)
  411. set(HAVE_STRCMPI)
  412. endif(NOT HAVE_STRNCMPI)
  413. check_symbol_exists(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR)
  414. check_symbol_exists(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R)
  415. check_symbol_exists(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY)
  416. check_symbol_exists(inet_addr "${CURL_INCLUDES}" HAVE_INET_ADDR)
  417. check_symbol_exists(inet_ntoa "${CURL_INCLUDES}" HAVE_INET_NTOA)
  418. check_symbol_exists(inet_ntoa_r "${CURL_INCLUDES}" HAVE_INET_NTOA_R)
  419. check_symbol_exists(tcsetattr "${CURL_INCLUDES}" HAVE_TCSETATTR)
  420. check_symbol_exists(tcgetattr "${CURL_INCLUDES}" HAVE_TCGETATTR)
  421. check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR)
  422. check_symbol_exists(closesocket "${CURL_INCLUDES}" HAVE_CLOSESOCKET)
  423. check_symbol_exists(setvbuf "${CURL_INCLUDES}" HAVE_SETVBUF)
  424. check_symbol_exists(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP)
  425. check_symbol_exists(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R)
  426. check_symbol_exists(strlcat "${CURL_INCLUDES}" HAVE_STRLCAT)
  427. check_symbol_exists(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID)
  428. check_symbol_exists(geteuid "${CURL_INCLUDES}" HAVE_GETEUID)
  429. check_symbol_exists(utime "${CURL_INCLUDES}" HAVE_UTIME)
  430. if(CMAKE_USE_OPENSSL)
  431. check_symbol_exists(RAND_status "${CURL_INCLUDES}" HAVE_RAND_STATUS)
  432. check_symbol_exists(RAND_screen "${CURL_INCLUDES}" HAVE_RAND_SCREEN)
  433. check_symbol_exists(RAND_egd "${CURL_INCLUDES}" HAVE_RAND_EGD)
  434. check_symbol_exists(CRYPTO_cleanup_all_ex_data "${CURL_INCLUDES}"
  435. HAVE_CRYPTO_CLEANUP_ALL_EX_DATA)
  436. if(HAVE_LIBCRYPTO AND HAVE_LIBSSL)
  437. set(USE_OPENSSL 1)
  438. set(USE_SSLEAY 1)
  439. endif(HAVE_LIBCRYPTO AND HAVE_LIBSSL)
  440. endif(CMAKE_USE_OPENSSL)
  441. check_symbol_exists(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R)
  442. check_symbol_exists(localtime_r "${CURL_INCLUDES}" HAVE_LOCALTIME_R)
  443. check_symbol_exists(gethostbyname "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME)
  444. check_symbol_exists(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R)
  445. check_symbol_exists(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC)
  446. check_symbol_exists(SIGALRM "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO)
  447. if(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
  448. set(HAVE_SIGNAL 1)
  449. endif(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
  450. check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME)
  451. check_symbol_exists(strtoll "${CURL_INCLUDES}" HAVE_STRTOLL)
  452. check_symbol_exists(_strtoi64 "${CURL_INCLUDES}" HAVE__STRTOI64)
  453. check_symbol_exists(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R)
  454. check_symbol_exists(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT)
  455. check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR)
  456. check_symbol_exists(fork "${CURL_INCLUDES}" HAVE_FORK)
  457. check_symbol_exists(freeaddrinfo "${CURL_INCLUDES}" HAVE_FREEADDRINFO)
  458. check_symbol_exists(freeifaddrs "${CURL_INCLUDES}" HAVE_FREEIFADDRS)
  459. check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE)
  460. check_symbol_exists(ftruncate "${CURL_INCLUDES}" HAVE_FTRUNCATE)
  461. check_symbol_exists(getprotobyname "${CURL_INCLUDES}" HAVE_GETPROTOBYNAME)
  462. check_symbol_exists(getrlimit "${CURL_INCLUDES}" HAVE_GETRLIMIT)
  463. check_symbol_exists(idn_free "${CURL_INCLUDES}" HAVE_IDN_FREE)
  464. check_symbol_exists(idna_strerror "${CURL_INCLUDES}" HAVE_IDNA_STRERROR)
  465. check_symbol_exists(tld_strerror "${CURL_INCLUDES}" HAVE_TLD_STRERROR)
  466. check_symbol_exists(setlocale "${CURL_INCLUDES}" HAVE_SETLOCALE)
  467. check_symbol_exists(setrlimit "${CURL_INCLUDES}" HAVE_SETRLIMIT)
  468. check_symbol_exists(fcntl "${CURL_INCLUDES}" HAVE_FCNTL)
  469. check_symbol_exists(ioctl "${CURL_INCLUDES}" HAVE_IOCTL)
  470. check_symbol_exists(setsockopt "${CURL_INCLUDES}" HAVE_SETSOCKOPT)
  471. # symbol exists in win32, but function does not.
  472. check_function_exists(inet_pton HAVE_INET_PTON)
  473. # sigaction and sigsetjmp are special. Use special mechanism for
  474. # detecting those, but only if previous attempt failed.
  475. if(HAVE_SIGNAL_H)
  476. check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
  477. endif(HAVE_SIGNAL_H)
  478. if(NOT HAVE_SIGSETJMP)
  479. if(HAVE_SETJMP_H)
  480. check_symbol_exists(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP)
  481. if(HAVE_MACRO_SIGSETJMP)
  482. set(HAVE_SIGSETJMP 1)
  483. endif(HAVE_MACRO_SIGSETJMP)
  484. endif(HAVE_SETJMP_H)
  485. endif(NOT HAVE_SIGSETJMP)
  486. # If there is no stricmp(), do not allow LDAP to parse URLs
  487. if(NOT HAVE_STRICMP)
  488. set(HAVE_LDAP_URL_PARSE 1)
  489. endif(NOT HAVE_STRICMP)
  490. # For other curl specific tests, use this macro.
  491. macro(CURL_INTERNAL_TEST CURL_TEST)
  492. if("${CURL_TEST}" MATCHES "^${CURL_TEST}$")
  493. set(MACRO_CHECK_FUNCTION_DEFINITIONS
  494. "-D${CURL_TEST} ${CURL_TEST_DEFINES} ${CMAKE_REQUIRED_FLAGS}")
  495. if(CMAKE_REQUIRED_LIBRARIES)
  496. set(CURL_TEST_ADD_LIBRARIES
  497. "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
  498. endif(CMAKE_REQUIRED_LIBRARIES)
  499. message(STATUS "Performing Curl Test ${CURL_TEST}")
  500. try_compile(${CURL_TEST}
  501. ${CMAKE_BINARY_DIR}
  502. ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CurlTests.c
  503. CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
  504. "${CURL_TEST_ADD_LIBRARIES}"
  505. OUTPUT_VARIABLE OUTPUT)
  506. if(${CURL_TEST})
  507. set(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
  508. message(STATUS "Performing Curl Test ${CURL_TEST} - Success")
  509. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  510. "Performing Curl Test ${CURL_TEST} passed with the following output:\n"
  511. "${OUTPUT}\n")
  512. else(${CURL_TEST})
  513. message(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
  514. set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
  515. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  516. "Performing Curl Test ${CURL_TEST} failed with the following output:\n"
  517. "${OUTPUT}\n")
  518. endif(${CURL_TEST})
  519. endif("${CURL_TEST}" MATCHES "^${CURL_TEST}$")
  520. endmacro(CURL_INTERNAL_TEST)
  521. macro(CURL_INTERNAL_TEST_RUN CURL_TEST)
  522. if("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$")
  523. set(MACRO_CHECK_FUNCTION_DEFINITIONS
  524. "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}")
  525. if(CMAKE_REQUIRED_LIBRARIES)
  526. set(CURL_TEST_ADD_LIBRARIES
  527. "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
  528. endif(CMAKE_REQUIRED_LIBRARIES)
  529. message(STATUS "Performing Curl Test ${CURL_TEST}")
  530. try_run(${CURL_TEST} ${CURL_TEST}_COMPILE
  531. ${CMAKE_BINARY_DIR}
  532. ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CurlTests.c
  533. CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
  534. "${CURL_TEST_ADD_LIBRARIES}"
  535. OUTPUT_VARIABLE OUTPUT)
  536. if(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
  537. set(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
  538. message(STATUS "Performing Curl Test ${CURL_TEST} - Success")
  539. else(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
  540. message(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
  541. set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
  542. file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
  543. "Performing Curl Test ${CURL_TEST} failed with the following output:\n"
  544. "${OUTPUT}")
  545. if(${CURL_TEST}_COMPILE)
  546. file(APPEND
  547. "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
  548. "There was a problem running this test\n")
  549. endif(${CURL_TEST}_COMPILE)
  550. file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
  551. "\n\n")
  552. endif(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
  553. endif("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$")
  554. endmacro(CURL_INTERNAL_TEST_RUN)
  555. # Do curl specific tests
  556. foreach(CURL_TEST
  557. HAVE_FCNTL_O_NONBLOCK
  558. HAVE_IOCTLSOCKET
  559. HAVE_IOCTLSOCKET_CAMEL
  560. HAVE_IOCTLSOCKET_CAMEL_FIONBIO
  561. HAVE_IOCTLSOCKET_FIONBIO
  562. HAVE_IOCTL_FIONBIO
  563. HAVE_IOCTL_SIOCGIFADDR
  564. HAVE_SETSOCKOPT_SO_NONBLOCK
  565. HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
  566. TIME_WITH_SYS_TIME
  567. HAVE_O_NONBLOCK
  568. HAVE_GETHOSTBYADDR_R_5
  569. HAVE_GETHOSTBYADDR_R_7
  570. HAVE_GETHOSTBYADDR_R_8
  571. HAVE_GETHOSTBYADDR_R_5_REENTRANT
  572. HAVE_GETHOSTBYADDR_R_7_REENTRANT
  573. HAVE_GETHOSTBYADDR_R_8_REENTRANT
  574. HAVE_GETHOSTBYNAME_R_3
  575. HAVE_GETHOSTBYNAME_R_5
  576. HAVE_GETHOSTBYNAME_R_6
  577. HAVE_GETHOSTBYNAME_R_3_REENTRANT
  578. HAVE_GETHOSTBYNAME_R_5_REENTRANT
  579. HAVE_GETHOSTBYNAME_R_6_REENTRANT
  580. HAVE_SOCKLEN_T
  581. HAVE_IN_ADDR_T
  582. HAVE_BOOL_T
  583. STDC_HEADERS
  584. RETSIGTYPE_TEST
  585. HAVE_INET_NTOA_R_DECL
  586. HAVE_INET_NTOA_R_DECL_REENTRANT
  587. HAVE_GETADDRINFO
  588. HAVE_FILE_OFFSET_BITS
  589. )
  590. curl_internal_test(${CURL_TEST})
  591. endforeach(CURL_TEST)
  592. if(HAVE_FILE_OFFSET_BITS)
  593. set(_FILE_OFFSET_BITS 64)
  594. endif(HAVE_FILE_OFFSET_BITS)
  595. foreach(CURL_TEST
  596. HAVE_GLIBC_STRERROR_R
  597. HAVE_POSIX_STRERROR_R
  598. )
  599. curl_internal_test_run(${CURL_TEST})
  600. endforeach(CURL_TEST)
  601. # Check for reentrant
  602. foreach(CURL_TEST
  603. HAVE_GETHOSTBYADDR_R_5
  604. HAVE_GETHOSTBYADDR_R_7
  605. HAVE_GETHOSTBYADDR_R_8
  606. HAVE_GETHOSTBYNAME_R_3
  607. HAVE_GETHOSTBYNAME_R_5
  608. HAVE_GETHOSTBYNAME_R_6
  609. HAVE_INET_NTOA_R_DECL_REENTRANT)
  610. if(NOT ${CURL_TEST})
  611. if(${CURL_TEST}_REENTRANT)
  612. set(NEED_REENTRANT 1)
  613. endif(${CURL_TEST}_REENTRANT)
  614. endif(NOT ${CURL_TEST})
  615. endforeach(CURL_TEST)
  616. if(NEED_REENTRANT)
  617. foreach(CURL_TEST
  618. HAVE_GETHOSTBYADDR_R_5
  619. HAVE_GETHOSTBYADDR_R_7
  620. HAVE_GETHOSTBYADDR_R_8
  621. HAVE_GETHOSTBYNAME_R_3
  622. HAVE_GETHOSTBYNAME_R_5
  623. HAVE_GETHOSTBYNAME_R_6)
  624. set(${CURL_TEST} 0)
  625. if(${CURL_TEST}_REENTRANT)
  626. set(${CURL_TEST} 1)
  627. endif(${CURL_TEST}_REENTRANT)
  628. endforeach(CURL_TEST)
  629. endif(NEED_REENTRANT)
  630. if(HAVE_INET_NTOA_R_DECL_REENTRANT)
  631. set(HAVE_INET_NTOA_R_DECL 1)
  632. set(NEED_REENTRANT 1)
  633. endif(HAVE_INET_NTOA_R_DECL_REENTRANT)
  634. # Some other minor tests
  635. if(NOT HAVE_IN_ADDR_T)
  636. set(in_addr_t "unsigned long")
  637. endif(NOT HAVE_IN_ADDR_T)
  638. # Fix libz / zlib.h
  639. if(NOT CURL_SPECIAL_LIBZ)
  640. if(NOT HAVE_LIBZ)
  641. set(HAVE_ZLIB_H 0)
  642. endif(NOT HAVE_LIBZ)
  643. if(NOT HAVE_ZLIB_H)
  644. set(HAVE_LIBZ 0)
  645. endif(NOT HAVE_ZLIB_H)
  646. endif(NOT CURL_SPECIAL_LIBZ)
  647. if(_FILE_OFFSET_BITS)
  648. set(_FILE_OFFSET_BITS 64)
  649. endif(_FILE_OFFSET_BITS)
  650. set(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64")
  651. set(CMAKE_EXTRA_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/curl/curl.h")
  652. check_type_size("curl_off_t" SIZEOF_CURL_OFF_T)
  653. set(CMAKE_EXTRA_INCLUDE_FILES)
  654. set(CMAKE_REQUIRED_FLAGS)
  655. # Check for nonblocking
  656. set(HAVE_DISABLED_NONBLOCKING 1)
  657. if(HAVE_FIONBIO OR
  658. HAVE_IOCTLSOCKET OR
  659. HAVE_IOCTLSOCKET_CASE OR
  660. HAVE_O_NONBLOCK)
  661. set(HAVE_DISABLED_NONBLOCKING)
  662. endif(HAVE_FIONBIO OR
  663. HAVE_IOCTLSOCKET OR
  664. HAVE_IOCTLSOCKET_CASE OR
  665. HAVE_O_NONBLOCK)
  666. if(RETSIGTYPE_TEST)
  667. set(RETSIGTYPE void)
  668. else(RETSIGTYPE_TEST)
  669. set(RETSIGTYPE int)
  670. endif(RETSIGTYPE_TEST)
  671. if(CMAKE_COMPILER_IS_GNUCC AND APPLE)
  672. include(CheckCCompilerFlag)
  673. check_c_compiler_flag(-Wno-long-double HAVE_C_FLAG_Wno_long_double)
  674. if(HAVE_C_FLAG_Wno_long_double)
  675. # The Mac version of GCC warns about use of long double. Disable it.
  676. get_source_file_property(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS)
  677. if(MPRINTF_COMPILE_FLAGS)
  678. set(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double")
  679. else(MPRINTF_COMPILE_FLAGS)
  680. set(MPRINTF_COMPILE_FLAGS "-Wno-long-double")
  681. endif(MPRINTF_COMPILE_FLAGS)
  682. set_source_files_properties(mprintf.c PROPERTIES
  683. COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS})
  684. endif(HAVE_C_FLAG_Wno_long_double)
  685. endif(CMAKE_COMPILER_IS_GNUCC AND APPLE)
  686. if(HAVE_SOCKLEN_T)
  687. set(CURL_TYPEOF_CURL_SOCKLEN_T "socklen_t")
  688. if(WIN32)
  689. set(CMAKE_EXTRA_INCLUDE_FILES "winsock2.h;ws2tcpip.h")
  690. elseif(HAVE_SYS_SOCKET_H)
  691. set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h")
  692. endif()
  693. check_type_size("socklen_t" CURL_SIZEOF_CURL_SOCKLEN_T)
  694. set(CMAKE_EXTRA_INCLUDE_FILES)
  695. if(NOT HAVE_CURL_SIZEOF_CURL_SOCKLEN_T)
  696. message(FATAL_ERROR
  697. "Check for sizeof socklen_t failed, see CMakeFiles/CMakerror.log")
  698. endif()
  699. else()
  700. set(CURL_TYPEOF_CURL_SOCKLEN_T int)
  701. set(CURL_SIZEOF_CURL_SOCKLEN_T ${SIZEOF_INT})
  702. endif()
  703. include(CMake/OtherTests.cmake)
  704. add_definitions(-DHAVE_CONFIG_H)
  705. # For windows, do not allow the compiler to use default target (Vista).
  706. if(WIN32)
  707. add_definitions(-D_WIN32_WINNT=0x0501)
  708. endif(WIN32)
  709. if(MSVC)
  710. add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
  711. endif(MSVC)
  712. # Sets up the dependencies (zlib, OpenSSL, etc.) of a cURL subproject according to options.
  713. # TODO This is far to be complete!
  714. function(SETUP_CURL_DEPENDENCIES TARGET_NAME)
  715. if(CURL_ZLIB AND ZLIB_FOUND)
  716. include_directories(${ZLIB_INCLUDE_DIR})
  717. #ADD_DEFINITIONS( -DHAVE_ZLIB_H -DHAVE_ZLIB -DHAVE_LIBZ )
  718. endif()
  719. if(CMAKE_USE_OPENSSL AND OPENSSL_FOUND)
  720. include_directories(${OPENSSL_INCLUDE_DIR})
  721. endif()
  722. if(CMAKE_USE_OPENSSL AND CURL_CONFIG_HAS_BEEN_RUN_BEFORE)
  723. #ADD_DEFINITIONS( -DUSE_SSLEAY )
  724. endif()
  725. target_link_libraries(${TARGET_NAME} ${CURL_LIBS})
  726. endfunction()
  727. # Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it).
  728. function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE)
  729. file(READ ${INPUT_FILE} MAKEFILE_INC_TEXT)
  730. string(REPLACE "$(top_srcdir)" "\${CURL_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  731. string(REPLACE "$(top_builddir)" "\${CURL_BINARY_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  732. string(REGEX REPLACE "\\\\\n" "§!§" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  733. string(REGEX REPLACE "([a-zA-Z_][a-zA-Z0-9_]*)[\t ]*=[\t ]*([^\n]*)" "SET(\\1 \\2)" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  734. string(REPLACE "§!§" "\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  735. string(REGEX REPLACE "\\$\\(([a-zA-Z_][a-zA-Z0-9_]*)\\)" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace $() with ${}
  736. string(REGEX REPLACE "@([a-zA-Z_][a-zA-Z0-9_]*)@" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace @@ with ${}, even if that may not be read by CMake scripts.
  737. file(WRITE ${OUTPUT_FILE} ${MAKEFILE_INC_TEXT})
  738. endfunction()
  739. add_subdirectory(lib)
  740. if(BUILD_CURL_EXE)
  741. add_subdirectory(src)
  742. endif()
  743. if(BUILD_CURL_TESTS)
  744. add_subdirectory(tests)
  745. endif()
  746. # This needs to be run very last so other parts of the scripts can take advantage of this.
  747. if(NOT CURL_CONFIG_HAS_BEEN_RUN_BEFORE)
  748. set(CURL_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before")
  749. endif()
  750. # Installation.
  751. # First, install generated curlbuild.h
  752. install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/curl/curlbuild.h"
  753. DESTINATION include/curl )
  754. # Next, install other headers excluding curlbuild.h
  755. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/curl"
  756. DESTINATION include
  757. FILES_MATCHING PATTERN "*.h"
  758. PATTERN "curlbuild.h" EXCLUDE)
  759. # Workaround for MSVS10 to avoid the Dialog Hell
  760. # FIXME: This could be removed with future version of CMake.
  761. if(MSVC_VERSION EQUAL 1600)
  762. set(CURL_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/CURL.sln")
  763. if(EXISTS "${CURL_SLN_FILENAME}")
  764. file(APPEND "${CURL_SLN_FILENAME}" "\n# This should be regenerated!\n")
  765. endif()
  766. endif()