1# Set curl options as needed for CMake build 2set(BUILD_CURL_EXE OFF CACHE INTERNAL "No curl exe") 3set(BUILD_DASHBOARD_REPORTS OFF CACHE INTERNAL "No curl dashboard reports") 4set(BUILD_RELEASE_DEBUG_DIRS OFF CACHE INTERNAL "No curl release/debug dirs") 5set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build shared libraries") 6set(CMAKE_USE_GSSAPI OFF CACHE INTERNAL "Disable curl gssapi") 7set(CMAKE_USE_LIBSSH2 OFF CACHE INTERNAL "Disable curl libssh2") 8set(CMAKE_USE_LIBSSH OFF) 9set(CMAKE_USE_OPENLDAP OFF CACHE INTERNAL "No curl OpenLDAP") 10set(CURL_BROTLI OFF) 11set(CURL_DISABLE_ALTSVC ON) 12set(CURL_DISABLE_COOKIES OFF CACHE INTERNAL "Do not disable curl cookie support") 13set(CURL_DISABLE_CRYPTO_AUTH OFF CACHE INTERNAL "Do not disable curl crypto auth") 14set(CURL_DISABLE_DICT ON CACHE INTERNAL "Disable curl dict protocol?") 15set(CURL_DISABLE_DOH OFF) 16set(CURL_DISABLE_FILE OFF CACHE INTERNAL "Disable curl file protocol?") 17set(CURL_DISABLE_FTP OFF CACHE INTERNAL "Disable curl ftp protocol?") 18set(CURL_DISABLE_GETOPTIONS OFF) 19set(CURL_DISABLE_GOPHER ON CACHE INTERNAL "Disable curl gopher protocol?") 20set(CURL_DISABLE_HSTS ON) 21set(CURL_DISABLE_HTTP_AUTH OFF) 22set(CURL_DISABLE_HTTP OFF CACHE INTERNAL "Disable curl http protocol?") 23set(CURL_DISABLE_IMAP ON CACHE INTERNAL "Disable curl imap protocol?") 24set(CURL_DISABLE_LDAP ON CACHE INTERNAL "Disable curl ldap protocol?") 25set(CURL_DISABLE_LDAPS ON CACHE INTERNAL "Disable curl ldaps protocol?") 26set(CURL_DISABLE_LIBCURL_OPTION OFF) 27set(CURL_DISABLE_MIME OFF) 28set(CURL_DISABLE_MQTT ON) 29set(CURL_DISABLE_NETRC OFF) 30set(CURL_DISABLE_NTLM OFF) 31set(CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG OFF) 32set(CURL_DISABLE_PARSEDATE OFF) 33set(CURL_DISABLE_POP3 ON CACHE INTERNAL "Disable curl pop3 protocol?") 34set(CURL_DISABLE_PROGRESS_METER OFF) 35set(CURL_DISABLE_PROXY OFF CACHE INTERNAL "Do not disable curl proxy") 36set(CURL_DISABLE_RTSP ON CACHE INTERNAL "Disable curl rtsp protocol?") 37set(CURL_DISABLE_SHUFFLE_DNS OFF) 38set(CURL_DISABLE_SMB OFF) 39set(CURL_DISABLE_SMTP ON CACHE INTERNAL "Disable curl smtp protocol?") 40set(CURL_DISABLE_SOCKETPAIR OFF) 41set(CURL_DISABLE_TELNET ON CACHE INTERNAL "Disable curl telnet protocol?") 42set(CURL_DISABLE_TFTP ON CACHE INTERNAL "Disable curl tftp protocol?") 43set(CURL_DISABLE_VERBOSE_STRINGS OFF CACHE INTERNAL "Do not disable curl verbosity") 44set(CURL_ENABLE_EXPORT_TARGET OFF) 45set(CURL_HIDDEN_SYMBOLS OFF CACHE INTERNAL "No curl hidden symbols") 46set(CURL_LTO OFF CACHE INTERNAL "Turn on compiler Link Time Optimizations") 47set(CURL_STATIC_CRT OFF CACHE INTERNAL "Set to ON to build libcurl with static CRT on Windows (/MT).") 48set(CURL_WERROR OFF CACHE INTERNAL "Turn compiler warnings into errors") 49set(CURL_ZSTD OFF) 50set(DISABLED_THREADSAFE OFF CACHE INTERNAL "Curl can use thread-safe functions") 51set(ENABLE_ARES OFF CACHE INTERNAL "No curl c-ares support") 52set(ENABLE_ALT_SVC OFF) 53set(ENABLE_CURLDEBUG OFF CACHE INTERNAL "No curl TrackMemory features") 54set(ENABLE_DEBUG OFF CACHE INTERNAL "No curl debug features") 55set(ENABLE_INET_PTON OFF CACHE INTERNAL "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.") 56set(ENABLE_IPV6 ON CACHE INTERNAL "Enable curl IPv6 support detection") 57set(ENABLE_MANUAL OFF CACHE INTERNAL "No curl built-in manual") 58set(ENABLE_THREADED_RESOLVER OFF CACHE INTERNAL "No curl POSIX threaded DNS lookup") 59set(ENABLE_UNICODE OFF) 60set(ENABLE_UNIX_SOCKETS OFF CACHE INTERNAL "No curl Unix domain sockets support") 61set(HTTP_ONLY OFF CACHE INTERNAL "Curl is not http-only") 62set(PICKY_COMPILER OFF CACHE INTERNAL "Enable picky compiler options") 63set(USE_LIBIDN2 ON) 64set(USE_NGHTTP2 ON) 65set(USE_NGTCP2 OFF) 66set(USE_QUICHE OFF) 67set(USE_WIN32_IDN OFF) 68set(USE_WIN32_LDAP OFF CACHE INTERNAL "No curl Windows LDAP") 69if(CMAKE_USE_OPENSSL) 70elseif(WIN32) 71 unset(CMAKE_USE_WINSSL CACHE) 72 set(CMAKE_USE_SCHANNEL ON) 73 set(CURL_WINDOWS_SSPI ON CACHE INTERNAL "Use windows libraries to allow NTLM authentication without openssl") 74elseif(APPLE) 75 # Use OS X SSL/TLS native implementation if available on target version. 76 if(CMAKE_OSX_DEPLOYMENT_TARGET) 77 set(OSX_VERSION ${CMAKE_OSX_DEPLOYMENT_TARGET}) 78 else() 79 execute_process( 80 COMMAND sw_vers -productVersion 81 OUTPUT_VARIABLE OSX_VERSION 82 OUTPUT_STRIP_TRAILING_WHITESPACE 83 ) 84 endif() 85 if(NOT OSX_VERSION VERSION_LESS 10.6 AND 86 CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang") 87 set(CMAKE_USE_SECTRANSP ON CACHE INTERNAL "enable Apple OS native SSL/TLS") 88 else() 89 set(CMAKE_USE_SECTRANSP OFF CACHE INTERNAL "enable Apple OS native SSL/TLS") 90 endif() 91 unset(CMAKE_USE_DARWINSSL CACHE) 92endif() 93set(CMAKE_USE_MBEDTLS OFF CACHE INTERNAL "Enable mbedTLS for SSL/TLS") 94set(CMAKE_USE_BEARSSL OFF CACHE INTERNAL "Enable BearSSL for SSL/TLS") 95set(CMAKE_USE_NSS OFF CACHE INTERNAL "Enable NSS for SSL/TLS") 96set(CMAKE_USE_WOLFSSL OFF) 97 98# Windows Vista and above have inet_pton, but this will link on 99# older versions and then the executable will fail to launch at 100# runtime on older versions because no DLL provides the symbol. 101if(WIN32) 102 set(HAVE_INET_PTON 0 CACHE INTERNAL "Do not use inet_pton") 103endif() 104 105# Starting with OSX 10.11 there is an unrelated libnetwork library which will 106# be picked up during curl configuration. Linking against this library is 107# unnecessary and breaks backward compatibility of the resulting binaries 108# because libnetwork is unavailable on older OSX versions. 109if(APPLE) 110 set(HAVE_LIBNETWORK 0 CACHE INTERNAL "Do not use libnetwork") 111endif(APPLE) 112 113# Disable warnings to avoid changing 3rd party code. 114if(CMAKE_C_COMPILER_ID MATCHES 115 "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$") 116 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") 117elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") 118 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") 119endif() 120 121#*************************************************************************** 122# _ _ ____ _ 123# Project ___| | | | _ \| | 124# / __| | | | |_) | | 125# | (__| |_| | _ <| |___ 126# \___|\___/|_| \_\_____| 127# 128# Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. 129# 130# This software is licensed as described in the file COPYING, which 131# you should have received as part of this distribution. The terms 132# are also available at https://curl.se/docs/copyright.html. 133# 134# You may opt to use, copy, modify, merge, publish, distribute and/or sell 135# copies of the Software, and permit persons to whom the Software is 136# furnished to do so, under the terms of the COPYING file. 137# 138# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 139# KIND, either express or implied. 140# 141########################################################################### 142# curl/libcurl CMake script 143# by Tetetest and Sukender (Benoit Neil) 144 145# TODO: 146# The output .so file lacks the soname number which we currently have within the lib/Makefile.am file 147# Add full (4 or 5 libs) SSL support 148# 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). 149# Check on all possible platforms 150# Test with as many configurations possible (With or without any option) 151# Create scripts that help keeping the CMake build system up to date (to reduce maintenance). According to Tetetest: 152# - lists of headers that 'configure' checks for; 153# - curl-specific tests (the ones that are in m4/curl-*.m4 files); 154# - (most obvious thing:) curl version numbers. 155# Add documentation subproject 156# 157# To check: 158# (From Daniel Stenberg) The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not. 159# (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. 160set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}") 161include(Utilities) 162include(Macros) 163include(CMakeDependentOption) 164include(CheckCCompilerFlag) 165 166project(CURL C) 167 168file(STRINGS ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS REGEX "#define LIBCURL_VERSION( |_NUM )") 169string(REGEX MATCH "#define LIBCURL_VERSION \"[^\"]*" 170 CURL_VERSION ${CURL_VERSION_H_CONTENTS}) 171string(REGEX REPLACE "[^\"]+\"" "" CURL_VERSION ${CURL_VERSION}) 172string(REGEX MATCH "#define LIBCURL_VERSION_NUM 0x[0-9a-fA-F]+" 173 CURL_VERSION_NUM ${CURL_VERSION_H_CONTENTS}) 174string(REGEX REPLACE "[^0]+0x" "" CURL_VERSION_NUM ${CURL_VERSION_NUM}) 175 176 177# Setup package meta-data 178# SET(PACKAGE "curl") 179if(0) # This code not needed for building within CMake. 180message(STATUS "curl version=[${CURL_VERSION}]") 181endif() 182# SET(PACKAGE_TARNAME "curl") 183# SET(PACKAGE_NAME "curl") 184# SET(PACKAGE_VERSION "-") 185# SET(PACKAGE_STRING "curl-") 186# SET(PACKAGE_BUGREPORT "a suitable curl mailing list => https://curl.se/mail/") 187set(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}") 188set(OS "\"${CMAKE_SYSTEM_NAME}\"") 189 190include_directories(${CURL_SOURCE_DIR}/include) 191 192option(CURL_WERROR "Turn compiler warnings into errors" OFF) 193option(PICKY_COMPILER "Enable picky compiler options" ON) 194option(BUILD_CURL_EXE "Set to ON to build curl executable." ON) 195option(BUILD_SHARED_LIBS "Build shared libraries" ON) 196option(ENABLE_ARES "Set to ON to enable c-ares support" OFF) 197if(WIN32) 198 option(CURL_STATIC_CRT "Set to ON to build libcurl with static CRT on Windows (/MT)." OFF) 199 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) 200 option(ENABLE_UNICODE "Set to ON to use the Unicode version of the Windows API functions" OFF) 201 if(0) # This code not needed for building within CMake. 202 set(CURL_TARGET_WINDOWS_VERSION "" CACHE STRING "Minimum target Windows version as hex string") 203 if(CURL_TARGET_WINDOWS_VERSION) 204 add_definitions(-D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}) 205 set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}") 206 elseif(ENABLE_INET_PTON) 207 # _WIN32_WINNT_VISTA (0x0600) 208 add_definitions(-D_WIN32_WINNT=0x0600) 209 set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0600") 210 else() 211 # _WIN32_WINNT_WINXP (0x0501) 212 add_definitions(-D_WIN32_WINNT=0x0501) 213 set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0501") 214 endif() 215 endif() 216 if(ENABLE_UNICODE) 217 add_definitions(-DUNICODE -D_UNICODE) 218 if(MINGW) 219 add_compile_options(-municode) 220 endif() 221 endif() 222endif() 223option(CURL_LTO "Turn on compiler Link Time Optimizations" OFF) 224 225if(0) # This code not needed for building within CMake. 226cmake_dependent_option(ENABLE_THREADED_RESOLVER "Set to ON to enable threaded DNS lookup" 227 ON "NOT ENABLE_ARES" 228 OFF) 229endif() 230 231option(ENABLE_DEBUG "Set to ON to enable curl debug features" OFF) 232option(ENABLE_CURLDEBUG "Set to ON to build with TrackMemory feature enabled" OFF) 233 234if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) 235 if(PICKY_COMPILER) 236 foreach(_CCOPT -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -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 -Wvla -Wdouble-promotion) 237 # surprisingly, CHECK_C_COMPILER_FLAG needs a new variable to store each new 238 # test result in. 239 string(MAKE_C_IDENTIFIER "OPT${_CCOPT}" _optvarname) 240 check_c_compiler_flag(${_CCOPT} ${_optvarname}) 241 if(${_optvarname}) 242 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT}") 243 endif() 244 endforeach() 245 foreach(_CCOPT long-long multichar format-nonliteral sign-conversion system-headers pedantic-ms-format) 246 # GCC only warns about unknown -Wno- options if there are also other diagnostic messages, 247 # so test for the positive form instead 248 string(MAKE_C_IDENTIFIER "OPT${_CCOPT}" _optvarname) 249 check_c_compiler_flag("-W${_CCOPT}" ${_optvarname}) 250 if(${_optvarname}) 251 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-${_CCOPT}") 252 endif() 253 endforeach() 254 endif() 255endif() 256 257if(ENABLE_DEBUG) 258 # DEBUGBUILD will be defined only for Debug builds 259 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUGBUILD>) 260 set(ENABLE_CURLDEBUG ON) 261endif() 262 263if(ENABLE_CURLDEBUG) 264 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS CURLDEBUG) 265endif() 266 267if(0) # This code not needed for building within CMake. 268# For debug libs and exes, add "-d" postfix 269if(NOT DEFINED CMAKE_DEBUG_POSTFIX) 270 set(CMAKE_DEBUG_POSTFIX "-d") 271endif() 272endif() 273 274# initialize CURL_LIBS 275set(CURL_LIBS "") 276 277if(ENABLE_ARES) 278 set(USE_ARES 1) 279 find_package(CARES REQUIRED) 280 list(APPEND CURL_LIBS ${CARES_LIBRARY}) 281endif() 282 283if(0) # This code not needed for building within CMake. 284include(CurlSymbolHiding) 285endif() 286 287option(CURL_ENABLE_EXPORT_TARGET "to enable cmake export target" ON) 288mark_as_advanced(CURL_ENABLE_EXPORT_TARGET) 289 290option(CURL_DISABLE_ALTSVC "disables alt-svc support" OFF) 291mark_as_advanced(CURL_DISABLE_ALTSVC) 292option(CURL_DISABLE_COOKIES "disables cookies support" OFF) 293mark_as_advanced(CURL_DISABLE_COOKIES) 294option(CURL_DISABLE_CRYPTO_AUTH "disables cryptographic authentication" OFF) 295mark_as_advanced(CURL_DISABLE_CRYPTO_AUTH) 296option(CURL_DISABLE_DICT "disables DICT" OFF) 297mark_as_advanced(CURL_DISABLE_DICT) 298option(CURL_DISABLE_DOH "disables DNS-over-HTTPS" OFF) 299mark_as_advanced(CURL_DISABLE_DOH) 300option(CURL_DISABLE_FILE "disables FILE" OFF) 301mark_as_advanced(CURL_DISABLE_FILE) 302option(CURL_DISABLE_FTP "disables FTP" OFF) 303mark_as_advanced(CURL_DISABLE_FTP) 304option(CURL_DISABLE_GETOPTIONS "disables curl_easy_options API for existing options to curl_easy_setopt" OFF) 305mark_as_advanced(CURL_DISABLE_GETOPTIONS) 306option(CURL_DISABLE_GOPHER "disables Gopher" OFF) 307mark_as_advanced(CURL_DISABLE_GOPHER) 308option(CURL_DISABLE_HSTS "disables HSTS support" OFF) 309mark_as_advanced(CURL_DISABLE_HSTS) 310option(CURL_DISABLE_HTTP "disables HTTP" OFF) 311mark_as_advanced(CURL_DISABLE_HTTP) 312option(CURL_DISABLE_HTTP_AUTH "disables all HTTP authentication methods" OFF) 313mark_as_advanced(CURL_DISABLE_HTTP_AUTH) 314option(CURL_DISABLE_IMAP "disables IMAP" OFF) 315mark_as_advanced(CURL_DISABLE_IMAP) 316option(CURL_DISABLE_LDAP "disables LDAP" OFF) 317mark_as_advanced(CURL_DISABLE_LDAP) 318option(CURL_DISABLE_LDAPS "disables LDAPS" OFF) 319mark_as_advanced(CURL_DISABLE_LDAPS) 320option(CURL_DISABLE_LIBCURL_OPTION "disables --libcurl option from the curl tool" OFF) 321mark_as_advanced(CURL_DISABLE_LIBCURL_OPTION) 322option(CURL_DISABLE_MIME "disables MIME support" OFF) 323mark_as_advanced(CURL_DISABLE_MIME) 324option(CURL_DISABLE_MQTT "disables MQTT" OFF) 325mark_as_advanced(CURL_DISABLE_MQTT) 326option(CURL_DISABLE_NETRC "disables netrc parser" OFF) 327mark_as_advanced(CURL_DISABLE_NETRC) 328option(CURL_DISABLE_NTLM "disables NTLM support" OFF) 329mark_as_advanced(CURL_DISABLE_NTLM) 330option(CURL_DISABLE_PARSEDATE "disables date parsing" OFF) 331mark_as_advanced(CURL_DISABLE_PARSEDATE) 332option(CURL_DISABLE_POP3 "disables POP3" OFF) 333mark_as_advanced(CURL_DISABLE_POP3) 334option(CURL_DISABLE_PROGRESS_METER "disables built-in progress meter" OFF) 335mark_as_advanced(CURL_DISABLE_PROGRESS_METER) 336option(CURL_DISABLE_PROXY "disables proxy support" OFF) 337mark_as_advanced(CURL_DISABLE_PROXY) 338option(CURL_DISABLE_RTSP "disables RTSP" OFF) 339mark_as_advanced(CURL_DISABLE_RTSP) 340option(CURL_DISABLE_SHUFFLE_DNS "disables shuffle DNS feature" OFF) 341mark_as_advanced(CURL_DISABLE_SHUFFLE_DNS) 342option(CURL_DISABLE_SMB "disables SMB" OFF) 343mark_as_advanced(CURL_DISABLE_SMB) 344option(CURL_DISABLE_SMTP "disables SMTP" OFF) 345mark_as_advanced(CURL_DISABLE_SMTP) 346option(CURL_DISABLE_SOCKETPAIR "disables use of socketpair for curl_multi_poll" OFF) 347mark_as_advanced(CURL_DISABLE_SOCKETPAIR) 348option(CURL_DISABLE_TELNET "disables Telnet" OFF) 349mark_as_advanced(CURL_DISABLE_TELNET) 350option(CURL_DISABLE_TFTP "disables TFTP" OFF) 351mark_as_advanced(CURL_DISABLE_TFTP) 352option(CURL_DISABLE_VERBOSE_STRINGS "disables verbose strings" OFF) 353mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS) 354 355# Corresponds to HTTP_ONLY in lib/curl_setup.h 356option(HTTP_ONLY "disables all protocols except HTTP (This overrides all CURL_DISABLE_* options)" OFF) 357mark_as_advanced(HTTP_ONLY) 358 359if(HTTP_ONLY) 360 set(CURL_DISABLE_DICT ON) 361 set(CURL_DISABLE_FILE ON) 362 set(CURL_DISABLE_FTP ON) 363 set(CURL_DISABLE_GOPHER ON) 364 set(CURL_DISABLE_IMAP ON) 365 set(CURL_DISABLE_LDAP ON) 366 set(CURL_DISABLE_LDAPS ON) 367 set(CURL_DISABLE_MQTT ON) 368 set(CURL_DISABLE_POP3 ON) 369 set(CURL_DISABLE_RTSP ON) 370 set(CURL_DISABLE_SMB ON) 371 set(CURL_DISABLE_SMTP ON) 372 set(CURL_DISABLE_TELNET ON) 373 set(CURL_DISABLE_TFTP ON) 374endif() 375 376option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON) 377mark_as_advanced(ENABLE_IPV6) 378if(ENABLE_IPV6 AND NOT WIN32) 379 include(CheckStructHasMember) 380 check_struct_has_member("struct sockaddr_in6" sin6_addr "netinet/in.h" 381 HAVE_SOCKADDR_IN6_SIN6_ADDR) 382 check_struct_has_member("struct sockaddr_in6" sin6_scope_id "netinet/in.h" 383 HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID) 384 if(NOT HAVE_SOCKADDR_IN6_SIN6_ADDR) 385 message(WARNING "struct sockaddr_in6 not available, disabling IPv6 support") 386 # Force the feature off as this name is used as guard macro... 387 set(ENABLE_IPV6 OFF 388 CACHE BOOL "Define if you want to enable IPv6 support" FORCE) 389 endif() 390endif() 391 392if(0) # This code not needed for building within CMake. 393if(USE_MANUAL) 394 #nroff is currently only used when USE_MANUAL is set, so we can prevent the warning of no *NROFF if USE_MANUAL is OFF (or not defined), by not even looking for NROFF.. 395 curl_nroff_check() 396endif() 397find_package(Perl) 398 399cmake_dependent_option(ENABLE_MANUAL "to provide the built-in manual" 400 ON "NROFF_USEFUL;PERL_FOUND" 401 OFF) 402 403if(ENABLE_MANUAL) 404 set(USE_MANUAL ON) 405endif() 406endif() 407 408if(CURL_STATIC_CRT) 409 set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") 410 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") 411 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") 412endif() 413 414# Disable warnings on Borland to avoid changing 3rd party code. 415if(BORLAND) 416 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") 417endif() 418 419# If we are on AIX, do the _ALL_SOURCE magic 420if(${CMAKE_SYSTEM_NAME} MATCHES AIX) 421 set(_ALL_SOURCE 1) 422endif() 423 424# Include all the necessary files for macros 425include(CMakePushCheckState) 426include(CheckFunctionExists) 427include(CheckIncludeFile) 428include(CheckIncludeFiles) 429include(CheckLibraryExists) 430include(CheckSymbolExists) 431include(CheckTypeSize) 432include(CheckCSourceCompiles) 433 434# On windows preload settings 435if(WIN32) 436 set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WINSOCKAPI_=") 437 include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Platforms/WindowsCache.cmake) 438endif() 439 440if(ENABLE_THREADED_RESOLVER) 441 find_package(Threads REQUIRED) 442 if(WIN32) 443 set(USE_THREADS_WIN32 ON) 444 else() 445 set(USE_THREADS_POSIX ${CMAKE_USE_PTHREADS_INIT}) 446 set(HAVE_PTHREAD_H ${CMAKE_USE_PTHREADS_INIT}) 447 endif() 448 set(CURL_LIBS ${CURL_LIBS} ${CMAKE_THREAD_LIBS_INIT}) 449endif() 450 451# Check for all needed libraries 452if(0) # This code not needed for building within CMake. 453check_library_exists_concat("${CMAKE_DL_LIBS}" dlopen HAVE_LIBDL) 454else() 455 # Use the cmake-defined dl libs as dl is should not be used 456 # on HPUX, but rather dld this avoids a warning 457 list(APPEND CURL_LIBS ${CMAKE_DL_LIBS}) 458endif() 459check_library_exists_concat("socket" connect HAVE_LIBSOCKET) 460check_library_exists("c" gethostbyname "" NOT_NEED_LIBNSL) 461 462# Yellowtab Zeta needs different libraries than BeOS 5. 463if(BEOS) 464 set(NOT_NEED_LIBNSL 1) 465 check_library_exists_concat("bind" gethostbyname HAVE_LIBBIND) 466 check_library_exists_concat("bnetapi" closesocket HAVE_LIBBNETAPI) 467endif() 468 469check_library_exists_concat("network" recv HAVE_LIBNETWORK) 470 471if(NOT NOT_NEED_LIBNSL) 472 check_library_exists_concat("nsl" gethostbyname HAVE_LIBNSL) 473endif() 474 475check_function_exists(gethostname HAVE_GETHOSTNAME) 476 477if(WIN32) 478 check_library_exists_concat("ws2_32" getch HAVE_LIBWS2_32) 479 check_library_exists_concat("winmm" getch HAVE_LIBWINMM) 480endif() 481 482# check SSL libraries 483# TODO support GnuTLS 484if(CMAKE_USE_WINSSL) 485 message(FATAL_ERROR "The cmake option CMAKE_USE_WINSSL was renamed to CMAKE_USE_SCHANNEL.") 486endif() 487 488if(APPLE) 489 option(CMAKE_USE_SECTRANSP "enable Apple OS native SSL/TLS" OFF) 490endif() 491if(WIN32) 492 option(CMAKE_USE_SCHANNEL "enable Windows native SSL/TLS" OFF) 493 cmake_dependent_option(CURL_WINDOWS_SSPI "Use windows libraries to allow NTLM authentication without openssl" ON 494 CMAKE_USE_SCHANNEL OFF) 495endif() 496option(CMAKE_USE_MBEDTLS "Enable mbedTLS for SSL/TLS" OFF) 497option(CMAKE_USE_BEARSSL "Enable BearSSL for SSL/TLS" OFF) 498option(CMAKE_USE_NSS "Enable NSS for SSL/TLS" OFF) 499option(CMAKE_USE_WOLFSSL "enable wolfSSL for SSL/TLS" OFF) 500 501set(openssl_default ON) 502if(WIN32 OR CMAKE_USE_SECTRANSP OR CMAKE_USE_SCHANNEL OR CMAKE_USE_MBEDTLS OR CMAKE_USE_NSS OR CMAKE_USE_WOLFSSL) 503 set(openssl_default OFF) 504endif() 505option(CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG "Disable automatic loading of OpenSSL configuration" OFF) 506 507count_true(enabled_ssl_options_count 508 CMAKE_USE_SCHANNEL 509 CMAKE_USE_SECTRANSP 510 CMAKE_USE_OPENSSL 511 CMAKE_USE_MBEDTLS 512 CMAKE_USE_BEARSSL 513 CMAKE_USE_NSS 514 CMAKE_USE_WOLFSSL 515) 516if(enabled_ssl_options_count GREATER "1") 517 set(CURL_WITH_MULTI_SSL ON) 518endif() 519 520if(CMAKE_USE_SCHANNEL) 521 set(SSL_ENABLED ON) 522 set(USE_SCHANNEL ON) # Windows native SSL/TLS support 523 set(USE_WINDOWS_SSPI ON) # CMAKE_USE_SCHANNEL implies CURL_WINDOWS_SSPI 524endif() 525if(CURL_WINDOWS_SSPI) 526 set(USE_WINDOWS_SSPI ON) 527 set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DSECURITY_WIN32") 528endif() 529 530if(CMAKE_USE_DARWINSSL) 531 message(FATAL_ERROR "The cmake option CMAKE_USE_DARWINSSL was renamed to CMAKE_USE_SECTRANSP.") 532endif() 533 534if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 535 find_library(COREFOUNDATION_FRAMEWORK "CoreFoundation") 536 if(NOT COREFOUNDATION_FRAMEWORK) 537 message(FATAL_ERROR "CoreFoundation framework not found") 538 endif() 539 540 find_library(SYSTEMCONFIGURATION_FRAMEWORK "SystemConfiguration") 541 if(NOT SYSTEMCONFIGURATION_FRAMEWORK) 542 message(FATAL_ERROR "SystemConfiguration framework not found") 543 endif() 544 545 list(APPEND CURL_LIBS "-framework CoreFoundation" "-framework SystemConfiguration") 546 547 if(CMAKE_USE_SECTRANSP) 548 find_library(SECURITY_FRAMEWORK "Security") 549 if(NOT SECURITY_FRAMEWORK) 550 message(FATAL_ERROR "Security framework not found") 551 endif() 552 553 set(SSL_ENABLED ON) 554 set(USE_SECTRANSP ON) 555 list(APPEND CURL_LIBS "-framework Security") 556 endif() 557endif() 558 559if(CMAKE_USE_OPENSSL) 560 find_package(OpenSSL) 561 if(NOT OpenSSL_FOUND) 562 message(FATAL_ERROR 563 "Could not find OpenSSL. Install an OpenSSL development package or " 564 "configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.") 565 endif() 566 set(SSL_ENABLED ON) 567 set(USE_OPENSSL ON) 568 list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES}) 569 include_directories(${OPENSSL_INCLUDE_DIR}) 570 571 set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) 572 check_include_file("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H) 573 check_include_file("openssl/err.h" HAVE_OPENSSL_ERR_H) 574 check_include_file("openssl/pem.h" HAVE_OPENSSL_PEM_H) 575 check_include_file("openssl/rsa.h" HAVE_OPENSSL_RSA_H) 576 check_include_file("openssl/ssl.h" HAVE_OPENSSL_SSL_H) 577 check_include_file("openssl/x509.h" HAVE_OPENSSL_X509_H) 578 check_include_file("openssl/rand.h" HAVE_OPENSSL_RAND_H) 579 check_symbol_exists(RAND_status "${CURL_INCLUDES}" HAVE_RAND_STATUS) 580 check_symbol_exists(RAND_screen "${CURL_INCLUDES}" HAVE_RAND_SCREEN) 581 check_symbol_exists(RAND_egd "${CURL_INCLUDES}" HAVE_RAND_EGD) 582 583 # Optionally build with a specific CA cert bundle. 584 if(CURL_CA_BUNDLE) 585 add_definitions(-DCURL_CA_BUNDLE="${CURL_CA_BUNDLE}") 586 endif() 587 # Optionally build with a specific CA cert dir. 588 if(CURL_CA_PATH) 589 add_definitions(-DCURL_CA_PATH="${CURL_CA_PATH}") 590 endif() 591endif() 592 593if(CMAKE_USE_MBEDTLS) 594 find_package(MbedTLS REQUIRED) 595 set(SSL_ENABLED ON) 596 set(USE_MBEDTLS ON) 597 list(APPEND CURL_LIBS ${MBEDTLS_LIBRARIES}) 598 include_directories(${MBEDTLS_INCLUDE_DIRS}) 599endif() 600 601if(CMAKE_USE_BEARSSL) 602 find_package(BearSSL REQUIRED) 603 set(SSL_ENABLED ON) 604 set(USE_BEARSSL ON) 605 list(APPEND CURL_LIBS ${BEARSSL_LIBRARY}) 606 include_directories(${BEARSSL_INCLUDE_DIRS}) 607endif() 608 609if(CMAKE_USE_WOLFSSL) 610 find_package(WolfSSL REQUIRED) 611 set(SSL_ENABLED ON) 612 set(USE_WOLFSSL ON) 613 list(APPEND CURL_LIBS ${WolfSSL_LIBRARIES}) 614 include_directories(${WolfSSL_INCLUDE_DIRS}) 615endif() 616 617if(CMAKE_USE_NSS) 618 find_package(NSS REQUIRED) 619 include_directories(${NSS_INCLUDE_DIRS}) 620 list(APPEND CURL_LIBS ${NSS_LIBRARIES}) 621 set(SSL_ENABLED ON) 622 set(USE_NSS ON) 623 cmake_push_check_state() 624 set(CMAKE_REQUIRED_INCLUDES ${NSS_INCLUDE_DIRS}) 625 set(CMAKE_REQUIRED_LIBRARIES ${NSS_LIBRARIES}) 626 check_symbol_exists(PK11_CreateManagedGenericObject "pk11pub.h" HAVE_PK11_CREATEMANAGEDGENERICOBJECT) 627 cmake_pop_check_state() 628endif() 629 630option(USE_NGHTTP2 "Use Nghttp2 library" OFF) 631if(USE_NGHTTP2) 632 find_package(NGHTTP2 REQUIRED) 633 include_directories(${NGHTTP2_INCLUDE_DIRS}) 634 list(APPEND CURL_LIBS ${NGHTTP2_LIBRARIES}) 635endif() 636 637function(CheckQuicSupportInOpenSSL) 638 # Be sure that the OpenSSL library actually supports QUIC. 639 cmake_push_check_state() 640 set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}") 641 set(CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES}") 642 check_symbol_exists(SSL_CTX_set_quic_method "openssl/ssl.h" HAVE_SSL_CTX_SET_QUIC_METHOD) 643 if(NOT HAVE_SSL_CTX_SET_QUIC_METHOD) 644 message(FATAL_ERROR "QUIC support is missing in OpenSSL/boringssl. Try setting -DOPENSSL_ROOT_DIR") 645 endif() 646 cmake_pop_check_state() 647endfunction() 648 649option(USE_NGTCP2 "Use ngtcp2 and nghttp3 libraries for HTTP/3 support" OFF) 650if(USE_NGTCP2) 651 if(USE_OPENSSL) 652 find_package(NGTCP2 REQUIRED OpenSSL) 653 CheckQuicSupportInOpenSSL() 654 elseif(USE_GNUTLS) 655 # TODO add GnuTLS support as vtls library. 656 find_package(NGTCP2 REQUIRED GnuTLS) 657 else() 658 message(FATAL_ERROR "ngtcp2 requires OpenSSL or GnuTLS") 659 endif() 660 set(USE_NGTCP2 ON) 661 include_directories(${NGTCP2_INCLUDE_DIRS}) 662 list(APPEND CURL_LIBS ${NGTCP2_LIBRARIES}) 663 664 find_package(NGHTTP3 REQUIRED) 665 set(USE_NGHTTP3 ON) 666 include_directories(${NGHTTP3_INCLUDE_DIRS}) 667 list(APPEND CURL_LIBS ${NGHTTP3_LIBRARIES}) 668endif() 669 670option(USE_QUICHE "Use quiche library for HTTP/3 support" OFF) 671if(USE_QUICHE) 672 if(USE_NGTCP2) 673 message(FATAL_ERROR "Only one HTTP/3 backend can be selected!") 674 endif() 675 find_package(QUICHE REQUIRED) 676 CheckQuicSupportInOpenSSL() 677 set(USE_QUICHE ON) 678 include_directories(${QUICHE_INCLUDE_DIRS}) 679 list(APPEND CURL_LIBS ${QUICHE_LIBRARIES}) 680 cmake_push_check_state() 681 set(CMAKE_REQUIRED_INCLUDES "${QUICHE_INCLUDE_DIRS}") 682 set(CMAKE_REQUIRED_LIBRARIES "${QUICHE_LIBRARIES}") 683 check_symbol_exists(quiche_conn_set_qlog_fd "quiche.h" HAVE_QUICHE_CONN_SET_QLOG_FD) 684 cmake_pop_check_state() 685endif() 686 687if(NOT CURL_DISABLE_LDAP) 688 if(WIN32) 689 option(USE_WIN32_LDAP "Use Windows LDAP implementation" ON) 690 if(USE_WIN32_LDAP) 691 check_library_exists_concat("wldap32" cldap_open HAVE_WLDAP32) 692 if(NOT HAVE_WLDAP32) 693 set(USE_WIN32_LDAP OFF) 694 endif() 695 endif() 696 endif() 697 698 option(CMAKE_USE_OPENLDAP "Use OpenLDAP code." OFF) 699 mark_as_advanced(CMAKE_USE_OPENLDAP) 700 set(CMAKE_LDAP_LIB "ldap" CACHE STRING "Name or full path to ldap library") 701 set(CMAKE_LBER_LIB "lber" CACHE STRING "Name or full path to lber library") 702 703 if(CMAKE_USE_OPENLDAP AND USE_WIN32_LDAP) 704 message(FATAL_ERROR "Cannot use USE_WIN32_LDAP and CMAKE_USE_OPENLDAP at the same time") 705 endif() 706 707 # Now that we know, we're not using windows LDAP... 708 if(USE_WIN32_LDAP) 709 check_include_file_concat("winldap.h" HAVE_WINLDAP_H) 710 check_include_file_concat("winber.h" HAVE_WINBER_H) 711 else() 712 # Check for LDAP 713 set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) 714 check_library_exists_concat(${CMAKE_LDAP_LIB} ldap_init HAVE_LIBLDAP) 715 check_library_exists_concat(${CMAKE_LBER_LIB} ber_init HAVE_LIBLBER) 716 717 set(CMAKE_REQUIRED_INCLUDES_BAK ${CMAKE_REQUIRED_INCLUDES}) 718 set(CMAKE_LDAP_INCLUDE_DIR "" CACHE STRING "Path to LDAP include directory") 719 if(CMAKE_LDAP_INCLUDE_DIR) 720 list(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_LDAP_INCLUDE_DIR}) 721 endif() 722 check_include_file_concat("ldap.h" HAVE_LDAP_H) 723 check_include_file_concat("lber.h" HAVE_LBER_H) 724 725 if(NOT HAVE_LDAP_H) 726 message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON") 727 set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE) 728 set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) #LDAP includes won't be used 729 elseif(NOT HAVE_LIBLDAP) 730 message(STATUS "LDAP library '${CMAKE_LDAP_LIB}' not found CURL_DISABLE_LDAP set ON") 731 set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE) 732 set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) #LDAP includes won't be used 733 else() 734 if(CMAKE_USE_OPENLDAP) 735 set(USE_OPENLDAP ON) 736 endif() 737 if(CMAKE_LDAP_INCLUDE_DIR) 738 include_directories(${CMAKE_LDAP_INCLUDE_DIR}) 739 endif() 740 set(NEED_LBER_H ON) 741 set(_HEADER_LIST) 742 if(HAVE_WINDOWS_H) 743 list(APPEND _HEADER_LIST "windows.h") 744 endif() 745 if(HAVE_SYS_TYPES_H) 746 list(APPEND _HEADER_LIST "sys/types.h") 747 endif() 748 list(APPEND _HEADER_LIST "ldap.h") 749 750 set(_SRC_STRING "") 751 foreach(_HEADER ${_HEADER_LIST}) 752 set(_INCLUDE_STRING "${_INCLUDE_STRING}#include <${_HEADER}>\n") 753 endforeach() 754 755 set(_SRC_STRING 756 " 757 ${_INCLUDE_STRING} 758 int main(int argc, char ** argv) 759 { 760 BerValue *bvp = NULL; 761 BerElement *bep = ber_init(bvp); 762 ber_free(bep, 1); 763 return 0; 764 }" 765 ) 766 set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DLDAP_DEPRECATED=1") 767 list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB}) 768 if(HAVE_LIBLBER) 769 list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LBER_LIB}) 770 endif() 771 check_c_source_compiles("${_SRC_STRING}" NOT_NEED_LBER_H) 772 unset(CMAKE_REQUIRED_LIBRARIES) 773 774 if(NOT_NEED_LBER_H) 775 set(NEED_LBER_H OFF) 776 else() 777 set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -DNEED_LBER_H") 778 endif() 779 endif() 780 endif() 781endif() 782 783# No ldap, no ldaps. 784if(CURL_DISABLE_LDAP) 785 if(NOT CURL_DISABLE_LDAPS) 786 message(STATUS "LDAP needs to be enabled to support LDAPS") 787 set(CURL_DISABLE_LDAPS ON CACHE BOOL "" FORCE) 788 endif() 789endif() 790 791if(NOT CURL_DISABLE_LDAPS) 792 check_include_file_concat("ldap_ssl.h" HAVE_LDAP_SSL_H) 793 check_include_file_concat("ldapssl.h" HAVE_LDAPSSL_H) 794endif() 795 796# Check for idn 797option(USE_LIBIDN2 "Use libidn2 for IDN support" ON) 798set(HAVE_LIBIDN2 OFF) 799if(USE_LIBIDN2) 800 check_library_exists_concat("idn2" idn2_lookup_ul HAVE_LIBIDN2) 801endif() 802 803if(WIN32) 804 option(USE_WIN32_IDN "Use WinIDN for IDN support" OFF) 805 if(USE_WIN32_IDN) 806 list(APPEND CURL_LIBS "Normaliz") 807 set(WANT_IDN_PROTOTYPES ON) 808 endif() 809endif() 810 811# Check for symbol dlopen (same as HAVE_LIBDL) 812check_library_exists("${CURL_LIBS}" dlopen "" HAVE_DLOPEN) 813 814if(0) # This code not needed for building within CMake. 815set(HAVE_LIBZ OFF) 816set(HAVE_ZLIB_H OFF) 817set(USE_ZLIB OFF) 818optional_dependency(ZLIB) 819if(ZLIB_FOUND) 820 set(HAVE_ZLIB_H ON) 821 set(HAVE_LIBZ ON) 822 set(USE_ZLIB ON) 823 824 # Depend on ZLIB via imported targets if supported by the running 825 # version of CMake. This allows our dependents to get our dependencies 826 # transitively. 827 if(NOT CMAKE_VERSION VERSION_LESS 3.4) 828 list(APPEND CURL_LIBS ZLIB::ZLIB) 829 else() 830 list(APPEND CURL_LIBS ${ZLIB_LIBRARIES}) 831 include_directories(${ZLIB_INCLUDE_DIRS}) 832 endif() 833 list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS}) 834endif() 835endif() 836 837#----------------------------------------------------------------------------- 838# CMake-specific curl code. 839 840if(CURL_SPECIAL_LIBZ) 841 set(CURL_LIBS ${CURL_LIBS} "${CURL_SPECIAL_LIBZ}") 842 include_directories(${CURL_SPECIAL_LIBZ_INCLUDES}) 843 set(HAVE_LIBZ 0) 844 set(HAVE_ZLIB_H 0) 845endif() 846 847option(CURL_BROTLI "Set to ON to enable building curl with brotli support." OFF) 848set(HAVE_BROTLI OFF) 849if(CURL_BROTLI) 850 find_package(Brotli QUIET) 851 if(BROTLI_FOUND) 852 set(HAVE_BROTLI ON) 853 list(APPEND CURL_LIBS ${BROTLI_LIBRARIES}) 854 include_directories(${BROTLI_INCLUDE_DIRS}) 855 list(APPEND CMAKE_REQUIRED_INCLUDES ${BROTLI_INCLUDE_DIRS}) 856 endif() 857endif() 858 859option(CURL_ZSTD "Set to ON to enable building curl with zstd support." OFF) 860set(HAVE_ZSTD OFF) 861if(CURL_ZSTD) 862 find_package(Zstd REQUIRED) 863 cmake_push_check_state() 864 set(CMAKE_REQUIRED_INCLUDES ${Zstd_INCLUDE_DIRS}) 865 set(CMAKE_REQUIRED_LIBRARIES ${Zstd_LIBRARIES}) 866 check_symbol_exists(ZSTD_createDStream "zstd.h" HAVE_ZSTD_CREATEDSTREAM) 867 cmake_pop_check_state() 868 if(Zstd_FOUND AND HAVE_ZSTD_CREATEDSTREAM) 869 set(HAVE_ZSTD ON) 870 list(APPEND CURL_LIBS ${Zstd_LIBRARIES}) 871 include_directories(${Zstd_INCLUDE_DIRS}) 872 endif() 873endif() 874 875#libSSH2 876option(CMAKE_USE_LIBSSH2 "Use libSSH2" ON) 877mark_as_advanced(CMAKE_USE_LIBSSH2) 878set(USE_LIBSSH2 OFF) 879set(HAVE_LIBSSH2 OFF) 880set(HAVE_LIBSSH2_H OFF) 881 882if(CMAKE_USE_LIBSSH2) 883 find_package(LibSSH2) 884 if(LIBSSH2_FOUND) 885 list(APPEND CURL_LIBS ${LIBSSH2_LIBRARY}) 886 set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH2_LIBRARY}) 887 list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIR}") 888 include_directories("${LIBSSH2_INCLUDE_DIR}") 889 set(HAVE_LIBSSH2 ON) 890 set(USE_LIBSSH2 ON) 891 892 # find_package has already found the headers 893 set(HAVE_LIBSSH2_H ON) 894 set(CURL_INCLUDES ${CURL_INCLUDES} "${LIBSSH2_INCLUDE_DIR}/libssh2.h") 895 set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -DHAVE_LIBSSH2_H") 896 unset(CMAKE_REQUIRED_LIBRARIES) 897 endif() 898endif() 899 900# libssh 901option(CMAKE_USE_LIBSSH "Use libSSH" OFF) 902mark_as_advanced(CMAKE_USE_LIBSSH) 903if(NOT HAVE_LIBSSH2 AND CMAKE_USE_LIBSSH) 904 find_package(libssh CONFIG) 905 if(libssh_FOUND) 906 message(STATUS "Found libssh ${libssh_VERSION}") 907 # Use imported target for include and library paths. 908 list(APPEND CURL_LIBS ssh) 909 set(USE_LIBSSH ON) 910 set(HAVE_LIBSSH_LIBSSH_H 1) 911 endif() 912endif() 913 914option(CMAKE_USE_GSSAPI "Use GSSAPI implementation (right now only Heimdal is supported with CMake build)" OFF) 915mark_as_advanced(CMAKE_USE_GSSAPI) 916 917if(CMAKE_USE_GSSAPI) 918 find_package(GSS) 919 920 set(HAVE_GSSAPI ${GSS_FOUND}) 921 if(GSS_FOUND) 922 923 message(STATUS "Found ${GSS_FLAVOUR} GSSAPI version: \"${GSS_VERSION}\"") 924 925 list(APPEND CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIR}) 926 check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H) 927 check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H) 928 check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H) 929 930 if(GSS_FLAVOUR STREQUAL "Heimdal") 931 set(HAVE_GSSHEIMDAL ON) 932 else() # MIT 933 set(HAVE_GSSMIT ON) 934 set(_INCLUDE_LIST "") 935 if(HAVE_GSSAPI_GSSAPI_H) 936 list(APPEND _INCLUDE_LIST "gssapi/gssapi.h") 937 endif() 938 if(HAVE_GSSAPI_GSSAPI_GENERIC_H) 939 list(APPEND _INCLUDE_LIST "gssapi/gssapi_generic.h") 940 endif() 941 if(HAVE_GSSAPI_GSSAPI_KRB5_H) 942 list(APPEND _INCLUDE_LIST "gssapi/gssapi_krb5.h") 943 endif() 944 945 string(REPLACE ";" " " _COMPILER_FLAGS_STR "${GSS_COMPILER_FLAGS}") 946 string(REPLACE ";" " " _LINKER_FLAGS_STR "${GSS_LINKER_FLAGS}") 947 948 foreach(_dir ${GSS_LINK_DIRECTORIES}) 949 set(_LINKER_FLAGS_STR "${_LINKER_FLAGS_STR} -L\"${_dir}\"") 950 endforeach() 951 952 set(CMAKE_REQUIRED_FLAGS "${_COMPILER_FLAGS_STR} ${_LINKER_FLAGS_STR}") 953 set(CMAKE_REQUIRED_LIBRARIES ${GSS_LIBRARIES}) 954 check_symbol_exists("GSS_C_NT_HOSTBASED_SERVICE" ${_INCLUDE_LIST} HAVE_GSS_C_NT_HOSTBASED_SERVICE) 955 if(NOT HAVE_GSS_C_NT_HOSTBASED_SERVICE) 956 set(HAVE_OLD_GSSMIT ON) 957 endif() 958 unset(CMAKE_REQUIRED_LIBRARIES) 959 960 endif() 961 962 include_directories(${GSS_INCLUDE_DIR}) 963 link_directories(${GSS_LINK_DIRECTORIES}) 964 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSS_COMPILER_FLAGS}") 965 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GSS_LINKER_FLAGS}") 966 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GSS_LINKER_FLAGS}") 967 set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${GSS_LINKER_FLAGS}") 968 list(APPEND CURL_LIBS ${GSS_LIBRARIES}) 969 970 else() 971 message(WARNING "GSSAPI support has been requested but no supporting libraries found. Skipping.") 972 endif() 973endif() 974 975option(ENABLE_UNIX_SOCKETS "Define if you want Unix domain sockets support" ON) 976if(ENABLE_UNIX_SOCKETS) 977 include(CheckStructHasMember) 978 if(WIN32) 979 set(USE_UNIX_SOCKETS ON) 980 else() 981 check_struct_has_member("struct sockaddr_un" sun_path "sys/un.h" USE_UNIX_SOCKETS) 982 endif() 983else() 984 unset(USE_UNIX_SOCKETS CACHE) 985endif() 986 987 988if(0) # This code not needed for building within CMake. 989# 990# CA handling 991# 992set(CURL_CA_BUNDLE "auto" CACHE STRING 993 "Path to the CA bundle. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.") 994set(CURL_CA_FALLBACK OFF CACHE BOOL 995 "Set ON to use built-in CA store of TLS backend. Defaults to OFF") 996set(CURL_CA_PATH "auto" CACHE STRING 997 "Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.") 998 999if("${CURL_CA_BUNDLE}" STREQUAL "") 1000 message(FATAL_ERROR "Invalid value of CURL_CA_BUNDLE. Use 'none', 'auto' or file path.") 1001elseif("${CURL_CA_BUNDLE}" STREQUAL "none") 1002 unset(CURL_CA_BUNDLE CACHE) 1003elseif("${CURL_CA_BUNDLE}" STREQUAL "auto") 1004 unset(CURL_CA_BUNDLE CACHE) 1005 set(CURL_CA_BUNDLE_AUTODETECT TRUE) 1006else() 1007 set(CURL_CA_BUNDLE_SET TRUE) 1008endif() 1009 1010if("${CURL_CA_PATH}" STREQUAL "") 1011 message(FATAL_ERROR "Invalid value of CURL_CA_PATH. Use 'none', 'auto' or directory path.") 1012elseif("${CURL_CA_PATH}" STREQUAL "none") 1013 unset(CURL_CA_PATH CACHE) 1014elseif("${CURL_CA_PATH}" STREQUAL "auto") 1015 unset(CURL_CA_PATH CACHE) 1016 if(NOT USE_NSS) 1017 set(CURL_CA_PATH_AUTODETECT TRUE) 1018 endif() 1019else() 1020 set(CURL_CA_PATH_SET TRUE) 1021endif() 1022 1023if(CURL_CA_BUNDLE_SET AND CURL_CA_PATH_AUTODETECT) 1024 # Skip autodetection of unset CA path because CA bundle is set explicitly 1025elseif(CURL_CA_PATH_SET AND CURL_CA_BUNDLE_AUTODETECT) 1026 # Skip autodetection of unset CA bundle because CA path is set explicitly 1027elseif(CURL_CA_PATH_AUTODETECT OR CURL_CA_BUNDLE_AUTODETECT) 1028 # first try autodetecting a CA bundle, then a CA path 1029 1030 if(CURL_CA_BUNDLE_AUTODETECT) 1031 set(SEARCH_CA_BUNDLE_PATHS 1032 /etc/ssl/certs/ca-certificates.crt 1033 /etc/pki/tls/certs/ca-bundle.crt 1034 /usr/share/ssl/certs/ca-bundle.crt 1035 /usr/local/share/certs/ca-root-nss.crt 1036 /etc/ssl/cert.pem) 1037 1038 foreach(SEARCH_CA_BUNDLE_PATH ${SEARCH_CA_BUNDLE_PATHS}) 1039 if(EXISTS "${SEARCH_CA_BUNDLE_PATH}") 1040 message(STATUS "Found CA bundle: ${SEARCH_CA_BUNDLE_PATH}") 1041 set(CURL_CA_BUNDLE "${SEARCH_CA_BUNDLE_PATH}" CACHE STRING 1042 "Path to the CA bundle. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.") 1043 set(CURL_CA_BUNDLE_SET TRUE CACHE BOOL "Path to the CA bundle has been set") 1044 break() 1045 endif() 1046 endforeach() 1047 endif() 1048 1049 if(CURL_CA_PATH_AUTODETECT AND (NOT CURL_CA_PATH_SET)) 1050 if(EXISTS "/etc/ssl/certs") 1051 set(CURL_CA_PATH "/etc/ssl/certs" CACHE STRING 1052 "Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.") 1053 set(CURL_CA_PATH_SET TRUE CACHE BOOL "Path to the CA bundle has been set") 1054 endif() 1055 endif() 1056endif() 1057 1058if(CURL_CA_PATH_SET AND NOT USE_OPENSSL AND NOT USE_MBEDTLS) 1059 message(STATUS 1060 "CA path only supported by OpenSSL, GnuTLS or mbed TLS. " 1061 "Set CURL_CA_PATH=none or enable one of those TLS backends.") 1062endif() 1063endif() 1064 1065# Check for header files 1066if(NOT UNIX) 1067 check_include_file_concat("windows.h" HAVE_WINDOWS_H) 1068 check_include_file_concat("winsock.h" HAVE_WINSOCK_H) 1069 check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H) 1070 check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H) 1071 check_include_file_concat("wincrypt.h" HAVE_WINCRYPT_H) 1072else() 1073 set(HAVE_WINDOWS_H 0) 1074 set(HAVE_WINSOCK_H 0) 1075 set(HAVE_WS2TCPIP_H 0) 1076 set(HAVE_WINSOCK2_H 0) 1077endif() 1078 1079check_include_file_concat("stdio.h" HAVE_STDIO_H) 1080check_include_file_concat("inttypes.h" HAVE_INTTYPES_H) 1081check_include_file_concat("sys/filio.h" HAVE_SYS_FILIO_H) 1082check_include_file_concat("sys/ioctl.h" HAVE_SYS_IOCTL_H) 1083check_include_file_concat("sys/param.h" HAVE_SYS_PARAM_H) 1084check_include_file_concat("sys/poll.h" HAVE_SYS_POLL_H) 1085check_include_file_concat("sys/resource.h" HAVE_SYS_RESOURCE_H) 1086check_include_file_concat("sys/select.h" HAVE_SYS_SELECT_H) 1087check_include_file_concat("sys/socket.h" HAVE_SYS_SOCKET_H) 1088check_include_file_concat("sys/sockio.h" HAVE_SYS_SOCKIO_H) 1089check_include_file_concat("sys/stat.h" HAVE_SYS_STAT_H) 1090check_include_file_concat("sys/time.h" HAVE_SYS_TIME_H) 1091check_include_file_concat("sys/types.h" HAVE_SYS_TYPES_H) 1092check_include_file_concat("sys/uio.h" HAVE_SYS_UIO_H) 1093check_include_file_concat("sys/un.h" HAVE_SYS_UN_H) 1094check_include_file_concat("sys/utime.h" HAVE_SYS_UTIME_H) 1095check_include_file_concat("sys/xattr.h" HAVE_SYS_XATTR_H) 1096check_include_file_concat("alloca.h" HAVE_ALLOCA_H) 1097check_include_file_concat("arpa/inet.h" HAVE_ARPA_INET_H) 1098check_include_file_concat("arpa/tftp.h" HAVE_ARPA_TFTP_H) 1099check_include_file_concat("assert.h" HAVE_ASSERT_H) 1100check_include_file_concat("errno.h" HAVE_ERRNO_H) 1101check_include_file_concat("fcntl.h" HAVE_FCNTL_H) 1102check_include_file_concat("idn2.h" HAVE_IDN2_H) 1103check_include_file_concat("ifaddrs.h" HAVE_IFADDRS_H) 1104check_include_file_concat("io.h" HAVE_IO_H) 1105check_include_file_concat("krb.h" HAVE_KRB_H) 1106check_include_file_concat("libgen.h" HAVE_LIBGEN_H) 1107check_include_file_concat("locale.h" HAVE_LOCALE_H) 1108check_include_file_concat("net/if.h" HAVE_NET_IF_H) 1109check_include_file_concat("netdb.h" HAVE_NETDB_H) 1110check_include_file_concat("netinet/in.h" HAVE_NETINET_IN_H) 1111check_include_file_concat("netinet/tcp.h" HAVE_NETINET_TCP_H) 1112check_include_file("linux/tcp.h" HAVE_LINUX_TCP_H) 1113 1114check_include_file_concat("pem.h" HAVE_PEM_H) 1115check_include_file_concat("poll.h" HAVE_POLL_H) 1116check_include_file_concat("pwd.h" HAVE_PWD_H) 1117check_include_file_concat("setjmp.h" HAVE_SETJMP_H) 1118check_include_file_concat("signal.h" HAVE_SIGNAL_H) 1119check_include_file_concat("ssl.h" HAVE_SSL_H) 1120check_include_file_concat("stdbool.h" HAVE_STDBOOL_H) 1121check_include_file_concat("stdint.h" HAVE_STDINT_H) 1122check_include_file_concat("stdio.h" HAVE_STDIO_H) 1123check_include_file_concat("stdlib.h" HAVE_STDLIB_H) 1124check_include_file_concat("string.h" HAVE_STRING_H) 1125check_include_file_concat("strings.h" HAVE_STRINGS_H) 1126check_include_file_concat("stropts.h" HAVE_STROPTS_H) 1127check_include_file_concat("termio.h" HAVE_TERMIO_H) 1128check_include_file_concat("termios.h" HAVE_TERMIOS_H) 1129check_include_file_concat("time.h" HAVE_TIME_H) 1130check_include_file_concat("unistd.h" HAVE_UNISTD_H) 1131check_include_file_concat("utime.h" HAVE_UTIME_H) 1132check_include_file_concat("x509.h" HAVE_X509_H) 1133 1134check_include_file_concat("process.h" HAVE_PROCESS_H) 1135check_include_file_concat("stddef.h" HAVE_STDDEF_H) 1136check_include_file_concat("dlfcn.h" HAVE_DLFCN_H) 1137check_include_file_concat("malloc.h" HAVE_MALLOC_H) 1138check_include_file_concat("memory.h" HAVE_MEMORY_H) 1139check_include_file_concat("netinet/if_ether.h" HAVE_NETINET_IF_ETHER_H) 1140check_include_file_concat("stdint.h" HAVE_STDINT_H) 1141check_include_file_concat("sockio.h" HAVE_SOCKIO_H) 1142check_include_file_concat("sys/utsname.h" HAVE_SYS_UTSNAME_H) 1143 1144check_type_size(size_t SIZEOF_SIZE_T) 1145check_type_size(ssize_t SIZEOF_SSIZE_T) 1146check_type_size("time_t" SIZEOF_TIME_T) 1147 1148find_file(RANDOM_FILE urandom /dev) 1149mark_as_advanced(RANDOM_FILE) 1150 1151# Check for some functions that are used 1152if(HAVE_LIBWS2_32) 1153 set(CMAKE_REQUIRED_LIBRARIES ws2_32) 1154elseif(HAVE_LIBSOCKET) 1155 set(CMAKE_REQUIRED_LIBRARIES socket) 1156elseif(HAVE_LIBNETWORK) 1157 set(CMAKE_REQUIRED_LIBRARIES network) 1158endif() 1159 1160check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME) 1161check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET) 1162check_symbol_exists(select "${CURL_INCLUDES}" HAVE_SELECT) 1163check_symbol_exists(poll "${CURL_INCLUDES}" HAVE_POLL) 1164check_symbol_exists(strdup "${CURL_INCLUDES}" HAVE_STRDUP) 1165check_symbol_exists(strstr "${CURL_INCLUDES}" HAVE_STRSTR) 1166check_symbol_exists(strtok_r "${CURL_INCLUDES}" HAVE_STRTOK_R) 1167check_symbol_exists(strftime "${CURL_INCLUDES}" HAVE_STRFTIME) 1168check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME) 1169check_symbol_exists(strcasecmp "${CURL_INCLUDES}" HAVE_STRCASECMP) 1170check_symbol_exists(stricmp "${CURL_INCLUDES}" HAVE_STRICMP) 1171check_symbol_exists(strcmpi "${CURL_INCLUDES}" HAVE_STRCMPI) 1172check_symbol_exists(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI) 1173check_symbol_exists(alarm "${CURL_INCLUDES}" HAVE_ALARM) 1174if(NOT HAVE_STRNCMPI) 1175 set(HAVE_STRCMPI) 1176endif() 1177check_symbol_exists(getppid "${CURL_INCLUDES}" HAVE_GETPPID) 1178check_symbol_exists(utimes "${CURL_INCLUDES}" HAVE_UTIMES) 1179 1180check_symbol_exists(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY) 1181check_symbol_exists(inet_addr "${CURL_INCLUDES}" HAVE_INET_ADDR) 1182check_symbol_exists(closesocket "${CURL_INCLUDES}" HAVE_CLOSESOCKET) 1183check_symbol_exists(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP) 1184check_symbol_exists(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R) 1185check_symbol_exists(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID) 1186check_symbol_exists(getpwuid_r "${CURL_INCLUDES}" HAVE_GETPWUID_R) 1187check_symbol_exists(geteuid "${CURL_INCLUDES}" HAVE_GETEUID) 1188check_symbol_exists(usleep "${CURL_INCLUDES}" HAVE_USLEEP) 1189check_symbol_exists(utime "${CURL_INCLUDES}" HAVE_UTIME) 1190check_symbol_exists(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R) 1191check_symbol_exists(localtime_r "${CURL_INCLUDES}" HAVE_LOCALTIME_R) 1192 1193check_symbol_exists(gethostbyname "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME) 1194check_symbol_exists(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R) 1195 1196check_symbol_exists(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC) 1197check_symbol_exists(SIGALRM "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO) 1198if(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO) 1199 set(HAVE_SIGNAL 1) 1200endif() 1201check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME) 1202check_symbol_exists(strtoll "${CURL_INCLUDES}" HAVE_STRTOLL) 1203check_symbol_exists(_strtoi64 "${CURL_INCLUDES}" HAVE__STRTOI64) 1204check_symbol_exists(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R) 1205check_symbol_exists(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT) 1206check_symbol_exists(getaddrinfo "${CURL_INCLUDES}" HAVE_GETADDRINFO) 1207check_symbol_exists(freeaddrinfo "${CURL_INCLUDES}" HAVE_FREEADDRINFO) 1208check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE) 1209check_symbol_exists(ftruncate "${CURL_INCLUDES}" HAVE_FTRUNCATE) 1210check_symbol_exists(getprotobyname "${CURL_INCLUDES}" HAVE_GETPROTOBYNAME) 1211check_symbol_exists(getpeername "${CURL_INCLUDES}" HAVE_GETPEERNAME) 1212check_symbol_exists(getsockname "${CURL_INCLUDES}" HAVE_GETSOCKNAME) 1213check_symbol_exists(if_nametoindex "${CURL_INCLUDES}" HAVE_IF_NAMETOINDEX) 1214check_symbol_exists(getrlimit "${CURL_INCLUDES}" HAVE_GETRLIMIT) 1215check_symbol_exists(setlocale "${CURL_INCLUDES}" HAVE_SETLOCALE) 1216check_symbol_exists(setmode "${CURL_INCLUDES}" HAVE_SETMODE) 1217check_symbol_exists(setrlimit "${CURL_INCLUDES}" HAVE_SETRLIMIT) 1218check_symbol_exists(fcntl "${CURL_INCLUDES}" HAVE_FCNTL) 1219check_symbol_exists(ioctl "${CURL_INCLUDES}" HAVE_IOCTL) 1220check_symbol_exists(setsockopt "${CURL_INCLUDES}" HAVE_SETSOCKOPT) 1221check_function_exists(mach_absolute_time HAVE_MACH_ABSOLUTE_TIME) 1222check_symbol_exists(inet_pton "${CURL_INCLUDES}" HAVE_INET_PTON) 1223 1224check_symbol_exists(fsetxattr "${CURL_INCLUDES}" HAVE_FSETXATTR) 1225if(HAVE_FSETXATTR) 1226 foreach(CURL_TEST HAVE_FSETXATTR_5 HAVE_FSETXATTR_6) 1227 curl_internal_test(${CURL_TEST}) 1228 endforeach() 1229endif() 1230 1231set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h") 1232check_type_size("sa_family_t" SIZEOF_SA_FAMILY_T) 1233set(HAVE_SA_FAMILY_T ${HAVE_SIZEOF_SA_FAMILY_T}) 1234set(CMAKE_EXTRA_INCLUDE_FILES "") 1235 1236set(CMAKE_EXTRA_INCLUDE_FILES "ws2def.h") 1237check_type_size("ADDRESS_FAMILY" SIZEOF_ADDRESS_FAMILY) 1238set(HAVE_ADDRESS_FAMILY ${HAVE_SIZEOF_ADDRESS_FAMILY}) 1239set(CMAKE_EXTRA_INCLUDE_FILES "") 1240 1241# sigaction and sigsetjmp are special. Use special mechanism for 1242# detecting those, but only if previous attempt failed. 1243if(HAVE_SIGNAL_H) 1244 check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION) 1245endif() 1246 1247if(NOT HAVE_SIGSETJMP) 1248 if(HAVE_SETJMP_H) 1249 check_symbol_exists(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP) 1250 if(HAVE_MACRO_SIGSETJMP) 1251 set(HAVE_SIGSETJMP 1) 1252 endif() 1253 endif() 1254endif() 1255 1256# If there is no stricmp(), do not allow LDAP to parse URLs 1257if(NOT HAVE_STRICMP) 1258 set(HAVE_LDAP_URL_PARSE 1) 1259endif() 1260 1261# Do curl specific tests 1262foreach(CURL_TEST 1263 HAVE_FCNTL_O_NONBLOCK 1264 HAVE_IOCTLSOCKET 1265 HAVE_IOCTLSOCKET_CAMEL 1266 HAVE_IOCTLSOCKET_CAMEL_FIONBIO 1267 HAVE_IOCTLSOCKET_FIONBIO 1268 HAVE_IOCTL_FIONBIO 1269 HAVE_IOCTL_SIOCGIFADDR 1270 HAVE_SETSOCKOPT_SO_NONBLOCK 1271 HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1272 TIME_WITH_SYS_TIME 1273 HAVE_O_NONBLOCK 1274 HAVE_GETHOSTBYNAME_R_3 1275 HAVE_GETHOSTBYNAME_R_5 1276 HAVE_GETHOSTBYNAME_R_6 1277 HAVE_GETHOSTBYNAME_R_3_REENTRANT 1278 HAVE_GETHOSTBYNAME_R_5_REENTRANT 1279 HAVE_GETHOSTBYNAME_R_6_REENTRANT 1280 HAVE_IN_ADDR_T 1281 HAVE_BOOL_T 1282 STDC_HEADERS 1283 HAVE_GETADDRINFO 1284 HAVE_FILE_OFFSET_BITS 1285 HAVE_VARIADIC_MACROS_C99 1286 HAVE_VARIADIC_MACROS_GCC 1287 ) 1288 curl_internal_test(${CURL_TEST}) 1289endforeach() 1290 1291if(HAVE_FILE_OFFSET_BITS) 1292 set(_FILE_OFFSET_BITS 64) 1293 set(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64") 1294endif() 1295check_type_size("off_t" SIZEOF_OFF_T) 1296 1297# include this header to get the type 1298set(CMAKE_REQUIRED_INCLUDES "${CURL_SOURCE_DIR}/include") 1299set(CMAKE_EXTRA_INCLUDE_FILES "curl/system.h") 1300check_type_size("curl_off_t" SIZEOF_CURL_OFF_T) 1301set(CMAKE_EXTRA_INCLUDE_FILES "") 1302 1303set(CMAKE_REQUIRED_FLAGS) 1304 1305foreach(CURL_TEST 1306 HAVE_GLIBC_STRERROR_R 1307 HAVE_POSIX_STRERROR_R 1308 ) 1309 curl_internal_test(${CURL_TEST}) 1310endforeach() 1311 1312# Check for reentrant 1313foreach(CURL_TEST 1314 HAVE_GETHOSTBYNAME_R_3 1315 HAVE_GETHOSTBYNAME_R_5 1316 HAVE_GETHOSTBYNAME_R_6) 1317 if(NOT ${CURL_TEST}) 1318 if(${CURL_TEST}_REENTRANT) 1319 set(NEED_REENTRANT 1) 1320 endif() 1321 endif() 1322endforeach() 1323 1324if(NEED_REENTRANT) 1325 foreach(CURL_TEST 1326 HAVE_GETHOSTBYNAME_R_3 1327 HAVE_GETHOSTBYNAME_R_5 1328 HAVE_GETHOSTBYNAME_R_6) 1329 set(${CURL_TEST} 0) 1330 if(${CURL_TEST}_REENTRANT) 1331 set(${CURL_TEST} 1) 1332 endif() 1333 endforeach() 1334endif() 1335 1336# Check clock_gettime(CLOCK_MONOTONIC, x) support 1337curl_internal_test(HAVE_CLOCK_GETTIME_MONOTONIC) 1338 1339# Check compiler support of __builtin_available() 1340curl_internal_test(HAVE_BUILTIN_AVAILABLE) 1341 1342# Some other minor tests 1343 1344if(NOT HAVE_IN_ADDR_T) 1345 set(in_addr_t "unsigned long") 1346endif() 1347 1348# Fix libz / zlib.h 1349 1350if(NOT CURL_SPECIAL_LIBZ) 1351 if(NOT HAVE_LIBZ) 1352 set(HAVE_ZLIB_H 0) 1353 endif() 1354 1355 if(NOT HAVE_ZLIB_H) 1356 set(HAVE_LIBZ 0) 1357 endif() 1358endif() 1359 1360# Check for nonblocking 1361set(HAVE_DISABLED_NONBLOCKING 1) 1362if(HAVE_FIONBIO OR 1363 HAVE_IOCTLSOCKET OR 1364 HAVE_IOCTLSOCKET_CASE OR 1365 HAVE_O_NONBLOCK) 1366 set(HAVE_DISABLED_NONBLOCKING) 1367endif() 1368 1369if(CMAKE_COMPILER_IS_GNUCC AND APPLE) 1370 include(CheckCCompilerFlag) 1371 check_c_compiler_flag(-Wno-long-double HAVE_C_FLAG_Wno_long_double) 1372 if(HAVE_C_FLAG_Wno_long_double) 1373 # The Mac version of GCC warns about use of long double. Disable it. 1374 get_source_file_property(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS) 1375 if(MPRINTF_COMPILE_FLAGS) 1376 set(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double") 1377 else() 1378 set(MPRINTF_COMPILE_FLAGS "-Wno-long-double") 1379 endif() 1380 set_source_files_properties(mprintf.c PROPERTIES 1381 COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS}) 1382 endif() 1383endif() 1384 1385# TODO test which of these headers are required 1386if(WIN32) 1387 set(CURL_PULL_WS2TCPIP_H ${HAVE_WS2TCPIP_H}) 1388else() 1389 set(CURL_PULL_SYS_TYPES_H ${HAVE_SYS_TYPES_H}) 1390 set(CURL_PULL_SYS_SOCKET_H ${HAVE_SYS_SOCKET_H}) 1391 set(CURL_PULL_SYS_POLL_H ${HAVE_SYS_POLL_H}) 1392endif() 1393set(CURL_PULL_STDINT_H ${HAVE_STDINT_H}) 1394set(CURL_PULL_INTTYPES_H ${HAVE_INTTYPES_H}) 1395 1396include(CMake/OtherTests.cmake) 1397 1398add_definitions(-DHAVE_CONFIG_H) 1399 1400# For Windows, all compilers used by CMake should support large files 1401if(WIN32) 1402 set(USE_WIN32_LARGE_FILES ON) 1403 1404 # Use the manifest embedded in the Windows Resource 1405 set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DCURL_EMBED_MANIFEST") 1406 1407 # Check if crypto functions in wincrypt.h are actually available 1408 if(HAVE_WINCRYPT_H) 1409 check_symbol_exists(CryptAcquireContext "${CURL_INCLUDES}" USE_WINCRYPT) 1410 endif() 1411 if(USE_WINCRYPT) 1412 set(USE_WIN32_CRYPTO ON) 1413 endif() 1414 1415 # Link required libraries for USE_WIN32_CRYPTO or USE_SCHANNEL 1416 if(USE_WIN32_CRYPTO OR USE_SCHANNEL) 1417 list(APPEND CURL_LIBS "advapi32" "crypt32") 1418 endif() 1419endif() 1420 1421if(MSVC) 1422 # Disable default manifest added by CMake 1423 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") 1424 1425 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) 1426 if(CMAKE_C_FLAGS MATCHES "/W[0-4]") 1427 string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") 1428 else() 1429 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") 1430 endif() 1431 1432 # Use multithreaded compilation on VS 2008+ 1433 if(MSVC_VERSION GREATER_EQUAL 1500) 1434 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") 1435 endif() 1436endif() 1437 1438if(CURL_WERROR) 1439 if(MSVC_VERSION) 1440 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") 1441 else() 1442 # this assumes clang or gcc style options 1443 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") 1444 endif() 1445endif() 1446 1447if(CURL_LTO) 1448 if(CMAKE_VERSION VERSION_LESS 3.9) 1449 message(FATAL_ERROR "Requested LTO but your cmake version ${CMAKE_VERSION} is to old. You need at least 3.9") 1450 endif() 1451 1452 cmake_policy(SET CMP0069 NEW) 1453 1454 include(CheckIPOSupported) 1455 check_ipo_supported(RESULT CURL_HAS_LTO OUTPUT CURL_LTO_ERROR LANGUAGES C) 1456 if(CURL_HAS_LTO) 1457 message(STATUS "LTO supported and enabled") 1458 else() 1459 message(FATAL_ERROR "LTO was requested - but compiler doesn't support it\n${CURL_LTO_ERROR}") 1460 endif() 1461endif() 1462 1463 1464# Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it). 1465function(transform_makefile_inc INPUT_FILE OUTPUT_FILE) 1466 file(READ ${INPUT_FILE} MAKEFILE_INC_TEXT) 1467 string(REPLACE "$(top_srcdir)" "\${CURL_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) 1468 string(REPLACE "$(top_builddir)" "\${CURL_BINARY_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) 1469 1470 string(REGEX REPLACE "\\\\\n" "!π!α!" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) 1471 string(REGEX REPLACE "([a-zA-Z_][a-zA-Z0-9_]*)[\t ]*=[\t ]*([^\n]*)" "SET(\\1 \\2)" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) 1472 string(REPLACE "!π!α!" "\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) 1473 1474 string(REGEX REPLACE "\\$\\(([a-zA-Z_][a-zA-Z0-9_]*)\\)" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace $() with ${} 1475 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. 1476 file(WRITE ${OUTPUT_FILE} ${MAKEFILE_INC_TEXT}) 1477 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${INPUT_FILE}") 1478endfunction() 1479 1480if(0) # This code not needed for building within CMake. 1481include(GNUInstallDirs) 1482 1483set(CURL_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) 1484set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") 1485set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") 1486set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") 1487set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") 1488endif() 1489 1490if(USE_MANUAL) 1491 add_subdirectory(docs) 1492endif() 1493 1494add_subdirectory(lib) 1495 1496if(BUILD_CURL_EXE) 1497 add_subdirectory(src) 1498endif() 1499 1500#----------------------------------------------------------------------------- 1501# CMake-specific curl code. 1502add_executable(curltest curltest.c) 1503target_link_libraries(curltest cmcurl) 1504 1505if(BUILD_TESTING AND CMAKE_CURL_TEST_URL) 1506 add_test(curl curltest ${CMAKE_CURL_TEST_URL}) 1507endif() 1508 1509install(FILES COPYING DESTINATION ${CMAKE_DOC_DIR}/cmcurl) 1510#----------------------------------------------------------------------------- 1511 1512if(0) # This code not needed for building within CMake. 1513cmake_dependent_option(BUILD_TESTING "Build tests" 1514 ON "PERL_FOUND;NOT CURL_DISABLE_TESTS" 1515 OFF) 1516if(BUILD_TESTING) 1517 add_subdirectory(tests) 1518endif() 1519 1520# Helper to populate a list (_items) with a label when conditions (the remaining 1521# args) are satisfied 1522macro(_add_if label) 1523 # needs to be a macro to allow this indirection 1524 if(${ARGN}) 1525 set(_items ${_items} "${label}") 1526 endif() 1527endmacro() 1528 1529# NTLM support requires crypto function adaptions from various SSL libs 1530# TODO alternative SSL libs tests for SSP1, GNUTLS, NSS 1531if(NOT (CURL_DISABLE_CRYPTO_AUTH OR CURL_DISABLE_NTLM) AND 1532 (USE_OPENSSL OR USE_MBEDTLS OR USE_DARWINSSL OR USE_WIN32_CRYPTO)) 1533 set(use_curl_ntlm_core ON) 1534endif() 1535 1536# Clear list and try to detect available features 1537set(_items) 1538_add_if("SSL" SSL_ENABLED) 1539_add_if("IPv6" ENABLE_IPV6) 1540_add_if("unixsockets" USE_UNIX_SOCKETS) 1541_add_if("libz" HAVE_LIBZ) 1542_add_if("brotli" HAVE_BROTLI) 1543_add_if("zstd" HAVE_ZSTD) 1544_add_if("AsynchDNS" USE_ARES OR USE_THREADS_POSIX OR USE_THREADS_WIN32) 1545_add_if("IDN" HAVE_LIBIDN2 OR USE_WIN32_IDN) 1546_add_if("Largefile" (SIZEOF_CURL_OFF_T GREATER 4) AND 1547 ((SIZEOF_OFF_T GREATER 4) OR USE_WIN32_LARGE_FILES)) 1548# TODO SSP1 (Schannel) check is missing 1549_add_if("SSPI" USE_WINDOWS_SSPI) 1550_add_if("GSS-API" HAVE_GSSAPI) 1551_add_if("alt-svc" NOT CURL_DISABLE_ALTSVC) 1552_add_if("HSTS" NOT CURL_DISABLE_HSTS) 1553# TODO SSP1 missing for SPNEGO 1554_add_if("SPNEGO" NOT CURL_DISABLE_CRYPTO_AUTH AND 1555 (HAVE_GSSAPI OR USE_WINDOWS_SSPI)) 1556_add_if("Kerberos" NOT CURL_DISABLE_CRYPTO_AUTH AND 1557 (HAVE_GSSAPI OR USE_WINDOWS_SSPI)) 1558# NTLM support requires crypto function adaptions from various SSL libs 1559# TODO alternative SSL libs tests for SSP1, GNUTLS, NSS 1560_add_if("NTLM" NOT (CURL_DISABLE_CRYPTO_AUTH OR CURL_DISABLE_NTLM) AND 1561 (use_curl_ntlm_core OR USE_WINDOWS_SSPI)) 1562# TODO missing option (autoconf: --enable-ntlm-wb) 1563_add_if("NTLM_WB" NOT (CURL_DISABLE_CRYPTO_AUTH OR CURL_DISABLE_NTLM) AND 1564 (use_curl_ntlm_core OR USE_WINDOWS_SSPI) AND 1565 NOT CURL_DISABLE_HTTP AND NTLM_WB_ENABLED) 1566# TODO missing option (--enable-tls-srp), depends on GNUTLS_SRP/OPENSSL_SRP 1567_add_if("TLS-SRP" USE_TLS_SRP) 1568# TODO option --with-nghttp2 tests for nghttp2 lib and nghttp2/nghttp2.h header 1569_add_if("HTTP2" USE_NGHTTP2) 1570_add_if("HTTP3" USE_NGTCP2 OR USE_QUICHE) 1571_add_if("MultiSSL" CURL_WITH_MULTI_SSL) 1572_add_if("HTTPS-proxy" SSL_ENABLED AND (USE_OPENSSL OR USE_GNUTLS OR USE_NSS)) 1573_add_if("unicode" ENABLE_UNICODE) 1574string(REPLACE ";" " " SUPPORT_FEATURES "${_items}") 1575message(STATUS "Enabled features: ${SUPPORT_FEATURES}") 1576 1577# Clear list and try to detect available protocols 1578set(_items) 1579_add_if("HTTP" NOT CURL_DISABLE_HTTP) 1580_add_if("HTTPS" NOT CURL_DISABLE_HTTP AND SSL_ENABLED) 1581_add_if("FTP" NOT CURL_DISABLE_FTP) 1582_add_if("FTPS" NOT CURL_DISABLE_FTP AND SSL_ENABLED) 1583_add_if("FILE" NOT CURL_DISABLE_FILE) 1584_add_if("TELNET" NOT CURL_DISABLE_TELNET) 1585_add_if("LDAP" NOT CURL_DISABLE_LDAP) 1586# CURL_DISABLE_LDAP implies CURL_DISABLE_LDAPS 1587# TODO check HAVE_LDAP_SSL (in autoconf this is enabled with --enable-ldaps) 1588_add_if("LDAPS" NOT CURL_DISABLE_LDAPS AND 1589 ((USE_OPENLDAP AND SSL_ENABLED) OR 1590 (NOT USE_OPENLDAP AND HAVE_LDAP_SSL))) 1591_add_if("DICT" NOT CURL_DISABLE_DICT) 1592_add_if("TFTP" NOT CURL_DISABLE_TFTP) 1593_add_if("GOPHER" NOT CURL_DISABLE_GOPHER) 1594_add_if("GOPHERS" NOT CURL_DISABLE_GOPHER AND SSL_ENABLED) 1595_add_if("POP3" NOT CURL_DISABLE_POP3) 1596_add_if("POP3S" NOT CURL_DISABLE_POP3 AND SSL_ENABLED) 1597_add_if("IMAP" NOT CURL_DISABLE_IMAP) 1598_add_if("IMAPS" NOT CURL_DISABLE_IMAP AND SSL_ENABLED) 1599_add_if("SMB" NOT CURL_DISABLE_SMB AND 1600 use_curl_ntlm_core AND (SIZEOF_CURL_OFF_T GREATER 4)) 1601_add_if("SMBS" NOT CURL_DISABLE_SMB AND SSL_ENABLED AND 1602 use_curl_ntlm_core AND (SIZEOF_CURL_OFF_T GREATER 4)) 1603_add_if("SMTP" NOT CURL_DISABLE_SMTP) 1604_add_if("SMTPS" NOT CURL_DISABLE_SMTP AND SSL_ENABLED) 1605_add_if("SCP" USE_LIBSSH2 OR USE_LIBSSH) 1606_add_if("SFTP" USE_LIBSSH2 OR USE_LIBSSH) 1607_add_if("RTSP" NOT CURL_DISABLE_RTSP) 1608_add_if("RTMP" USE_LIBRTMP) 1609_add_if("MQTT" NOT CURL_DISABLE_MQTT) 1610if(_items) 1611 list(SORT _items) 1612endif() 1613string(REPLACE ";" " " SUPPORT_PROTOCOLS "${_items}") 1614message(STATUS "Enabled protocols: ${SUPPORT_PROTOCOLS}") 1615 1616# Clear list and collect SSL backends 1617set(_items) 1618_add_if("Schannel" SSL_ENABLED AND USE_SCHANNEL) 1619_add_if("OpenSSL" SSL_ENABLED AND USE_OPENSSL) 1620_add_if("Secure Transport" SSL_ENABLED AND USE_SECTRANSP) 1621_add_if("mbedTLS" SSL_ENABLED AND USE_MBEDTLS) 1622_add_if("BearSSL" SSL_ENABLED AND USE_BEARSSL) 1623_add_if("NSS" SSL_ENABLED AND USE_NSS) 1624_add_if("wolfSSL" SSL_ENABLED AND USE_WOLFSSL) 1625if(_items) 1626 list(SORT _items) 1627endif() 1628string(REPLACE ";" " " SSL_BACKENDS "${_items}") 1629message(STATUS "Enabled SSL backends: ${SSL_BACKENDS}") 1630 1631# curl-config needs the following options to be set. 1632set(CC "${CMAKE_C_COMPILER}") 1633# TODO probably put a -D... options here? 1634set(CONFIGURE_OPTIONS "") 1635# TODO when to set "-DCURL_STATICLIB" for CPPFLAG_CURL_STATICLIB? 1636set(CPPFLAG_CURL_STATICLIB "") 1637set(CURLVERSION "${CURL_VERSION}") 1638set(exec_prefix "\${prefix}") 1639set(includedir "\${prefix}/include") 1640set(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}") 1641set(LIBCURL_LIBS "") 1642set(libdir "${CMAKE_INSTALL_PREFIX}/lib") 1643foreach(_lib ${CMAKE_C_IMPLICIT_LINK_LIBRARIES} ${CURL_LIBS}) 1644 if(TARGET "${_lib}") 1645 set(_libname "${_lib}") 1646 get_target_property(_libtype "${_libname}" TYPE) 1647 if(_libtype STREQUAL INTERFACE_LIBRARY) 1648 # Interface libraries can occur when an external project embeds curl and 1649 # defined targets such as ZLIB::ZLIB by themselves. Ignore these as 1650 # reading the LOCATION property will error out. Assume the user won't need 1651 # this information in the .pc file. 1652 continue() 1653 endif() 1654 get_target_property(_lib "${_libname}" LOCATION) 1655 if(NOT _lib) 1656 message(WARNING "Bad lib in library list: ${_libname}") 1657 continue() 1658 endif() 1659 endif() 1660 if(_lib MATCHES ".*/.*" OR _lib MATCHES "^-") 1661 set(LIBCURL_LIBS "${LIBCURL_LIBS} ${_lib}") 1662 else() 1663 set(LIBCURL_LIBS "${LIBCURL_LIBS} -l${_lib}") 1664 endif() 1665endforeach() 1666if(BUILD_SHARED_LIBS) 1667 set(ENABLE_SHARED "yes") 1668 set(ENABLE_STATIC "no") 1669 set(LIBCURL_NO_SHARED "") 1670else() 1671 set(ENABLE_SHARED "no") 1672 set(ENABLE_STATIC "yes") 1673 set(LIBCURL_NO_SHARED "${LIBCURL_LIBS}") 1674endif() 1675# "a" (Linux) or "lib" (Windows) 1676string(REPLACE "." "" libext "${CMAKE_STATIC_LIBRARY_SUFFIX}") 1677set(prefix "${CMAKE_INSTALL_PREFIX}") 1678# Set this to "yes" to append all libraries on which -lcurl is dependent 1679set(REQUIRE_LIB_DEPS "no") 1680# SUPPORT_FEATURES 1681# SUPPORT_PROTOCOLS 1682set(VERSIONNUM "${CURL_VERSION_NUM}") 1683 1684# Finally generate a "curl-config" matching this config 1685# Use: 1686# * ENABLE_SHARED 1687# * ENABLE_STATIC 1688configure_file("${CURL_SOURCE_DIR}/curl-config.in" 1689 "${CURL_BINARY_DIR}/curl-config" @ONLY) 1690install(FILES "${CURL_BINARY_DIR}/curl-config" 1691 DESTINATION ${CMAKE_INSTALL_BINDIR} 1692 PERMISSIONS 1693 OWNER_READ OWNER_WRITE OWNER_EXECUTE 1694 GROUP_READ GROUP_EXECUTE 1695 WORLD_READ WORLD_EXECUTE) 1696 1697# Finally generate a pkg-config file matching this config 1698configure_file("${CURL_SOURCE_DIR}/libcurl.pc.in" 1699 "${CURL_BINARY_DIR}/libcurl.pc" @ONLY) 1700install(FILES "${CURL_BINARY_DIR}/libcurl.pc" 1701 DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 1702 1703# install headers 1704install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/curl" 1705 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 1706 FILES_MATCHING PATTERN "*.h") 1707 1708include(CMakePackageConfigHelpers) 1709write_basic_package_version_file( 1710 "${version_config}" 1711 VERSION ${CURL_VERSION} 1712 COMPATIBILITY SameMajorVersion 1713) 1714 1715# Use: 1716# * TARGETS_EXPORT_NAME 1717# * PROJECT_NAME 1718configure_package_config_file(CMake/curl-config.cmake.in 1719 "${project_config}" 1720 INSTALL_DESTINATION ${CURL_INSTALL_CMAKE_DIR} 1721) 1722 1723if(CURL_ENABLE_EXPORT_TARGET) 1724 install( 1725 EXPORT "${TARGETS_EXPORT_NAME}" 1726 NAMESPACE "${PROJECT_NAME}::" 1727 DESTINATION ${CURL_INSTALL_CMAKE_DIR} 1728 ) 1729endif() 1730 1731install( 1732 FILES ${version_config} ${project_config} 1733 DESTINATION ${CURL_INSTALL_CMAKE_DIR} 1734) 1735 1736# Workaround for MSVS10 to avoid the Dialog Hell 1737# FIXME: This could be removed with future version of CMake. 1738if(MSVC_VERSION EQUAL 1600) 1739 set(CURL_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/CURL.sln") 1740 if(EXISTS "${CURL_SLN_FILENAME}") 1741 file(APPEND "${CURL_SLN_FILENAME}" "\n# This should be regenerated!\n") 1742 endif() 1743endif() 1744 1745if(NOT TARGET uninstall) 1746 configure_file( 1747 ${CMAKE_CURRENT_SOURCE_DIR}/CMake/cmake_uninstall.cmake.in 1748 ${CMAKE_CURRENT_BINARY_DIR}/CMake/cmake_uninstall.cmake 1749 IMMEDIATE @ONLY) 1750 1751 add_custom_target(uninstall 1752 COMMAND ${CMAKE_COMMAND} -P 1753 ${CMAKE_CURRENT_BINARY_DIR}/CMake/cmake_uninstall.cmake) 1754endif() 1755endif() 1756