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