lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #*************************************************************************** |
| 2 | # _ _ ____ _ |
| 3 | # Project ___| | | | _ \| | |
| 4 | # / __| | | | |_) | | |
| 5 | # | (__| |_| | _ <| |___ |
| 6 | # \___|\___/|_| \_\_____| |
| 7 | # |
| 8 | # Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. |
| 9 | # |
| 10 | # This software is licensed as described in the file COPYING, which |
| 11 | # you should have received as part of this distribution. The terms |
| 12 | # are also available at https://curl.haxx.se/docs/copyright.html. |
| 13 | # |
| 14 | # You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 15 | # copies of the Software, and permit persons to whom the Software is |
| 16 | # furnished to do so, under the terms of the COPYING file. |
| 17 | # |
| 18 | # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 19 | # KIND, either express or implied. |
| 20 | # |
| 21 | ########################################################################### |
| 22 | # curl/libcurl CMake script |
| 23 | # by Tetetest and Sukender (Benoit Neil) |
| 24 | |
| 25 | # TODO: |
| 26 | # The output .so file lacks the soname number which we currently have within the lib/Makefile.am file |
| 27 | # Add full (4 or 5 libs) SSL support |
| 28 | # 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). |
| 29 | # Add CTests(?) |
| 30 | # Check on all possible platforms |
| 31 | # Test with as many configurations possible (With or without any option) |
| 32 | # Create scripts that help keeping the CMake build system up to date (to reduce maintenance). According to Tetetest: |
| 33 | # - lists of headers that 'configure' checks for; |
| 34 | # - curl-specific tests (the ones that are in m4/curl-*.m4 files); |
| 35 | # - (most obvious thing:) curl version numbers. |
| 36 | # Add documentation subproject |
| 37 | # |
| 38 | # To check: |
| 39 | # (From Daniel Stenberg) The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not. |
| 40 | # (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. |
| 41 | cmake_minimum_required(VERSION 2.8 FATAL_ERROR) |
| 42 | set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}") |
| 43 | include(Utilities) |
| 44 | include(Macros) |
| 45 | include(CMakeDependentOption) |
| 46 | |
| 47 | project( CURL C ) |
| 48 | |
| 49 | message(WARNING "the curl cmake build system is poorly maintained. Be aware") |
| 50 | |
| 51 | file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS) |
| 52 | string (REGEX MATCH "#define LIBCURL_VERSION \"[^\"]*" |
| 53 | CURL_VERSION ${CURL_VERSION_H_CONTENTS}) |
| 54 | string (REGEX REPLACE "[^\"]+\"" "" CURL_VERSION ${CURL_VERSION}) |
| 55 | string (REGEX MATCH "#define LIBCURL_VERSION_NUM 0x[0-9a-fA-F]+" |
| 56 | CURL_VERSION_NUM ${CURL_VERSION_H_CONTENTS}) |
| 57 | string (REGEX REPLACE "[^0]+0x" "" CURL_VERSION_NUM ${CURL_VERSION_NUM}) |
| 58 | |
| 59 | include_regular_expression("^.*$") # Sukender: Is it necessary? |
| 60 | |
| 61 | # Setup package meta-data |
| 62 | # SET(PACKAGE "curl") |
| 63 | message(STATUS "curl version=[${CURL_VERSION}]") |
| 64 | # SET(PACKAGE_TARNAME "curl") |
| 65 | # SET(PACKAGE_NAME "curl") |
| 66 | # SET(PACKAGE_VERSION "-") |
| 67 | # SET(PACKAGE_STRING "curl-") |
| 68 | # SET(PACKAGE_BUGREPORT "a suitable curl mailing list => https://curl.haxx.se/mail/") |
| 69 | set(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}") |
| 70 | set(OS "\"${CMAKE_SYSTEM_NAME}\"") |
| 71 | |
| 72 | include_directories(${PROJECT_BINARY_DIR}/include/curl) |
| 73 | include_directories( ${CURL_SOURCE_DIR}/include ) |
| 74 | |
| 75 | option(BUILD_CURL_EXE "Set to ON to build curl executable." ON) |
| 76 | option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF) |
| 77 | option(ENABLE_ARES "Set to ON to enable c-ares support" OFF) |
| 78 | if(WIN32) |
| 79 | CMAKE_DEPENDENT_OPTION(ENABLE_THREADED_RESOLVER |
| 80 | "Set to ON to enable threaded DNS lookup" |
| 81 | ON "NOT ENABLE_ARES" |
| 82 | OFF) |
| 83 | else() |
| 84 | option(ENABLE_THREADED_RESOLVER "Set to ON to enable POSIX threaded DNS lookup" OFF) |
| 85 | endif() |
| 86 | option(ENABLE_DEBUG "Set to ON to enable curl debug features" OFF) |
| 87 | option(ENABLE_CURLDEBUG "Set to ON to build with TrackMemory feature enabled" OFF) |
| 88 | |
| 89 | if (ENABLE_DEBUG) |
| 90 | # DEBUGBUILD will be defined only for Debug builds |
| 91 | if(NOT CMAKE_VERSION VERSION_LESS 3.0) |
| 92 | set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUGBUILD>) |
| 93 | else() |
| 94 | set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUGBUILD) |
| 95 | endif() |
| 96 | set(ENABLE_CURLDEBUG ON) |
| 97 | endif() |
| 98 | |
| 99 | if (ENABLE_CURLDEBUG) |
| 100 | set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS CURLDEBUG) |
| 101 | endif() |
| 102 | |
| 103 | # initialize CURL_LIBS |
| 104 | set(CURL_LIBS "") |
| 105 | |
| 106 | if(ENABLE_THREADED_RESOLVER AND ENABLE_ARES) |
| 107 | message(FATAL_ERROR "Options ENABLE_THREADED_RESOLVER and ENABLE_ARES are mutually exclusive") |
| 108 | endif() |
| 109 | |
| 110 | if(ENABLE_ARES) |
| 111 | set(USE_ARES 1) |
| 112 | find_package(CARES REQUIRED) |
| 113 | list(APPEND CURL_LIBS ${CARES_LIBRARY} ) |
| 114 | set(CURL_LIBS ${CURL_LIBS} ${CARES_LIBRARY}) |
| 115 | endif() |
| 116 | |
| 117 | if(MSVC) |
| 118 | option(BUILD_RELEASE_DEBUG_DIRS "Set OFF to build each configuration to a separate directory" OFF) |
| 119 | mark_as_advanced(BUILD_RELEASE_DEBUG_DIRS) |
| 120 | endif() |
| 121 | |
| 122 | include(CurlSymbolHiding) |
| 123 | |
| 124 | option(HTTP_ONLY "disables all protocols except HTTP (This overrides all CURL_DISABLE_* options)" OFF) |
| 125 | mark_as_advanced(HTTP_ONLY) |
| 126 | option(CURL_DISABLE_FTP "disables FTP" OFF) |
| 127 | mark_as_advanced(CURL_DISABLE_FTP) |
| 128 | option(CURL_DISABLE_LDAP "disables LDAP" OFF) |
| 129 | mark_as_advanced(CURL_DISABLE_LDAP) |
| 130 | option(CURL_DISABLE_TELNET "disables Telnet" OFF) |
| 131 | mark_as_advanced(CURL_DISABLE_TELNET) |
| 132 | option(CURL_DISABLE_DICT "disables DICT" OFF) |
| 133 | mark_as_advanced(CURL_DISABLE_DICT) |
| 134 | option(CURL_DISABLE_FILE "disables FILE" OFF) |
| 135 | mark_as_advanced(CURL_DISABLE_FILE) |
| 136 | option(CURL_DISABLE_TFTP "disables TFTP" OFF) |
| 137 | mark_as_advanced(CURL_DISABLE_TFTP) |
| 138 | option(CURL_DISABLE_HTTP "disables HTTP" OFF) |
| 139 | mark_as_advanced(CURL_DISABLE_HTTP) |
| 140 | |
| 141 | option(CURL_DISABLE_LDAPS "to disable LDAPS" OFF) |
| 142 | mark_as_advanced(CURL_DISABLE_LDAPS) |
| 143 | |
| 144 | option(CURL_DISABLE_RTSP "to disable RTSP" OFF) |
| 145 | mark_as_advanced(CURL_DISABLE_RTSP) |
| 146 | option(CURL_DISABLE_PROXY "to disable proxy" OFF) |
| 147 | mark_as_advanced(CURL_DISABLE_PROXY) |
| 148 | option(CURL_DISABLE_POP3 "to disable POP3" OFF) |
| 149 | mark_as_advanced(CURL_DISABLE_POP3) |
| 150 | option(CURL_DISABLE_IMAP "to disable IMAP" OFF) |
| 151 | mark_as_advanced(CURL_DISABLE_IMAP) |
| 152 | option(CURL_DISABLE_SMTP "to disable SMTP" OFF) |
| 153 | mark_as_advanced(CURL_DISABLE_SMTP) |
| 154 | option(CURL_DISABLE_GOPHER "to disable Gopher" OFF) |
| 155 | mark_as_advanced(CURL_DISABLE_GOPHER) |
| 156 | |
| 157 | if(HTTP_ONLY) |
| 158 | set(CURL_DISABLE_FTP ON) |
| 159 | set(CURL_DISABLE_LDAP ON) |
| 160 | set(CURL_DISABLE_LDAPS ON) |
| 161 | set(CURL_DISABLE_TELNET ON) |
| 162 | set(CURL_DISABLE_DICT ON) |
| 163 | set(CURL_DISABLE_FILE ON) |
| 164 | set(CURL_DISABLE_TFTP ON) |
| 165 | set(CURL_DISABLE_RTSP ON) |
| 166 | set(CURL_DISABLE_POP3 ON) |
| 167 | set(CURL_DISABLE_IMAP ON) |
| 168 | set(CURL_DISABLE_SMTP ON) |
| 169 | set(CURL_DISABLE_GOPHER ON) |
| 170 | endif() |
| 171 | |
| 172 | option(CURL_DISABLE_COOKIES "to disable cookies support" OFF) |
| 173 | mark_as_advanced(CURL_DISABLE_COOKIES) |
| 174 | |
| 175 | option(CURL_DISABLE_CRYPTO_AUTH "to disable cryptographic authentication" OFF) |
| 176 | mark_as_advanced(CURL_DISABLE_CRYPTO_AUTH) |
| 177 | option(CURL_DISABLE_VERBOSE_STRINGS "to disable verbose strings" OFF) |
| 178 | mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS) |
| 179 | option(DISABLED_THREADSAFE "Set to explicitly specify we don't want to use thread-safe functions" OFF) |
| 180 | mark_as_advanced(DISABLED_THREADSAFE) |
| 181 | option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON) |
| 182 | mark_as_advanced(ENABLE_IPV6) |
| 183 | if(ENABLE_IPV6 AND NOT WIN32) |
| 184 | include(CheckStructHasMember) |
| 185 | check_struct_has_member("struct sockaddr_in6" sin6_addr "netinet/in.h" |
| 186 | HAVE_SOCKADDR_IN6_SIN6_ADDR) |
| 187 | check_struct_has_member("struct sockaddr_in6" sin6_scope_id "netinet/in.h" |
| 188 | HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID) |
| 189 | if(NOT HAVE_SOCKADDR_IN6_SIN6_ADDR) |
| 190 | message(WARNING "struct sockaddr_in6 not available, disabling IPv6 support") |
| 191 | # Force the feature off as this name is used as guard macro... |
| 192 | set(ENABLE_IPV6 OFF |
| 193 | CACHE BOOL "Define if you want to enable IPv6 support" FORCE) |
| 194 | endif() |
| 195 | endif() |
| 196 | |
| 197 | option(ENABLE_MANUAL "to provide the built-in manual" ON) |
| 198 | unset(USE_MANUAL CACHE) # TODO: cache NROFF/NROFF_MANOPT/USE_MANUAL vars? |
| 199 | if(ENABLE_MANUAL) |
| 200 | find_program(NROFF NAMES gnroff nroff) |
| 201 | if(NROFF) |
| 202 | # Need a way to write to stdin, this will do |
| 203 | file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt" "test") |
| 204 | # Tests for a valid nroff option to generate a manpage |
| 205 | foreach(_MANOPT "-man" "-mandoc") |
| 206 | execute_process(COMMAND "${NROFF}" ${_MANOPT} |
| 207 | OUTPUT_VARIABLE NROFF_MANOPT_OUTPUT |
| 208 | INPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt" |
| 209 | ERROR_QUIET) |
| 210 | # Save the option if it was valid |
| 211 | if(NROFF_MANOPT_OUTPUT) |
| 212 | message("Found *nroff option: -- ${_MANOPT}") |
| 213 | set(NROFF_MANOPT ${_MANOPT}) |
| 214 | set(USE_MANUAL 1) |
| 215 | break() |
| 216 | endif() |
| 217 | endforeach() |
| 218 | # No need for the temporary file |
| 219 | file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt") |
| 220 | if(NOT USE_MANUAL) |
| 221 | message(WARNING "Found no *nroff option to get plaintext from man pages") |
| 222 | endif() |
| 223 | else() |
| 224 | message(WARNING "Found no *nroff program") |
| 225 | endif() |
| 226 | endif() |
| 227 | # Required for building manual, docs, tests |
| 228 | find_package(Perl REQUIRED) |
| 229 | |
| 230 | # We need ansi c-flags, especially on HP |
| 231 | set(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") |
| 232 | set(CMAKE_REQUIRED_FLAGS ${CMAKE_ANSI_CFLAGS}) |
| 233 | |
| 234 | # Disable warnings on Borland to avoid changing 3rd party code. |
| 235 | if(BORLAND) |
| 236 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") |
| 237 | endif(BORLAND) |
| 238 | |
| 239 | # If we are on AIX, do the _ALL_SOURCE magic |
| 240 | if(${CMAKE_SYSTEM_NAME} MATCHES AIX) |
| 241 | set(_ALL_SOURCE 1) |
| 242 | endif(${CMAKE_SYSTEM_NAME} MATCHES AIX) |
| 243 | |
| 244 | # Include all the necessary files for macros |
| 245 | include (CheckFunctionExists) |
| 246 | include (CheckIncludeFile) |
| 247 | include (CheckIncludeFiles) |
| 248 | include (CheckLibraryExists) |
| 249 | include (CheckSymbolExists) |
| 250 | include (CheckTypeSize) |
| 251 | include (CheckCSourceCompiles) |
| 252 | include (CMakeDependentOption) |
| 253 | |
| 254 | # On windows preload settings |
| 255 | if(WIN32) |
| 256 | set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WINSOCKAPI_=") |
| 257 | include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Platforms/WindowsCache.cmake) |
| 258 | endif(WIN32) |
| 259 | |
| 260 | if(ENABLE_THREADED_RESOLVER) |
| 261 | if(WIN32) |
| 262 | set(USE_THREADS_WIN32 ON) |
| 263 | else() |
| 264 | check_include_file_concat("pthread.h" HAVE_PTHREAD_H) |
| 265 | if(HAVE_PTHREAD_H) |
| 266 | set(CMAKE_THREAD_PREFER_PTHREAD 1) |
| 267 | find_package(Threads) |
| 268 | if(CMAKE_USE_PTHREADS_INIT) |
| 269 | set(CURL_LIBS ${CURL_LIBS} ${CMAKE_THREAD_LIBS_INIT}) |
| 270 | set(USE_THREADS_POSIX 1) |
| 271 | endif() |
| 272 | endif() |
| 273 | endif() |
| 274 | endif() |
| 275 | |
| 276 | # Check for all needed libraries |
| 277 | check_library_exists_concat("dl" dlopen HAVE_LIBDL) |
| 278 | check_library_exists_concat("socket" connect HAVE_LIBSOCKET) |
| 279 | check_library_exists("c" gethostbyname "" NOT_NEED_LIBNSL) |
| 280 | |
| 281 | # Yellowtab Zeta needs different libraries than BeOS 5. |
| 282 | if(BEOS) |
| 283 | set(NOT_NEED_LIBNSL 1) |
| 284 | check_library_exists_concat("bind" gethostbyname HAVE_LIBBIND) |
| 285 | check_library_exists_concat("bnetapi" closesocket HAVE_LIBBNETAPI) |
| 286 | endif(BEOS) |
| 287 | |
| 288 | if(NOT NOT_NEED_LIBNSL) |
| 289 | check_library_exists_concat("nsl" gethostbyname HAVE_LIBNSL) |
| 290 | endif(NOT NOT_NEED_LIBNSL) |
| 291 | |
| 292 | check_function_exists(gethostname HAVE_GETHOSTNAME) |
| 293 | |
| 294 | if(WIN32) |
| 295 | check_library_exists_concat("ws2_32" getch HAVE_LIBWS2_32) |
| 296 | check_library_exists_concat("winmm" getch HAVE_LIBWINMM) |
| 297 | endif() |
| 298 | |
| 299 | # check SSL libraries |
| 300 | # TODO support GNUTLS, NSS, POLARSSL, AXTLS, CYASSL |
| 301 | |
| 302 | if(APPLE) |
| 303 | option(CMAKE_USE_DARWINSSL "enable Apple OS native SSL/TLS" OFF) |
| 304 | endif() |
| 305 | if(WIN32) |
| 306 | option(CMAKE_USE_WINSSL "enable Windows native SSL/TLS" OFF) |
| 307 | cmake_dependent_option(CURL_WINDOWS_SSPI "Use windows libraries to allow NTLM authentication without openssl" ON |
| 308 | CMAKE_USE_WINSSL OFF) |
| 309 | endif() |
| 310 | option(CMAKE_USE_MBEDTLS "Enable mbedTLS for SSL/TLS" OFF) |
| 311 | |
| 312 | set(openssl_default ON) |
| 313 | if(WIN32 OR CMAKE_USE_DARWINSSL OR CMAKE_USE_WINSSL OR CMAKE_USE_MBEDTLS) |
| 314 | set(openssl_default OFF) |
| 315 | endif() |
| 316 | option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ${openssl_default}) |
| 317 | |
| 318 | collect_true(enabled_ssl_options enabled_ssl_options_count |
| 319 | CMAKE_USE_WINSSL |
| 320 | CMAKE_USE_DARWINSSL |
| 321 | CMAKE_USE_OPENSSL |
| 322 | CMAKE_USE_MBEDTLS |
| 323 | ) |
| 324 | if(enabled_ssl_options_count GREATER 1) |
| 325 | message(FATAL_ERROR "Multiple SSL options specified: ${enabled_ssl_options}. Please pick at most one and disable the rest.") |
| 326 | endif() |
| 327 | |
| 328 | if(CMAKE_USE_WINSSL) |
| 329 | set(SSL_ENABLED ON) |
| 330 | set(USE_SCHANNEL ON) # Windows native SSL/TLS support |
| 331 | set(USE_WINDOWS_SSPI ON) # CMAKE_USE_WINSSL implies CURL_WINDOWS_SSPI |
| 332 | list(APPEND CURL_LIBS "crypt32") |
| 333 | endif() |
| 334 | if(CURL_WINDOWS_SSPI) |
| 335 | set(USE_WINDOWS_SSPI ON) |
| 336 | set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DSECURITY_WIN32") |
| 337 | endif() |
| 338 | |
| 339 | if(CMAKE_USE_DARWINSSL) |
| 340 | find_library(COREFOUNDATION_FRAMEWORK "CoreFoundation") |
| 341 | if(NOT COREFOUNDATION_FRAMEWORK) |
| 342 | message(FATAL_ERROR "CoreFoundation framework not found") |
| 343 | endif() |
| 344 | |
| 345 | find_library(SECURITY_FRAMEWORK "Security") |
| 346 | if(NOT SECURITY_FRAMEWORK) |
| 347 | message(FATAL_ERROR "Security framework not found") |
| 348 | endif() |
| 349 | |
| 350 | set(SSL_ENABLED ON) |
| 351 | set(USE_DARWINSSL ON) |
| 352 | list(APPEND CURL_LIBS "${COREFOUNDATION_FRAMEWORK}" "${SECURITY_FRAMEWORK}") |
| 353 | endif() |
| 354 | |
| 355 | if(CMAKE_USE_OPENSSL) |
| 356 | find_package(OpenSSL REQUIRED) |
| 357 | set(SSL_ENABLED ON) |
| 358 | set(USE_OPENSSL ON) |
| 359 | set(HAVE_LIBCRYPTO ON) |
| 360 | set(HAVE_LIBSSL ON) |
| 361 | list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES}) |
| 362 | include_directories(${OPENSSL_INCLUDE_DIR}) |
| 363 | set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) |
| 364 | check_include_file("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H) |
| 365 | check_include_file("openssl/engine.h" HAVE_OPENSSL_ENGINE_H) |
| 366 | check_include_file("openssl/err.h" HAVE_OPENSSL_ERR_H) |
| 367 | check_include_file("openssl/pem.h" HAVE_OPENSSL_PEM_H) |
| 368 | check_include_file("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H) |
| 369 | check_include_file("openssl/rsa.h" HAVE_OPENSSL_RSA_H) |
| 370 | check_include_file("openssl/ssl.h" HAVE_OPENSSL_SSL_H) |
| 371 | check_include_file("openssl/x509.h" HAVE_OPENSSL_X509_H) |
| 372 | check_include_file("openssl/rand.h" HAVE_OPENSSL_RAND_H) |
| 373 | check_symbol_exists(RAND_status "${CURL_INCLUDES}" HAVE_RAND_STATUS) |
| 374 | check_symbol_exists(RAND_screen "${CURL_INCLUDES}" HAVE_RAND_SCREEN) |
| 375 | check_symbol_exists(RAND_egd "${CURL_INCLUDES}" HAVE_RAND_EGD) |
| 376 | endif() |
| 377 | |
| 378 | if(CMAKE_USE_MBEDTLS) |
| 379 | find_package(MbedTLS REQUIRED) |
| 380 | set(SSL_ENABLED ON) |
| 381 | set(USE_MBEDTLS ON) |
| 382 | list(APPEND CURL_LIBS ${MBEDTLS_LIBRARIES}) |
| 383 | include_directories(${MBEDTLS_INCLUDE_DIRS}) |
| 384 | endif() |
| 385 | |
| 386 | option(USE_NGHTTP2 "Use Nghttp2 library" OFF) |
| 387 | if(USE_NGHTTP2) |
| 388 | find_package(NGHTTP2 REQUIRED) |
| 389 | include_directories(${NGHTTP2_INCLUDE_DIRS}) |
| 390 | list(APPEND CURL_LIBS ${NGHTTP2_LIBRARIES}) |
| 391 | endif() |
| 392 | |
| 393 | if(NOT CURL_DISABLE_LDAP) |
| 394 | if(WIN32) |
| 395 | option(USE_WIN32_LDAP "Use Windows LDAP implementation" ON) |
| 396 | if(USE_WIN32_LDAP) |
| 397 | check_library_exists_concat("wldap32" cldap_open HAVE_WLDAP32) |
| 398 | if(NOT HAVE_WLDAP32) |
| 399 | set(USE_WIN32_LDAP OFF) |
| 400 | endif() |
| 401 | endif() |
| 402 | endif() |
| 403 | |
| 404 | option(CMAKE_USE_OPENLDAP "Use OpenLDAP code." OFF) |
| 405 | mark_as_advanced(CMAKE_USE_OPENLDAP) |
| 406 | set(CMAKE_LDAP_LIB "ldap" CACHE STRING "Name or full path to ldap library") |
| 407 | set(CMAKE_LBER_LIB "lber" CACHE STRING "Name or full path to lber library") |
| 408 | |
| 409 | if(CMAKE_USE_OPENLDAP AND USE_WIN32_LDAP) |
| 410 | message(FATAL_ERROR "Cannot use USE_WIN32_LDAP and CMAKE_USE_OPENLDAP at the same time") |
| 411 | endif() |
| 412 | |
| 413 | # Now that we know, we're not using windows LDAP... |
| 414 | if(USE_WIN32_LDAP) |
| 415 | check_include_file_concat("winldap.h" HAVE_WINLDAP_H) |
| 416 | check_include_file_concat("winber.h" HAVE_WINBER_H) |
| 417 | else() |
| 418 | # Check for LDAP |
| 419 | set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) |
| 420 | check_library_exists_concat(${CMAKE_LDAP_LIB} ldap_init HAVE_LIBLDAP) |
| 421 | check_library_exists_concat(${CMAKE_LBER_LIB} ber_init HAVE_LIBLBER) |
| 422 | |
| 423 | set(CMAKE_REQUIRED_INCLUDES_BAK ${CMAKE_REQUIRED_INCLUDES}) |
| 424 | set(CMAKE_LDAP_INCLUDE_DIR "" CACHE STRING "Path to LDAP include directory") |
| 425 | if(CMAKE_LDAP_INCLUDE_DIR) |
| 426 | list(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_LDAP_INCLUDE_DIR}) |
| 427 | endif() |
| 428 | check_include_file_concat("ldap.h" HAVE_LDAP_H) |
| 429 | check_include_file_concat("lber.h" HAVE_LBER_H) |
| 430 | |
| 431 | if(NOT HAVE_LDAP_H) |
| 432 | message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON") |
| 433 | set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE) |
| 434 | set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) #LDAP includes won't be used |
| 435 | elseif(NOT HAVE_LIBLDAP) |
| 436 | message(STATUS "LDAP library '${CMAKE_LDAP_LIB}' not found CURL_DISABLE_LDAP set ON") |
| 437 | set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE) |
| 438 | set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) #LDAP includes won't be used |
| 439 | else() |
| 440 | if(CMAKE_USE_OPENLDAP) |
| 441 | set(USE_OPENLDAP ON) |
| 442 | endif() |
| 443 | if(CMAKE_LDAP_INCLUDE_DIR) |
| 444 | include_directories(${CMAKE_LDAP_INCLUDE_DIR}) |
| 445 | endif() |
| 446 | set(NEED_LBER_H ON) |
| 447 | set(_HEADER_LIST) |
| 448 | if(HAVE_WINDOWS_H) |
| 449 | list(APPEND _HEADER_LIST "windows.h") |
| 450 | endif() |
| 451 | if(HAVE_SYS_TYPES_H) |
| 452 | list(APPEND _HEADER_LIST "sys/types.h") |
| 453 | endif() |
| 454 | list(APPEND _HEADER_LIST "ldap.h") |
| 455 | |
| 456 | set(_SRC_STRING "") |
| 457 | foreach(_HEADER ${_HEADER_LIST}) |
| 458 | set(_INCLUDE_STRING "${_INCLUDE_STRING}#include <${_HEADER}>\n") |
| 459 | endforeach() |
| 460 | |
| 461 | set(_SRC_STRING |
| 462 | " |
| 463 | ${_INCLUDE_STRING} |
| 464 | int main(int argc, char ** argv) |
| 465 | { |
| 466 | BerValue *bvp = NULL; |
| 467 | BerElement *bep = ber_init(bvp); |
| 468 | ber_free(bep, 1); |
| 469 | return 0; |
| 470 | }" |
| 471 | ) |
| 472 | set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DLDAP_DEPRECATED=1") |
| 473 | list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB}) |
| 474 | if(HAVE_LIBLBER) |
| 475 | list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LBER_LIB}) |
| 476 | endif() |
| 477 | check_c_source_compiles("${_SRC_STRING}" NOT_NEED_LBER_H) |
| 478 | |
| 479 | if(NOT_NEED_LBER_H) |
| 480 | set(NEED_LBER_H OFF) |
| 481 | else() |
| 482 | set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -DNEED_LBER_H") |
| 483 | endif() |
| 484 | endif() |
| 485 | endif() |
| 486 | |
| 487 | endif() |
| 488 | |
| 489 | # No ldap, no ldaps. |
| 490 | if(CURL_DISABLE_LDAP) |
| 491 | if(NOT CURL_DISABLE_LDAPS) |
| 492 | message(STATUS "LDAP needs to be enabled to support LDAPS") |
| 493 | set(CURL_DISABLE_LDAPS ON CACHE BOOL "" FORCE) |
| 494 | endif() |
| 495 | endif() |
| 496 | |
| 497 | if(NOT CURL_DISABLE_LDAPS) |
| 498 | check_include_file_concat("ldap_ssl.h" HAVE_LDAP_SSL_H) |
| 499 | check_include_file_concat("ldapssl.h" HAVE_LDAPSSL_H) |
| 500 | endif() |
| 501 | |
| 502 | # Check for idn |
| 503 | check_library_exists_concat("idn2" idn2_lookup_ul HAVE_LIBIDN2) |
| 504 | |
| 505 | # Check for symbol dlopen (same as HAVE_LIBDL) |
| 506 | check_library_exists("${CURL_LIBS}" dlopen "" HAVE_DLOPEN) |
| 507 | |
| 508 | option(CURL_ZLIB "Set to ON to enable building curl with zlib support." ON) |
| 509 | set(HAVE_LIBZ OFF) |
| 510 | set(HAVE_ZLIB_H OFF) |
| 511 | set(HAVE_ZLIB OFF) |
| 512 | if(CURL_ZLIB) |
| 513 | find_package(ZLIB QUIET) |
| 514 | if(ZLIB_FOUND) |
| 515 | set(HAVE_ZLIB_H ON) |
| 516 | set(HAVE_ZLIB ON) |
| 517 | set(HAVE_LIBZ ON) |
| 518 | list(APPEND CURL_LIBS ${ZLIB_LIBRARIES}) |
| 519 | include_directories(${ZLIB_INCLUDE_DIRS}) |
| 520 | list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS}) |
| 521 | endif() |
| 522 | endif() |
| 523 | |
| 524 | #libSSH2 |
| 525 | option(CMAKE_USE_LIBSSH2 "Use libSSH2" ON) |
| 526 | mark_as_advanced(CMAKE_USE_LIBSSH2) |
| 527 | set(USE_LIBSSH2 OFF) |
| 528 | set(HAVE_LIBSSH2 OFF) |
| 529 | set(HAVE_LIBSSH2_H OFF) |
| 530 | |
| 531 | if(CMAKE_USE_LIBSSH2) |
| 532 | find_package(LibSSH2) |
| 533 | if(LIBSSH2_FOUND) |
| 534 | list(APPEND CURL_LIBS ${LIBSSH2_LIBRARY}) |
| 535 | set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH2_LIBRARY}) |
| 536 | list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIR}") |
| 537 | include_directories("${LIBSSH2_INCLUDE_DIR}") |
| 538 | set(HAVE_LIBSSH2 ON) |
| 539 | set(USE_LIBSSH2 ON) |
| 540 | |
| 541 | # find_package has already found the headers |
| 542 | set(HAVE_LIBSSH2_H ON) |
| 543 | set(CURL_INCLUDES ${CURL_INCLUDES} "${LIBSSH2_INCLUDE_DIR}/libssh2.h") |
| 544 | set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -DHAVE_LIBSSH2_H") |
| 545 | |
| 546 | # now check for specific libssh2 symbols as they were added in different versions |
| 547 | set(CMAKE_EXTRA_INCLUDE_FILES "libssh2.h") |
| 548 | check_function_exists(libssh2_version HAVE_LIBSSH2_VERSION) |
| 549 | check_function_exists(libssh2_init HAVE_LIBSSH2_INIT) |
| 550 | check_function_exists(libssh2_exit HAVE_LIBSSH2_EXIT) |
| 551 | check_function_exists(libssh2_scp_send64 HAVE_LIBSSH2_SCP_SEND64) |
| 552 | check_function_exists(libssh2_session_handshake HAVE_LIBSSH2_SESSION_HANDSHAKE) |
| 553 | set(CMAKE_EXTRA_INCLUDE_FILES "") |
| 554 | |
| 555 | endif(LIBSSH2_FOUND) |
| 556 | endif(CMAKE_USE_LIBSSH2) |
| 557 | |
| 558 | option(CMAKE_USE_GSSAPI "Use GSSAPI implementation (right now only Heimdal is supported with CMake build)" OFF) |
| 559 | mark_as_advanced(CMAKE_USE_GSSAPI) |
| 560 | |
| 561 | if(CMAKE_USE_GSSAPI) |
| 562 | find_package(GSS) |
| 563 | |
| 564 | set(HAVE_GSSAPI ${GSS_FOUND}) |
| 565 | if(GSS_FOUND) |
| 566 | |
| 567 | message(STATUS "Found ${GSS_FLAVOUR} GSSAPI version: \"${GSS_VERSION}\"") |
| 568 | |
| 569 | list(APPEND CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIRECTORIES}) |
| 570 | check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H) |
| 571 | check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H) |
| 572 | check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H) |
| 573 | |
| 574 | if(GSS_FLAVOUR STREQUAL "Heimdal") |
| 575 | set(HAVE_GSSHEIMDAL ON) |
| 576 | else() # MIT |
| 577 | set(HAVE_GSSMIT ON) |
| 578 | set(_INCLUDE_LIST "") |
| 579 | if(HAVE_GSSAPI_GSSAPI_H) |
| 580 | list(APPEND _INCLUDE_LIST "gssapi/gssapi.h") |
| 581 | endif() |
| 582 | if(HAVE_GSSAPI_GSSAPI_GENERIC_H) |
| 583 | list(APPEND _INCLUDE_LIST "gssapi/gssapi_generic.h") |
| 584 | endif() |
| 585 | if(HAVE_GSSAPI_GSSAPI_KRB5_H) |
| 586 | list(APPEND _INCLUDE_LIST "gssapi/gssapi_krb5.h") |
| 587 | endif() |
| 588 | |
| 589 | string(REPLACE ";" " " _COMPILER_FLAGS_STR "${GSS_COMPILER_FLAGS}") |
| 590 | string(REPLACE ";" " " _LINKER_FLAGS_STR "${GSS_LINKER_FLAGS}") |
| 591 | |
| 592 | foreach(_dir ${GSS_LINK_DIRECTORIES}) |
| 593 | set(_LINKER_FLAGS_STR "${_LINKER_FLAGS_STR} -L\"${_dir}\"") |
| 594 | endforeach() |
| 595 | |
| 596 | set(CMAKE_REQUIRED_FLAGS "${_COMPILER_FLAGS_STR} ${_LINKER_FLAGS_STR}") |
| 597 | set(CMAKE_REQUIRED_LIBRARIES ${GSS_LIBRARIES}) |
| 598 | check_symbol_exists("GSS_C_NT_HOSTBASED_SERVICE" ${_INCLUDE_LIST} HAVE_GSS_C_NT_HOSTBASED_SERVICE) |
| 599 | if(NOT HAVE_GSS_C_NT_HOSTBASED_SERVICE) |
| 600 | set(HAVE_OLD_GSSMIT ON) |
| 601 | endif() |
| 602 | |
| 603 | endif() |
| 604 | |
| 605 | include_directories(${GSS_INCLUDE_DIRECTORIES}) |
| 606 | link_directories(${GSS_LINK_DIRECTORIES}) |
| 607 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSS_COMPILER_FLAGS}") |
| 608 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GSS_LINKER_FLAGS}") |
| 609 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GSS_LINKER_FLAGS}") |
| 610 | list(APPEND CURL_LIBS ${GSS_LIBRARIES}) |
| 611 | |
| 612 | else() |
| 613 | message(WARNING "GSSAPI support has been requested but no supporting libraries found. Skipping.") |
| 614 | endif() |
| 615 | endif() |
| 616 | |
| 617 | option(ENABLE_UNIX_SOCKETS "Define if you want Unix domain sockets support" ON) |
| 618 | if(ENABLE_UNIX_SOCKETS) |
| 619 | include(CheckStructHasMember) |
| 620 | check_struct_has_member("struct sockaddr_un" sun_path "sys/un.h" USE_UNIX_SOCKETS) |
| 621 | else() |
| 622 | unset(USE_UNIX_SOCKETS CACHE) |
| 623 | endif() |
| 624 | |
| 625 | |
| 626 | # |
| 627 | # CA handling |
| 628 | # |
| 629 | set(CURL_CA_BUNDLE "auto" CACHE STRING |
| 630 | "Path to the CA bundle. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.") |
| 631 | set(CURL_CA_FALLBACK OFF CACHE BOOL |
| 632 | "Set ON to use built-in CA store of TLS backend. Defaults to OFF") |
| 633 | set(CURL_CA_PATH "auto" CACHE STRING |
| 634 | "Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.") |
| 635 | |
| 636 | if("${CURL_CA_BUNDLE}" STREQUAL "") |
| 637 | message(FATAL_ERROR "Invalid value of CURL_CA_BUNDLE. Use 'none', 'auto' or file path.") |
| 638 | elseif("${CURL_CA_BUNDLE}" STREQUAL "none") |
| 639 | unset(CURL_CA_BUNDLE CACHE) |
| 640 | elseif("${CURL_CA_BUNDLE}" STREQUAL "auto") |
| 641 | unset(CURL_CA_BUNDLE CACHE) |
| 642 | set(CURL_CA_BUNDLE_AUTODETECT TRUE) |
| 643 | else() |
| 644 | set(CURL_CA_BUNDLE_SET TRUE) |
| 645 | endif() |
| 646 | |
| 647 | if("${CURL_CA_PATH}" STREQUAL "") |
| 648 | message(FATAL_ERROR "Invalid value of CURL_CA_PATH. Use 'none', 'auto' or directory path.") |
| 649 | elseif("${CURL_CA_PATH}" STREQUAL "none") |
| 650 | unset(CURL_CA_PATH CACHE) |
| 651 | elseif("${CURL_CA_PATH}" STREQUAL "auto") |
| 652 | unset(CURL_CA_PATH CACHE) |
| 653 | set(CURL_CA_PATH_AUTODETECT TRUE) |
| 654 | else() |
| 655 | set(CURL_CA_PATH_SET TRUE) |
| 656 | endif() |
| 657 | |
| 658 | if(CURL_CA_BUNDLE_SET AND CURL_CA_PATH_AUTODETECT) |
| 659 | # Skip autodetection of unset CA path because CA bundle is set explicitly |
| 660 | elseif(CURL_CA_PATH_SET AND CURL_CA_BUNDLE_AUTODETECT) |
| 661 | # Skip autodetection of unset CA bundle because CA path is set explicitly |
| 662 | elseif(CURL_CA_PATH_AUTODETECT OR CURL_CA_BUNDLE_AUTODETECT) |
| 663 | # first try autodetecting a CA bundle, then a CA path |
| 664 | |
| 665 | if(CURL_CA_BUNDLE_AUTODETECT) |
| 666 | set(SEARCH_CA_BUNDLE_PATHS |
| 667 | /etc/ssl/certs/ca-certificates.crt |
| 668 | /etc/pki/tls/certs/ca-bundle.crt |
| 669 | /usr/share/ssl/certs/ca-bundle.crt |
| 670 | /usr/local/share/certs/ca-root-nss.crt |
| 671 | /etc/ssl/cert.pem) |
| 672 | |
| 673 | foreach(SEARCH_CA_BUNDLE_PATH ${SEARCH_CA_BUNDLE_PATHS}) |
| 674 | if(EXISTS "${SEARCH_CA_BUNDLE_PATH}") |
| 675 | message(STATUS "Found CA bundle: ${SEARCH_CA_BUNDLE_PATH}") |
| 676 | set(CURL_CA_BUNDLE "${SEARCH_CA_BUNDLE_PATH}") |
| 677 | set(CURL_CA_BUNDLE_SET TRUE CACHE BOOL "Path to the CA bundle has been set") |
| 678 | break() |
| 679 | endif() |
| 680 | endforeach() |
| 681 | endif() |
| 682 | |
| 683 | if(CURL_CA_PATH_AUTODETECT AND (NOT CURL_CA_PATH_SET)) |
| 684 | if(EXISTS "/etc/ssl/certs") |
| 685 | set(CURL_CA_PATH "/etc/ssl/certs") |
| 686 | set(CURL_CA_PATH_SET TRUE CACHE BOOL "Path to the CA bundle has been set") |
| 687 | endif() |
| 688 | endif() |
| 689 | endif() |
| 690 | |
| 691 | if(CURL_CA_PATH_SET AND NOT USE_OPENSSL AND NOT USE_MBEDTLS) |
| 692 | message(FATAL_ERROR |
| 693 | "CA path only supported by OpenSSL, GnuTLS or mbed TLS. " |
| 694 | "Set CURL_CA_PATH=none or enable one of those TLS backends.") |
| 695 | endif() |
| 696 | |
| 697 | |
| 698 | # Check for header files |
| 699 | if(NOT UNIX) |
| 700 | check_include_file_concat("windows.h" HAVE_WINDOWS_H) |
| 701 | check_include_file_concat("winsock.h" HAVE_WINSOCK_H) |
| 702 | check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H) |
| 703 | check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H) |
| 704 | if(NOT CURL_WINDOWS_SSPI AND USE_OPENSSL) |
| 705 | set(CURL_LIBS ${CURL_LIBS} "crypt32") |
| 706 | endif() |
| 707 | endif(NOT UNIX) |
| 708 | |
| 709 | check_include_file_concat("stdio.h" HAVE_STDIO_H) |
| 710 | check_include_file_concat("inttypes.h" HAVE_INTTYPES_H) |
| 711 | check_include_file_concat("sys/filio.h" HAVE_SYS_FILIO_H) |
| 712 | check_include_file_concat("sys/ioctl.h" HAVE_SYS_IOCTL_H) |
| 713 | check_include_file_concat("sys/param.h" HAVE_SYS_PARAM_H) |
| 714 | check_include_file_concat("sys/poll.h" HAVE_SYS_POLL_H) |
| 715 | check_include_file_concat("sys/resource.h" HAVE_SYS_RESOURCE_H) |
| 716 | check_include_file_concat("sys/select.h" HAVE_SYS_SELECT_H) |
| 717 | check_include_file_concat("sys/socket.h" HAVE_SYS_SOCKET_H) |
| 718 | check_include_file_concat("sys/sockio.h" HAVE_SYS_SOCKIO_H) |
| 719 | check_include_file_concat("sys/stat.h" HAVE_SYS_STAT_H) |
| 720 | check_include_file_concat("sys/time.h" HAVE_SYS_TIME_H) |
| 721 | check_include_file_concat("sys/types.h" HAVE_SYS_TYPES_H) |
| 722 | check_include_file_concat("sys/uio.h" HAVE_SYS_UIO_H) |
| 723 | check_include_file_concat("sys/un.h" HAVE_SYS_UN_H) |
| 724 | check_include_file_concat("sys/utime.h" HAVE_SYS_UTIME_H) |
| 725 | check_include_file_concat("sys/xattr.h" HAVE_SYS_XATTR_H) |
| 726 | check_include_file_concat("alloca.h" HAVE_ALLOCA_H) |
| 727 | check_include_file_concat("arpa/inet.h" HAVE_ARPA_INET_H) |
| 728 | check_include_file_concat("arpa/tftp.h" HAVE_ARPA_TFTP_H) |
| 729 | check_include_file_concat("assert.h" HAVE_ASSERT_H) |
| 730 | check_include_file_concat("crypto.h" HAVE_CRYPTO_H) |
| 731 | check_include_file_concat("des.h" HAVE_DES_H) |
| 732 | check_include_file_concat("err.h" HAVE_ERR_H) |
| 733 | check_include_file_concat("errno.h" HAVE_ERRNO_H) |
| 734 | check_include_file_concat("fcntl.h" HAVE_FCNTL_H) |
| 735 | check_include_file_concat("idn2.h" HAVE_IDN2_H) |
| 736 | check_include_file_concat("ifaddrs.h" HAVE_IFADDRS_H) |
| 737 | check_include_file_concat("io.h" HAVE_IO_H) |
| 738 | check_include_file_concat("krb.h" HAVE_KRB_H) |
| 739 | check_include_file_concat("libgen.h" HAVE_LIBGEN_H) |
| 740 | check_include_file_concat("limits.h" HAVE_LIMITS_H) |
| 741 | check_include_file_concat("locale.h" HAVE_LOCALE_H) |
| 742 | check_include_file_concat("net/if.h" HAVE_NET_IF_H) |
| 743 | check_include_file_concat("netdb.h" HAVE_NETDB_H) |
| 744 | check_include_file_concat("netinet/in.h" HAVE_NETINET_IN_H) |
| 745 | check_include_file_concat("netinet/tcp.h" HAVE_NETINET_TCP_H) |
| 746 | |
| 747 | check_include_file_concat("pem.h" HAVE_PEM_H) |
| 748 | check_include_file_concat("poll.h" HAVE_POLL_H) |
| 749 | check_include_file_concat("pwd.h" HAVE_PWD_H) |
| 750 | check_include_file_concat("rsa.h" HAVE_RSA_H) |
| 751 | check_include_file_concat("setjmp.h" HAVE_SETJMP_H) |
| 752 | check_include_file_concat("sgtty.h" HAVE_SGTTY_H) |
| 753 | check_include_file_concat("signal.h" HAVE_SIGNAL_H) |
| 754 | check_include_file_concat("ssl.h" HAVE_SSL_H) |
| 755 | check_include_file_concat("stdbool.h" HAVE_STDBOOL_H) |
| 756 | check_include_file_concat("stdint.h" HAVE_STDINT_H) |
| 757 | check_include_file_concat("stdio.h" HAVE_STDIO_H) |
| 758 | check_include_file_concat("stdlib.h" HAVE_STDLIB_H) |
| 759 | check_include_file_concat("string.h" HAVE_STRING_H) |
| 760 | check_include_file_concat("strings.h" HAVE_STRINGS_H) |
| 761 | check_include_file_concat("stropts.h" HAVE_STROPTS_H) |
| 762 | check_include_file_concat("termio.h" HAVE_TERMIO_H) |
| 763 | check_include_file_concat("termios.h" HAVE_TERMIOS_H) |
| 764 | check_include_file_concat("time.h" HAVE_TIME_H) |
| 765 | check_include_file_concat("unistd.h" HAVE_UNISTD_H) |
| 766 | check_include_file_concat("utime.h" HAVE_UTIME_H) |
| 767 | check_include_file_concat("x509.h" HAVE_X509_H) |
| 768 | |
| 769 | check_include_file_concat("process.h" HAVE_PROCESS_H) |
| 770 | check_include_file_concat("stddef.h" HAVE_STDDEF_H) |
| 771 | check_include_file_concat("dlfcn.h" HAVE_DLFCN_H) |
| 772 | check_include_file_concat("malloc.h" HAVE_MALLOC_H) |
| 773 | check_include_file_concat("memory.h" HAVE_MEMORY_H) |
| 774 | check_include_file_concat("netinet/if_ether.h" HAVE_NETINET_IF_ETHER_H) |
| 775 | check_include_file_concat("stdint.h" HAVE_STDINT_H) |
| 776 | check_include_file_concat("sockio.h" HAVE_SOCKIO_H) |
| 777 | check_include_file_concat("sys/utsname.h" HAVE_SYS_UTSNAME_H) |
| 778 | |
| 779 | check_type_size(size_t SIZEOF_SIZE_T) |
| 780 | check_type_size(ssize_t SIZEOF_SSIZE_T) |
| 781 | check_type_size("long long" SIZEOF_LONG_LONG) |
| 782 | check_type_size("long" SIZEOF_LONG) |
| 783 | check_type_size("short" SIZEOF_SHORT) |
| 784 | check_type_size("int" SIZEOF_INT) |
| 785 | check_type_size("__int64" SIZEOF___INT64) |
| 786 | check_type_size("long double" SIZEOF_LONG_DOUBLE) |
| 787 | check_type_size("time_t" SIZEOF_TIME_T) |
| 788 | if(NOT HAVE_SIZEOF_SSIZE_T) |
| 789 | if(SIZEOF_LONG EQUAL SIZEOF_SIZE_T) |
| 790 | set(ssize_t long) |
| 791 | endif(SIZEOF_LONG EQUAL SIZEOF_SIZE_T) |
| 792 | if(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T) |
| 793 | set(ssize_t __int64) |
| 794 | endif(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T) |
| 795 | endif(NOT HAVE_SIZEOF_SSIZE_T) |
| 796 | # off_t is sized later, after the HAVE_FILE_OFFSET_BITS test |
| 797 | |
| 798 | # Different sizeofs, etc. |
| 799 | |
| 800 | # define CURL_SIZEOF_LONG 4 |
| 801 | # define CURL_TYPEOF_CURL_OFF_T long long |
| 802 | # define CURL_FORMAT_CURL_OFF_T "lld" |
| 803 | # define CURL_FORMAT_CURL_OFF_TU "llu" |
| 804 | # define CURL_FORMAT_OFF_T "%lld" |
| 805 | # define CURL_SIZEOF_CURL_OFF_T 8 |
| 806 | # define CURL_SUFFIX_CURL_OFF_T LL |
| 807 | # define CURL_SUFFIX_CURL_OFF_TU ULL |
| 808 | |
| 809 | set(CURL_SIZEOF_LONG ${SIZEOF_LONG}) |
| 810 | |
| 811 | if(SIZEOF_LONG EQUAL 8) |
| 812 | set(CURL_TYPEOF_CURL_OFF_T long) |
| 813 | set(CURL_SIZEOF_CURL_OFF_T 8) |
| 814 | set(CURL_FORMAT_CURL_OFF_T "ld") |
| 815 | set(CURL_FORMAT_CURL_OFF_TU "lu") |
| 816 | set(CURL_FORMAT_OFF_T "%ld") |
| 817 | set(CURL_SUFFIX_CURL_OFF_T L) |
| 818 | set(CURL_SUFFIX_CURL_OFF_TU UL) |
| 819 | endif(SIZEOF_LONG EQUAL 8) |
| 820 | |
| 821 | if(SIZEOF_LONG_LONG EQUAL 8) |
| 822 | set(CURL_TYPEOF_CURL_OFF_T "long long") |
| 823 | set(CURL_SIZEOF_CURL_OFF_T 8) |
| 824 | set(CURL_FORMAT_CURL_OFF_T "lld") |
| 825 | set(CURL_FORMAT_CURL_OFF_TU "llu") |
| 826 | set(CURL_FORMAT_OFF_T "%lld") |
| 827 | set(CURL_SUFFIX_CURL_OFF_T LL) |
| 828 | set(CURL_SUFFIX_CURL_OFF_TU ULL) |
| 829 | endif(SIZEOF_LONG_LONG EQUAL 8) |
| 830 | |
| 831 | if(NOT CURL_TYPEOF_CURL_OFF_T) |
| 832 | set(CURL_TYPEOF_CURL_OFF_T ${ssize_t}) |
| 833 | set(CURL_SIZEOF_CURL_OFF_T ${SIZEOF_SSIZE_T}) |
| 834 | # TODO: need adjustment here. |
| 835 | set(CURL_FORMAT_CURL_OFF_T "ld") |
| 836 | set(CURL_FORMAT_CURL_OFF_TU "lu") |
| 837 | set(CURL_FORMAT_OFF_T "%ld") |
| 838 | set(CURL_SUFFIX_CURL_OFF_T L) |
| 839 | set(CURL_SUFFIX_CURL_OFF_TU LU) |
| 840 | endif(NOT CURL_TYPEOF_CURL_OFF_T) |
| 841 | |
| 842 | if(HAVE_SIZEOF_LONG_LONG) |
| 843 | set(HAVE_LONGLONG 1) |
| 844 | set(HAVE_LL 1) |
| 845 | endif(HAVE_SIZEOF_LONG_LONG) |
| 846 | |
| 847 | find_file(RANDOM_FILE urandom /dev) |
| 848 | mark_as_advanced(RANDOM_FILE) |
| 849 | |
| 850 | # Check for some functions that are used |
| 851 | if(HAVE_LIBWS2_32) |
| 852 | set(CMAKE_REQUIRED_LIBRARIES ws2_32) |
| 853 | elseif(HAVE_LIBSOCKET) |
| 854 | set(CMAKE_REQUIRED_LIBRARIES socket) |
| 855 | endif() |
| 856 | |
| 857 | check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME) |
| 858 | check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET) |
| 859 | # poll on macOS is unreliable, it first did not exist, then was broken until |
| 860 | # fixed in 10.9 only to break again in 10.12. |
| 861 | if(NOT APPLE) |
| 862 | check_symbol_exists(poll "${CURL_INCLUDES}" HAVE_POLL) |
| 863 | endif() |
| 864 | check_symbol_exists(select "${CURL_INCLUDES}" HAVE_SELECT) |
| 865 | check_symbol_exists(strdup "${CURL_INCLUDES}" HAVE_STRDUP) |
| 866 | check_symbol_exists(strstr "${CURL_INCLUDES}" HAVE_STRSTR) |
| 867 | check_symbol_exists(strtok_r "${CURL_INCLUDES}" HAVE_STRTOK_R) |
| 868 | check_symbol_exists(strftime "${CURL_INCLUDES}" HAVE_STRFTIME) |
| 869 | check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME) |
| 870 | check_symbol_exists(strcasecmp "${CURL_INCLUDES}" HAVE_STRCASECMP) |
| 871 | check_symbol_exists(stricmp "${CURL_INCLUDES}" HAVE_STRICMP) |
| 872 | check_symbol_exists(strcmpi "${CURL_INCLUDES}" HAVE_STRCMPI) |
| 873 | check_symbol_exists(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI) |
| 874 | check_symbol_exists(alarm "${CURL_INCLUDES}" HAVE_ALARM) |
| 875 | if(NOT HAVE_STRNCMPI) |
| 876 | set(HAVE_STRCMPI) |
| 877 | endif(NOT HAVE_STRNCMPI) |
| 878 | check_symbol_exists(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR) |
| 879 | check_symbol_exists(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R) |
| 880 | check_symbol_exists(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY) |
| 881 | check_symbol_exists(inet_addr "${CURL_INCLUDES}" HAVE_INET_ADDR) |
| 882 | check_symbol_exists(inet_ntoa "${CURL_INCLUDES}" HAVE_INET_NTOA) |
| 883 | check_symbol_exists(inet_ntoa_r "${CURL_INCLUDES}" HAVE_INET_NTOA_R) |
| 884 | check_symbol_exists(tcsetattr "${CURL_INCLUDES}" HAVE_TCSETATTR) |
| 885 | check_symbol_exists(tcgetattr "${CURL_INCLUDES}" HAVE_TCGETATTR) |
| 886 | check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR) |
| 887 | check_symbol_exists(closesocket "${CURL_INCLUDES}" HAVE_CLOSESOCKET) |
| 888 | check_symbol_exists(setvbuf "${CURL_INCLUDES}" HAVE_SETVBUF) |
| 889 | check_symbol_exists(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP) |
| 890 | check_symbol_exists(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R) |
| 891 | check_symbol_exists(strlcat "${CURL_INCLUDES}" HAVE_STRLCAT) |
| 892 | check_symbol_exists(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID) |
| 893 | check_symbol_exists(geteuid "${CURL_INCLUDES}" HAVE_GETEUID) |
| 894 | check_symbol_exists(utime "${CURL_INCLUDES}" HAVE_UTIME) |
| 895 | check_symbol_exists(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R) |
| 896 | check_symbol_exists(localtime_r "${CURL_INCLUDES}" HAVE_LOCALTIME_R) |
| 897 | |
| 898 | check_symbol_exists(gethostbyname "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME) |
| 899 | check_symbol_exists(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R) |
| 900 | |
| 901 | check_symbol_exists(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC) |
| 902 | check_symbol_exists(SIGALRM "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO) |
| 903 | if(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO) |
| 904 | set(HAVE_SIGNAL 1) |
| 905 | endif(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO) |
| 906 | check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME) |
| 907 | check_symbol_exists(strtoll "${CURL_INCLUDES}" HAVE_STRTOLL) |
| 908 | check_symbol_exists(_strtoi64 "${CURL_INCLUDES}" HAVE__STRTOI64) |
| 909 | check_symbol_exists(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R) |
| 910 | check_symbol_exists(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT) |
| 911 | check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR) |
| 912 | check_symbol_exists(fork "${CURL_INCLUDES}" HAVE_FORK) |
| 913 | check_symbol_exists(getaddrinfo "${CURL_INCLUDES}" HAVE_GETADDRINFO) |
| 914 | check_symbol_exists(freeaddrinfo "${CURL_INCLUDES}" HAVE_FREEADDRINFO) |
| 915 | check_symbol_exists(freeifaddrs "${CURL_INCLUDES}" HAVE_FREEIFADDRS) |
| 916 | check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE) |
| 917 | check_symbol_exists(ftruncate "${CURL_INCLUDES}" HAVE_FTRUNCATE) |
| 918 | check_symbol_exists(getprotobyname "${CURL_INCLUDES}" HAVE_GETPROTOBYNAME) |
| 919 | check_symbol_exists(getrlimit "${CURL_INCLUDES}" HAVE_GETRLIMIT) |
| 920 | check_symbol_exists(setlocale "${CURL_INCLUDES}" HAVE_SETLOCALE) |
| 921 | check_symbol_exists(setrlimit "${CURL_INCLUDES}" HAVE_SETRLIMIT) |
| 922 | check_symbol_exists(fcntl "${CURL_INCLUDES}" HAVE_FCNTL) |
| 923 | check_symbol_exists(ioctl "${CURL_INCLUDES}" HAVE_IOCTL) |
| 924 | check_symbol_exists(setsockopt "${CURL_INCLUDES}" HAVE_SETSOCKOPT) |
| 925 | |
| 926 | # symbol exists in win32, but function does not. |
| 927 | check_function_exists(inet_pton HAVE_INET_PTON) |
| 928 | |
| 929 | check_symbol_exists(fsetxattr "${CURL_INCLUDES}" HAVE_FSETXATTR) |
| 930 | if(HAVE_FSETXATTR) |
| 931 | foreach(CURL_TEST HAVE_FSETXATTR_5 HAVE_FSETXATTR_6) |
| 932 | curl_internal_test_run(${CURL_TEST}) |
| 933 | endforeach(CURL_TEST) |
| 934 | endif(HAVE_FSETXATTR) |
| 935 | |
| 936 | # sigaction and sigsetjmp are special. Use special mechanism for |
| 937 | # detecting those, but only if previous attempt failed. |
| 938 | if(HAVE_SIGNAL_H) |
| 939 | check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION) |
| 940 | endif(HAVE_SIGNAL_H) |
| 941 | |
| 942 | if(NOT HAVE_SIGSETJMP) |
| 943 | if(HAVE_SETJMP_H) |
| 944 | check_symbol_exists(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP) |
| 945 | if(HAVE_MACRO_SIGSETJMP) |
| 946 | set(HAVE_SIGSETJMP 1) |
| 947 | endif(HAVE_MACRO_SIGSETJMP) |
| 948 | endif(HAVE_SETJMP_H) |
| 949 | endif(NOT HAVE_SIGSETJMP) |
| 950 | |
| 951 | # If there is no stricmp(), do not allow LDAP to parse URLs |
| 952 | if(NOT HAVE_STRICMP) |
| 953 | set(HAVE_LDAP_URL_PARSE 1) |
| 954 | endif(NOT HAVE_STRICMP) |
| 955 | |
| 956 | # Do curl specific tests |
| 957 | foreach(CURL_TEST |
| 958 | HAVE_FCNTL_O_NONBLOCK |
| 959 | HAVE_IOCTLSOCKET |
| 960 | HAVE_IOCTLSOCKET_CAMEL |
| 961 | HAVE_IOCTLSOCKET_CAMEL_FIONBIO |
| 962 | HAVE_IOCTLSOCKET_FIONBIO |
| 963 | HAVE_IOCTL_FIONBIO |
| 964 | HAVE_IOCTL_SIOCGIFADDR |
| 965 | HAVE_SETSOCKOPT_SO_NONBLOCK |
| 966 | HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID |
| 967 | TIME_WITH_SYS_TIME |
| 968 | HAVE_O_NONBLOCK |
| 969 | HAVE_GETHOSTBYADDR_R_5 |
| 970 | HAVE_GETHOSTBYADDR_R_7 |
| 971 | HAVE_GETHOSTBYADDR_R_8 |
| 972 | HAVE_GETHOSTBYADDR_R_5_REENTRANT |
| 973 | HAVE_GETHOSTBYADDR_R_7_REENTRANT |
| 974 | HAVE_GETHOSTBYADDR_R_8_REENTRANT |
| 975 | HAVE_GETHOSTBYNAME_R_3 |
| 976 | HAVE_GETHOSTBYNAME_R_5 |
| 977 | HAVE_GETHOSTBYNAME_R_6 |
| 978 | HAVE_GETHOSTBYNAME_R_3_REENTRANT |
| 979 | HAVE_GETHOSTBYNAME_R_5_REENTRANT |
| 980 | HAVE_GETHOSTBYNAME_R_6_REENTRANT |
| 981 | HAVE_SOCKLEN_T |
| 982 | HAVE_IN_ADDR_T |
| 983 | HAVE_BOOL_T |
| 984 | STDC_HEADERS |
| 985 | RETSIGTYPE_TEST |
| 986 | HAVE_INET_NTOA_R_DECL |
| 987 | HAVE_INET_NTOA_R_DECL_REENTRANT |
| 988 | HAVE_GETADDRINFO |
| 989 | HAVE_FILE_OFFSET_BITS |
| 990 | ) |
| 991 | curl_internal_test(${CURL_TEST}) |
| 992 | endforeach(CURL_TEST) |
| 993 | |
| 994 | if(HAVE_FILE_OFFSET_BITS) |
| 995 | set(_FILE_OFFSET_BITS 64) |
| 996 | set(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64") |
| 997 | endif(HAVE_FILE_OFFSET_BITS) |
| 998 | check_type_size("off_t" SIZEOF_OFF_T) |
| 999 | set(CMAKE_REQUIRED_FLAGS) |
| 1000 | |
| 1001 | foreach(CURL_TEST |
| 1002 | HAVE_GLIBC_STRERROR_R |
| 1003 | HAVE_POSIX_STRERROR_R |
| 1004 | ) |
| 1005 | curl_internal_test_run(${CURL_TEST}) |
| 1006 | endforeach(CURL_TEST) |
| 1007 | |
| 1008 | # Check for reentrant |
| 1009 | foreach(CURL_TEST |
| 1010 | HAVE_GETHOSTBYADDR_R_5 |
| 1011 | HAVE_GETHOSTBYADDR_R_7 |
| 1012 | HAVE_GETHOSTBYADDR_R_8 |
| 1013 | HAVE_GETHOSTBYNAME_R_3 |
| 1014 | HAVE_GETHOSTBYNAME_R_5 |
| 1015 | HAVE_GETHOSTBYNAME_R_6 |
| 1016 | HAVE_INET_NTOA_R_DECL_REENTRANT) |
| 1017 | if(NOT ${CURL_TEST}) |
| 1018 | if(${CURL_TEST}_REENTRANT) |
| 1019 | set(NEED_REENTRANT 1) |
| 1020 | endif(${CURL_TEST}_REENTRANT) |
| 1021 | endif(NOT ${CURL_TEST}) |
| 1022 | endforeach(CURL_TEST) |
| 1023 | |
| 1024 | if(NEED_REENTRANT) |
| 1025 | foreach(CURL_TEST |
| 1026 | HAVE_GETHOSTBYADDR_R_5 |
| 1027 | HAVE_GETHOSTBYADDR_R_7 |
| 1028 | HAVE_GETHOSTBYADDR_R_8 |
| 1029 | HAVE_GETHOSTBYNAME_R_3 |
| 1030 | HAVE_GETHOSTBYNAME_R_5 |
| 1031 | HAVE_GETHOSTBYNAME_R_6) |
| 1032 | set(${CURL_TEST} 0) |
| 1033 | if(${CURL_TEST}_REENTRANT) |
| 1034 | set(${CURL_TEST} 1) |
| 1035 | endif(${CURL_TEST}_REENTRANT) |
| 1036 | endforeach(CURL_TEST) |
| 1037 | endif(NEED_REENTRANT) |
| 1038 | |
| 1039 | if(HAVE_INET_NTOA_R_DECL_REENTRANT) |
| 1040 | set(HAVE_INET_NTOA_R_DECL 1) |
| 1041 | set(NEED_REENTRANT 1) |
| 1042 | endif(HAVE_INET_NTOA_R_DECL_REENTRANT) |
| 1043 | |
| 1044 | # Some other minor tests |
| 1045 | |
| 1046 | if(NOT HAVE_IN_ADDR_T) |
| 1047 | set(in_addr_t "unsigned long") |
| 1048 | endif(NOT HAVE_IN_ADDR_T) |
| 1049 | |
| 1050 | # Fix libz / zlib.h |
| 1051 | |
| 1052 | if(NOT CURL_SPECIAL_LIBZ) |
| 1053 | if(NOT HAVE_LIBZ) |
| 1054 | set(HAVE_ZLIB_H 0) |
| 1055 | endif(NOT HAVE_LIBZ) |
| 1056 | |
| 1057 | if(NOT HAVE_ZLIB_H) |
| 1058 | set(HAVE_LIBZ 0) |
| 1059 | endif(NOT HAVE_ZLIB_H) |
| 1060 | endif(NOT CURL_SPECIAL_LIBZ) |
| 1061 | |
| 1062 | # Check for nonblocking |
| 1063 | set(HAVE_DISABLED_NONBLOCKING 1) |
| 1064 | if(HAVE_FIONBIO OR |
| 1065 | HAVE_IOCTLSOCKET OR |
| 1066 | HAVE_IOCTLSOCKET_CASE OR |
| 1067 | HAVE_O_NONBLOCK) |
| 1068 | set(HAVE_DISABLED_NONBLOCKING) |
| 1069 | endif(HAVE_FIONBIO OR |
| 1070 | HAVE_IOCTLSOCKET OR |
| 1071 | HAVE_IOCTLSOCKET_CASE OR |
| 1072 | HAVE_O_NONBLOCK) |
| 1073 | |
| 1074 | if(RETSIGTYPE_TEST) |
| 1075 | set(RETSIGTYPE void) |
| 1076 | else(RETSIGTYPE_TEST) |
| 1077 | set(RETSIGTYPE int) |
| 1078 | endif(RETSIGTYPE_TEST) |
| 1079 | |
| 1080 | if(CMAKE_COMPILER_IS_GNUCC AND APPLE) |
| 1081 | include(CheckCCompilerFlag) |
| 1082 | check_c_compiler_flag(-Wno-long-double HAVE_C_FLAG_Wno_long_double) |
| 1083 | if(HAVE_C_FLAG_Wno_long_double) |
| 1084 | # The Mac version of GCC warns about use of long double. Disable it. |
| 1085 | get_source_file_property(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS) |
| 1086 | if(MPRINTF_COMPILE_FLAGS) |
| 1087 | set(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double") |
| 1088 | else(MPRINTF_COMPILE_FLAGS) |
| 1089 | set(MPRINTF_COMPILE_FLAGS "-Wno-long-double") |
| 1090 | endif(MPRINTF_COMPILE_FLAGS) |
| 1091 | set_source_files_properties(mprintf.c PROPERTIES |
| 1092 | COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS}) |
| 1093 | endif(HAVE_C_FLAG_Wno_long_double) |
| 1094 | endif(CMAKE_COMPILER_IS_GNUCC AND APPLE) |
| 1095 | |
| 1096 | if(HAVE_SOCKLEN_T) |
| 1097 | set(CURL_TYPEOF_CURL_SOCKLEN_T "socklen_t") |
| 1098 | if(WIN32) |
| 1099 | set(CMAKE_EXTRA_INCLUDE_FILES "winsock2.h;ws2tcpip.h") |
| 1100 | elseif(HAVE_SYS_SOCKET_H) |
| 1101 | set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h") |
| 1102 | endif() |
| 1103 | check_type_size("socklen_t" CURL_SIZEOF_CURL_SOCKLEN_T) |
| 1104 | set(CMAKE_EXTRA_INCLUDE_FILES) |
| 1105 | if(NOT HAVE_CURL_SIZEOF_CURL_SOCKLEN_T) |
| 1106 | message(FATAL_ERROR |
| 1107 | "Check for sizeof socklen_t failed, see CMakeFiles/CMakerror.log") |
| 1108 | endif() |
| 1109 | else() |
| 1110 | set(CURL_TYPEOF_CURL_SOCKLEN_T int) |
| 1111 | set(CURL_SIZEOF_CURL_SOCKLEN_T ${SIZEOF_INT}) |
| 1112 | endif() |
| 1113 | |
| 1114 | # TODO test which of these headers are required for the typedefs used in curlbuild.h |
| 1115 | if(WIN32) |
| 1116 | set(CURL_PULL_WS2TCPIP_H ${HAVE_WS2TCPIP_H}) |
| 1117 | else() |
| 1118 | set(CURL_PULL_SYS_TYPES_H ${HAVE_SYS_TYPES_H}) |
| 1119 | set(CURL_PULL_SYS_SOCKET_H ${HAVE_SYS_SOCKET_H}) |
| 1120 | set(CURL_PULL_SYS_POLL_H ${HAVE_SYS_POLL_H}) |
| 1121 | endif() |
| 1122 | set(CURL_PULL_STDINT_H ${HAVE_STDINT_H}) |
| 1123 | set(CURL_PULL_INTTYPES_H ${HAVE_INTTYPES_H}) |
| 1124 | |
| 1125 | include(CMake/OtherTests.cmake) |
| 1126 | |
| 1127 | add_definitions(-DHAVE_CONFIG_H) |
| 1128 | |
| 1129 | # For windows, do not allow the compiler to use default target (Vista). |
| 1130 | if(WIN32) |
| 1131 | add_definitions(-D_WIN32_WINNT=0x0501) |
| 1132 | endif(WIN32) |
| 1133 | |
| 1134 | # For windows, all compilers used by cmake should support large files |
| 1135 | if(WIN32) |
| 1136 | set(USE_WIN32_LARGE_FILES ON) |
| 1137 | endif(WIN32) |
| 1138 | |
| 1139 | if(MSVC) |
| 1140 | add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) |
| 1141 | endif(MSVC) |
| 1142 | |
| 1143 | # Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it). |
| 1144 | function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE) |
| 1145 | file(READ ${INPUT_FILE} MAKEFILE_INC_TEXT) |
| 1146 | string(REPLACE "$(top_srcdir)" "\${CURL_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) |
| 1147 | string(REPLACE "$(top_builddir)" "\${CURL_BINARY_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) |
| 1148 | |
| 1149 | string(REGEX REPLACE "\\\\\n" "!π!α!" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) |
| 1150 | string(REGEX REPLACE "([a-zA-Z_][a-zA-Z0-9_]*)[\t ]*=[\t ]*([^\n]*)" "SET(\\1 \\2)" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) |
| 1151 | string(REPLACE "!π!α!" "\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) |
| 1152 | |
| 1153 | string(REGEX REPLACE "\\$\\(([a-zA-Z_][a-zA-Z0-9_]*)\\)" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace $() with ${} |
| 1154 | 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. |
| 1155 | file(WRITE ${OUTPUT_FILE} ${MAKEFILE_INC_TEXT}) |
| 1156 | |
| 1157 | endfunction() |
| 1158 | |
| 1159 | add_subdirectory(docs) |
| 1160 | add_subdirectory(lib) |
| 1161 | if(BUILD_CURL_EXE) |
| 1162 | add_subdirectory(src) |
| 1163 | endif() |
| 1164 | |
| 1165 | include(CTest) |
| 1166 | if(BUILD_TESTING) |
| 1167 | add_subdirectory(tests) |
| 1168 | endif() |
| 1169 | |
| 1170 | # Helper to populate a list (_items) with a label when conditions (the remaining |
| 1171 | # args) are satisfied |
| 1172 | function(_add_if label) |
| 1173 | # TODO need to disable policy CMP0054 (CMake 3.1) to allow this indirection |
| 1174 | if(${ARGN}) |
| 1175 | set(_items ${_items} "${label}" PARENT_SCOPE) |
| 1176 | endif() |
| 1177 | endfunction() |
| 1178 | |
| 1179 | # Clear list and try to detect available features |
| 1180 | set(_items) |
| 1181 | _add_if("WinSSL" SSL_ENABLED AND USE_WINDOWS_SSPI) |
| 1182 | _add_if("OpenSSL" SSL_ENABLED AND USE_OPENSSL) |
| 1183 | _add_if("DarwinSSL" SSL_ENABLED AND USE_DARWINSSL) |
| 1184 | _add_if("mbedTLS" SSL_ENABLED AND USE_MBEDTLS) |
| 1185 | _add_if("IPv6" ENABLE_IPV6) |
| 1186 | _add_if("unix-sockets" USE_UNIX_SOCKETS) |
| 1187 | _add_if("libz" HAVE_LIBZ) |
| 1188 | _add_if("AsynchDNS" USE_ARES OR USE_THREADS_POSIX OR USE_THREADS_WIN32) |
| 1189 | _add_if("IDN" HAVE_LIBIDN2) |
| 1190 | _add_if("Largefile" (CURL_SIZEOF_CURL_OFF_T GREATER 4) AND |
| 1191 | ((SIZEOF_OFF_T GREATER 4) OR USE_WIN32_LARGE_FILES)) |
| 1192 | # TODO SSP1 (WinSSL) check is missing |
| 1193 | _add_if("SSPI" USE_WINDOWS_SSPI) |
| 1194 | _add_if("GSS-API" HAVE_GSSAPI) |
| 1195 | # TODO SSP1 missing for SPNEGO |
| 1196 | _add_if("SPNEGO" NOT CURL_DISABLE_CRYPTO_AUTH AND |
| 1197 | (HAVE_GSSAPI OR USE_WINDOWS_SSPI)) |
| 1198 | _add_if("Kerberos" NOT CURL_DISABLE_CRYPTO_AUTH AND |
| 1199 | (HAVE_GSSAPI OR USE_WINDOWS_SSPI)) |
| 1200 | # NTLM support requires crypto function adaptions from various SSL libs |
| 1201 | # TODO alternative SSL libs tests for SSP1, GNUTLS, NSS |
| 1202 | if(NOT CURL_DISABLE_CRYPTO_AUTH AND (USE_OPENSSL OR USE_WINDOWS_SSPI OR USE_DARWINSSL OR USE_MBEDTLS)) |
| 1203 | _add_if("NTLM" 1) |
| 1204 | # TODO missing option (autoconf: --enable-ntlm-wb) |
| 1205 | _add_if("NTLM_WB" NOT CURL_DISABLE_HTTP AND NTLM_WB_ENABLED) |
| 1206 | endif() |
| 1207 | # TODO missing option (--enable-tls-srp), depends on GNUTLS_SRP/OPENSSL_SRP |
| 1208 | _add_if("TLS-SRP" USE_TLS_SRP) |
| 1209 | # TODO option --with-nghttp2 tests for nghttp2 lib and nghttp2/nghttp2.h header |
| 1210 | _add_if("HTTP2" USE_NGHTTP2) |
| 1211 | string(REPLACE ";" " " SUPPORT_FEATURES "${_items}") |
| 1212 | message(STATUS "Enabled features: ${SUPPORT_FEATURES}") |
| 1213 | |
| 1214 | # Clear list and try to detect available protocols |
| 1215 | set(_items) |
| 1216 | _add_if("HTTP" NOT CURL_DISABLE_HTTP) |
| 1217 | _add_if("HTTPS" NOT CURL_DISABLE_HTTP AND SSL_ENABLED) |
| 1218 | _add_if("FTP" NOT CURL_DISABLE_FTP) |
| 1219 | _add_if("FTPS" NOT CURL_DISABLE_FTP AND SSL_ENABLED) |
| 1220 | _add_if("FILE" NOT CURL_DISABLE_FILE) |
| 1221 | _add_if("TELNET" NOT CURL_DISABLE_TELNET) |
| 1222 | _add_if("LDAP" NOT CURL_DISABLE_LDAP) |
| 1223 | # CURL_DISABLE_LDAP implies CURL_DISABLE_LDAPS |
| 1224 | # TODO check HAVE_LDAP_SSL (in autoconf this is enabled with --enable-ldaps) |
| 1225 | _add_if("LDAPS" NOT CURL_DISABLE_LDAPS AND |
| 1226 | ((USE_OPENLDAP AND SSL_ENABLED) OR |
| 1227 | (NOT USE_OPENLDAP AND HAVE_LDAP_SSL))) |
| 1228 | _add_if("DICT" NOT CURL_DISABLE_DICT) |
| 1229 | _add_if("TFTP" NOT CURL_DISABLE_TFTP) |
| 1230 | _add_if("GOPHER" NOT CURL_DISABLE_GOPHER) |
| 1231 | _add_if("POP3" NOT CURL_DISABLE_POP3) |
| 1232 | _add_if("POP3S" NOT CURL_DISABLE_POP3 AND SSL_ENABLED) |
| 1233 | _add_if("IMAP" NOT CURL_DISABLE_IMAP) |
| 1234 | _add_if("IMAPS" NOT CURL_DISABLE_IMAP AND SSL_ENABLED) |
| 1235 | _add_if("SMTP" NOT CURL_DISABLE_SMTP) |
| 1236 | _add_if("SMTPS" NOT CURL_DISABLE_SMTP AND SSL_ENABLED) |
| 1237 | _add_if("SCP" USE_LIBSSH2) |
| 1238 | _add_if("SFTP" USE_LIBSSH2) |
| 1239 | _add_if("RTSP" NOT CURL_DISABLE_RTSP) |
| 1240 | _add_if("RTMP" USE_LIBRTMP) |
| 1241 | list(SORT _items) |
| 1242 | string(REPLACE ";" " " SUPPORT_PROTOCOLS "${_items}") |
| 1243 | message(STATUS "Enabled protocols: ${SUPPORT_PROTOCOLS}") |
| 1244 | |
| 1245 | # curl-config needs the following options to be set. |
| 1246 | set(CC "${CMAKE_C_COMPILER}") |
| 1247 | # TODO probably put a -D... options here? |
| 1248 | set(CONFIGURE_OPTIONS "") |
| 1249 | # TODO when to set "-DCURL_STATICLIB" for CPPFLAG_CURL_STATICLIB? |
| 1250 | set(CPPFLAG_CURL_STATICLIB "") |
| 1251 | set(CURLVERSION "${CURL_VERSION}") |
| 1252 | set(ENABLE_SHARED "yes") |
| 1253 | if(CURL_STATICLIB) |
| 1254 | set(ENABLE_STATIC "yes") |
| 1255 | else() |
| 1256 | set(ENABLE_STATIC "no") |
| 1257 | endif() |
| 1258 | set(exec_prefix "\${prefix}") |
| 1259 | set(includedir "\${prefix}/include") |
| 1260 | set(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}") |
| 1261 | set(LIBCURL_LIBS "") |
| 1262 | set(libdir "${CMAKE_INSTALL_PREFIX}/lib") |
| 1263 | foreach(_lib ${CMAKE_C_IMPLICIT_LINK_LIBRARIES} ${CURL_LIBS}) |
| 1264 | if(_lib MATCHES ".*/.*") |
| 1265 | set(LIBCURL_LIBS "${LIBCURL_LIBS} ${_lib}") |
| 1266 | else() |
| 1267 | set(LIBCURL_LIBS "${LIBCURL_LIBS} -l${_lib}") |
| 1268 | endif() |
| 1269 | endforeach() |
| 1270 | # "a" (Linux) or "lib" (Windows) |
| 1271 | string(REPLACE "." "" libext "${CMAKE_STATIC_LIBRARY_SUFFIX}") |
| 1272 | set(prefix "${CMAKE_INSTALL_PREFIX}") |
| 1273 | # Set this to "yes" to append all libraries on which -lcurl is dependent |
| 1274 | set(REQUIRE_LIB_DEPS "no") |
| 1275 | # SUPPORT_FEATURES |
| 1276 | # SUPPORT_PROTOCOLS |
| 1277 | set(VERSIONNUM "${CURL_VERSION_NUM}") |
| 1278 | |
| 1279 | # Finally generate a "curl-config" matching this config |
| 1280 | configure_file("${CURL_SOURCE_DIR}/curl-config.in" |
| 1281 | "${CURL_BINARY_DIR}/curl-config" @ONLY) |
| 1282 | install(FILES "${CURL_BINARY_DIR}/curl-config" |
| 1283 | DESTINATION bin |
| 1284 | PERMISSIONS |
| 1285 | OWNER_READ OWNER_WRITE OWNER_EXECUTE |
| 1286 | GROUP_READ GROUP_EXECUTE |
| 1287 | WORLD_READ WORLD_EXECUTE) |
| 1288 | |
| 1289 | # Finally generate a pkg-config file matching this config |
| 1290 | configure_file("${CURL_SOURCE_DIR}/libcurl.pc.in" |
| 1291 | "${CURL_BINARY_DIR}/libcurl.pc" @ONLY) |
| 1292 | install(FILES "${CURL_BINARY_DIR}/libcurl.pc" |
| 1293 | DESTINATION lib/pkgconfig) |
| 1294 | |
| 1295 | # This needs to be run very last so other parts of the scripts can take advantage of this. |
| 1296 | if(NOT CURL_CONFIG_HAS_BEEN_RUN_BEFORE) |
| 1297 | 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") |
| 1298 | endif() |
| 1299 | |
| 1300 | # Installation. |
| 1301 | # First, install generated curlbuild.h |
| 1302 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/curl/curlbuild.h" |
| 1303 | DESTINATION include/curl ) |
| 1304 | # Next, install other headers excluding curlbuild.h |
| 1305 | install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/curl" |
| 1306 | DESTINATION include |
| 1307 | FILES_MATCHING PATTERN "*.h" |
| 1308 | PATTERN "curlbuild.h" EXCLUDE) |
| 1309 | |
| 1310 | |
| 1311 | # Workaround for MSVS10 to avoid the Dialog Hell |
| 1312 | # FIXME: This could be removed with future version of CMake. |
| 1313 | if(MSVC_VERSION EQUAL 1600) |
| 1314 | set(CURL_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/CURL.sln") |
| 1315 | if(EXISTS "${CURL_SLN_FILENAME}") |
| 1316 | file(APPEND "${CURL_SLN_FILENAME}" "\n# This should be regenerated!\n") |
| 1317 | endif() |
| 1318 | endif() |