2
0

CMakeLists.txt 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 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.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. # SPDX-License-Identifier: curl
  22. #
  23. ###########################################################################
  24. # curl/libcurl CMake script
  25. # by Tetetest and Sukender (Benoit Neil)
  26. # TODO:
  27. # The output .so file lacks the soname number which we currently have within the lib/Makefile.am file
  28. # Add full (4 or 5 libs) SSL support
  29. # 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).
  30. # Check on all possible platforms
  31. # Test with as many configurations possible (With or without any option)
  32. # Create scripts that help keeping the CMake build system up to date (to reduce maintenance). According to Tetetest:
  33. # - lists of headers that 'configure' checks for;
  34. # - curl-specific tests (the ones that are in m4/curl-*.m4 files);
  35. # - (most obvious thing:) curl version numbers.
  36. # Add documentation subproject
  37. #
  38. # To check:
  39. # (From Daniel Stenberg) The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not.
  40. # (From Daniel Stenberg) The gcc command line use neither -g nor any -O options. As a developer, I also treasure our configure scripts's --enable-debug option that sets a long range of "picky" compiler options.
  41. # Note: By default this CMake build script detects the version of some
  42. # dependencies using `check_symbol_exists`. Those checks do not work
  43. # in the case that both CURL and its dependency are included as
  44. # sub-projects in a larger build using `FetchContent`. To support
  45. # that case, additional variables may be defined by the parent
  46. # project, ideally in the "extra" find package redirect file:
  47. # https://cmake.org/cmake/help/latest/module/FetchContent.html#integrating-with-find-package
  48. #
  49. # The following variables are available:
  50. # HAVE_RAND_EGD: `RAND_egd` present in OpenSSL
  51. # HAVE_AWSLC: OpenSSL is AWS-LC
  52. # HAVE_BORINGSSL: OpenSSL is BoringSSL
  53. # HAVE_PK11_CREATEMANAGEDGENERICOBJECTL: `PK11_CreateManagedGenericObject` present in NSS
  54. # HAVE_SSL_CTX_SET_QUIC_METHOD: `SSL_CTX_set_quic_method` present in OpenSSL/wolfSSL
  55. # HAVE_QUICHE_CONN_SET_QLOG_FD: `quiche_conn_set_qlog_fd` present in QUICHE
  56. # HAVE_ZSTD_CREATEDSTREAM: `ZSTD_createDStream` present in Zstd
  57. #
  58. # For each of the above variables, if the variable is DEFINED (either
  59. # to ON or OFF), the symbol detection will be skipped. If the
  60. # variable is NOT DEFINED, the symbol detection will be performed.
  61. cmake_minimum_required(VERSION 3.7...3.16 FATAL_ERROR)
  62. set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
  63. include(Utilities)
  64. include(Macros)
  65. include(CMakeDependentOption)
  66. include(CheckCCompilerFlag)
  67. project(CURL C)
  68. file(STRINGS ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS REGEX "#define LIBCURL_VERSION( |_NUM )")
  69. string(REGEX MATCH "#define LIBCURL_VERSION \"[^\"]*"
  70. CURL_VERSION ${CURL_VERSION_H_CONTENTS})
  71. string(REGEX REPLACE "[^\"]+\"" "" CURL_VERSION ${CURL_VERSION})
  72. string(REGEX MATCH "#define LIBCURL_VERSION_NUM 0x[0-9a-fA-F]+"
  73. CURL_VERSION_NUM ${CURL_VERSION_H_CONTENTS})
  74. string(REGEX REPLACE "[^0]+0x" "" CURL_VERSION_NUM ${CURL_VERSION_NUM})
  75. # Setup package meta-data
  76. # SET(PACKAGE "curl")
  77. message(STATUS "curl version=[${CURL_VERSION}]")
  78. # SET(PACKAGE_TARNAME "curl")
  79. # SET(PACKAGE_NAME "curl")
  80. # SET(PACKAGE_VERSION "-")
  81. # SET(PACKAGE_STRING "curl-")
  82. # SET(PACKAGE_BUGREPORT "a suitable curl mailing list => https://curl.se/mail/")
  83. set(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}")
  84. if(CMAKE_C_COMPILER_TARGET)
  85. set(OS "\"${CMAKE_C_COMPILER_TARGET}\"")
  86. else()
  87. set(OS "\"${CMAKE_SYSTEM_NAME}\"")
  88. endif()
  89. include_directories(${CURL_SOURCE_DIR}/include)
  90. set(CMAKE_UNITY_BUILD_BATCH_SIZE 0)
  91. option(CURL_WERROR "Turn compiler warnings into errors" OFF)
  92. option(PICKY_COMPILER "Enable picky compiler options" ON)
  93. option(BUILD_CURL_EXE "Set to ON to build curl executable." ON)
  94. option(BUILD_SHARED_LIBS "Build shared libraries" ON)
  95. option(ENABLE_ARES "Set to ON to enable c-ares support" OFF)
  96. if(WIN32)
  97. option(CURL_STATIC_CRT "Set to ON to build libcurl with static CRT on Windows (/MT)." OFF)
  98. option(ENABLE_UNICODE "Set to ON to use the Unicode version of the Windows API functions" OFF)
  99. set(CURL_TARGET_WINDOWS_VERSION "" CACHE STRING "Minimum target Windows version as hex string")
  100. if(CURL_TARGET_WINDOWS_VERSION)
  101. add_definitions(-D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION})
  102. list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION})
  103. set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}")
  104. endif()
  105. if(ENABLE_UNICODE)
  106. add_definitions(-DUNICODE -D_UNICODE)
  107. if(MINGW)
  108. add_compile_options(-municode)
  109. endif()
  110. endif()
  111. endif()
  112. option(CURL_LTO "Turn on compiler Link Time Optimizations" OFF)
  113. cmake_dependent_option(ENABLE_THREADED_RESOLVER "Set to ON to enable threaded DNS lookup"
  114. ON "NOT ENABLE_ARES"
  115. OFF)
  116. option(ENABLE_DEBUG "Set to ON to enable curl debug features" OFF)
  117. option(ENABLE_CURLDEBUG "Set to ON to build with TrackMemory feature enabled" OFF)
  118. include(PickyWarnings)
  119. if(ENABLE_DEBUG)
  120. # DEBUGBUILD will be defined only for Debug builds
  121. set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUGBUILD>)
  122. set(ENABLE_CURLDEBUG ON)
  123. endif()
  124. if(ENABLE_CURLDEBUG)
  125. set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS CURLDEBUG)
  126. endif()
  127. # For debug libs and exes, add "-d" postfix
  128. if(NOT DEFINED CMAKE_DEBUG_POSTFIX)
  129. set(CMAKE_DEBUG_POSTFIX "-d")
  130. endif()
  131. # initialize CURL_LIBS
  132. set(CURL_LIBS "")
  133. if(ENABLE_ARES)
  134. set(USE_ARES 1)
  135. find_package(CARES REQUIRED)
  136. list(APPEND CURL_LIBS ${CARES_LIBRARY})
  137. endif()
  138. include(CurlSymbolHiding)
  139. option(CURL_ENABLE_EXPORT_TARGET "to enable cmake export target" ON)
  140. mark_as_advanced(CURL_ENABLE_EXPORT_TARGET)
  141. option(CURL_DISABLE_ALTSVC "disables alt-svc support" OFF)
  142. mark_as_advanced(CURL_DISABLE_ALTSVC)
  143. option(CURL_DISABLE_COOKIES "disables cookies support" OFF)
  144. mark_as_advanced(CURL_DISABLE_COOKIES)
  145. option(CURL_DISABLE_CRYPTO_AUTH "disables cryptographic authentication" OFF)
  146. mark_as_advanced(CURL_DISABLE_CRYPTO_AUTH)
  147. option(CURL_DISABLE_DICT "disables DICT" OFF)
  148. mark_as_advanced(CURL_DISABLE_DICT)
  149. option(CURL_DISABLE_DOH "disables DNS-over-HTTPS" OFF)
  150. mark_as_advanced(CURL_DISABLE_DOH)
  151. option(CURL_DISABLE_FILE "disables FILE" OFF)
  152. mark_as_advanced(CURL_DISABLE_FILE)
  153. option(CURL_DISABLE_FTP "disables FTP" OFF)
  154. mark_as_advanced(CURL_DISABLE_FTP)
  155. option(CURL_DISABLE_GETOPTIONS "disables curl_easy_options API for existing options to curl_easy_setopt" OFF)
  156. mark_as_advanced(CURL_DISABLE_GETOPTIONS)
  157. option(CURL_DISABLE_GOPHER "disables Gopher" OFF)
  158. mark_as_advanced(CURL_DISABLE_GOPHER)
  159. option(CURL_DISABLE_HSTS "disables HSTS support" OFF)
  160. mark_as_advanced(CURL_DISABLE_HSTS)
  161. option(CURL_DISABLE_HTTP "disables HTTP" OFF)
  162. mark_as_advanced(CURL_DISABLE_HTTP)
  163. option(CURL_DISABLE_HTTP_AUTH "disables all HTTP authentication methods" OFF)
  164. mark_as_advanced(CURL_DISABLE_HTTP_AUTH)
  165. option(CURL_DISABLE_IMAP "disables IMAP" OFF)
  166. mark_as_advanced(CURL_DISABLE_IMAP)
  167. option(CURL_DISABLE_LDAP "disables LDAP" OFF)
  168. mark_as_advanced(CURL_DISABLE_LDAP)
  169. option(CURL_DISABLE_LDAPS "disables LDAPS" OFF)
  170. mark_as_advanced(CURL_DISABLE_LDAPS)
  171. option(CURL_DISABLE_LIBCURL_OPTION "disables --libcurl option from the curl tool" OFF)
  172. mark_as_advanced(CURL_DISABLE_LIBCURL_OPTION)
  173. option(CURL_DISABLE_MIME "disables MIME support" OFF)
  174. mark_as_advanced(CURL_DISABLE_MIME)
  175. option(CURL_DISABLE_MQTT "disables MQTT" OFF)
  176. mark_as_advanced(CURL_DISABLE_MQTT)
  177. option(CURL_DISABLE_NETRC "disables netrc parser" OFF)
  178. mark_as_advanced(CURL_DISABLE_NETRC)
  179. option(CURL_DISABLE_NTLM "disables NTLM support" OFF)
  180. mark_as_advanced(CURL_DISABLE_NTLM)
  181. option(CURL_DISABLE_PARSEDATE "disables date parsing" OFF)
  182. mark_as_advanced(CURL_DISABLE_PARSEDATE)
  183. option(CURL_DISABLE_POP3 "disables POP3" OFF)
  184. mark_as_advanced(CURL_DISABLE_POP3)
  185. option(CURL_DISABLE_PROGRESS_METER "disables built-in progress meter" OFF)
  186. mark_as_advanced(CURL_DISABLE_PROGRESS_METER)
  187. option(CURL_DISABLE_PROXY "disables proxy support" OFF)
  188. mark_as_advanced(CURL_DISABLE_PROXY)
  189. option(CURL_DISABLE_RTSP "disables RTSP" OFF)
  190. mark_as_advanced(CURL_DISABLE_RTSP)
  191. option(CURL_DISABLE_SHUFFLE_DNS "disables shuffle DNS feature" OFF)
  192. mark_as_advanced(CURL_DISABLE_SHUFFLE_DNS)
  193. option(CURL_DISABLE_SMB "disables SMB" OFF)
  194. mark_as_advanced(CURL_DISABLE_SMB)
  195. option(CURL_DISABLE_SMTP "disables SMTP" OFF)
  196. mark_as_advanced(CURL_DISABLE_SMTP)
  197. option(CURL_DISABLE_SOCKETPAIR "disables use of socketpair for curl_multi_poll" OFF)
  198. mark_as_advanced(CURL_DISABLE_SOCKETPAIR)
  199. option(CURL_DISABLE_TELNET "disables Telnet" OFF)
  200. mark_as_advanced(CURL_DISABLE_TELNET)
  201. option(CURL_DISABLE_TFTP "disables TFTP" OFF)
  202. mark_as_advanced(CURL_DISABLE_TFTP)
  203. option(CURL_DISABLE_VERBOSE_STRINGS "disables verbose strings" OFF)
  204. mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS)
  205. # Corresponds to HTTP_ONLY in lib/curl_setup.h
  206. option(HTTP_ONLY "disables all protocols except HTTP (This overrides all CURL_DISABLE_* options)" OFF)
  207. mark_as_advanced(HTTP_ONLY)
  208. if(HTTP_ONLY)
  209. set(CURL_DISABLE_DICT ON)
  210. set(CURL_DISABLE_FILE ON)
  211. set(CURL_DISABLE_FTP ON)
  212. set(CURL_DISABLE_GOPHER ON)
  213. set(CURL_DISABLE_IMAP ON)
  214. set(CURL_DISABLE_LDAP ON)
  215. set(CURL_DISABLE_LDAPS ON)
  216. set(CURL_DISABLE_MQTT ON)
  217. set(CURL_DISABLE_POP3 ON)
  218. set(CURL_DISABLE_RTSP ON)
  219. set(CURL_DISABLE_SMB ON)
  220. set(CURL_DISABLE_SMTP ON)
  221. set(CURL_DISABLE_TELNET ON)
  222. set(CURL_DISABLE_TFTP ON)
  223. endif()
  224. option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON)
  225. mark_as_advanced(ENABLE_IPV6)
  226. if(ENABLE_IPV6 AND NOT WIN32)
  227. include(CheckStructHasMember)
  228. check_struct_has_member("struct sockaddr_in6" sin6_addr "netinet/in.h"
  229. HAVE_SOCKADDR_IN6_SIN6_ADDR)
  230. check_struct_has_member("struct sockaddr_in6" sin6_scope_id "netinet/in.h"
  231. HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
  232. if(NOT HAVE_SOCKADDR_IN6_SIN6_ADDR)
  233. message(WARNING "struct sockaddr_in6 not available, disabling IPv6 support")
  234. # Force the feature off as this name is used as guard macro...
  235. set(ENABLE_IPV6 OFF
  236. CACHE BOOL "Define if you want to enable IPv6 support" FORCE)
  237. endif()
  238. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT ENABLE_ARES)
  239. set(use_core_foundation ON)
  240. find_library(SYSTEMCONFIGURATION_FRAMEWORK "SystemConfiguration")
  241. if(NOT SYSTEMCONFIGURATION_FRAMEWORK)
  242. message(FATAL_ERROR "SystemConfiguration framework not found")
  243. endif()
  244. list(APPEND CURL_LIBS "-framework SystemConfiguration")
  245. endif()
  246. endif()
  247. if(USE_MANUAL)
  248. #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..
  249. curl_nroff_check()
  250. endif()
  251. find_package(Perl)
  252. cmake_dependent_option(ENABLE_MANUAL "to provide the built-in manual"
  253. ON "NROFF_USEFUL;PERL_FOUND"
  254. OFF)
  255. if(ENABLE_MANUAL)
  256. set(USE_MANUAL ON)
  257. endif()
  258. if(CURL_STATIC_CRT)
  259. set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
  260. set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
  261. set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
  262. endif()
  263. # Disable warnings on Borland to avoid changing 3rd party code.
  264. if(BORLAND)
  265. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")
  266. endif()
  267. # If we are on AIX, do the _ALL_SOURCE magic
  268. if(${CMAKE_SYSTEM_NAME} MATCHES AIX)
  269. set(_ALL_SOURCE 1)
  270. endif()
  271. # If we are on Haiku, make sure that the network library is brought in.
  272. if(${CMAKE_SYSTEM_NAME} MATCHES Haiku)
  273. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lnetwork")
  274. endif()
  275. # Include all the necessary files for macros
  276. include(CMakePushCheckState)
  277. include(CheckFunctionExists)
  278. include(CheckIncludeFile)
  279. include(CheckIncludeFiles)
  280. include(CheckLibraryExists)
  281. include(CheckSymbolExists)
  282. include(CheckTypeSize)
  283. include(CheckCSourceCompiles)
  284. # On windows preload settings
  285. if(WIN32)
  286. list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_WINSOCKAPI_=)
  287. include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Platforms/WindowsCache.cmake)
  288. endif()
  289. if(ENABLE_THREADED_RESOLVER)
  290. find_package(Threads REQUIRED)
  291. if(WIN32)
  292. set(USE_THREADS_WIN32 ON)
  293. else()
  294. set(USE_THREADS_POSIX ${CMAKE_USE_PTHREADS_INIT})
  295. set(HAVE_PTHREAD_H ${CMAKE_USE_PTHREADS_INIT})
  296. endif()
  297. set(CURL_LIBS ${CURL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
  298. endif()
  299. # Check for all needed libraries
  300. check_library_exists_concat("socket" connect HAVE_LIBSOCKET)
  301. check_function_exists(gethostname HAVE_GETHOSTNAME)
  302. if(WIN32)
  303. check_library_exists_concat("ws2_32" getch HAVE_LIBWS2_32)
  304. check_library_exists_concat("winmm" getch HAVE_LIBWINMM)
  305. # Matching logic used for Curl_win32_random()
  306. if(MINGW)
  307. check_c_source_compiles("
  308. #include <_mingw.h>
  309. #if defined(__MINGW64_VERSION_MAJOR)
  310. #error
  311. #endif
  312. int main(void) {
  313. return 0;
  314. }"
  315. HAVE_MINGW_ORIGINAL)
  316. endif()
  317. endif()
  318. # check SSL libraries
  319. # TODO support GnuTLS
  320. option(CURL_ENABLE_SSL "Enable SSL support" ON)
  321. if(APPLE)
  322. cmake_dependent_option(CURL_USE_SECTRANSP "enable Apple OS native SSL/TLS" OFF CURL_ENABLE_SSL OFF)
  323. endif()
  324. if(WIN32)
  325. cmake_dependent_option(CURL_USE_SCHANNEL "enable Windows native SSL/TLS" OFF CURL_ENABLE_SSL OFF)
  326. cmake_dependent_option(CURL_WINDOWS_SSPI "Use windows libraries to allow NTLM authentication without OpenSSL" ON
  327. CURL_USE_SCHANNEL OFF)
  328. endif()
  329. cmake_dependent_option(CURL_USE_MBEDTLS "Enable mbedTLS for SSL/TLS" OFF CURL_ENABLE_SSL OFF)
  330. cmake_dependent_option(CURL_USE_BEARSSL "Enable BearSSL for SSL/TLS" OFF CURL_ENABLE_SSL OFF)
  331. cmake_dependent_option(CURL_USE_NSS "Enable NSS for SSL/TLS" OFF CURL_ENABLE_SSL OFF)
  332. cmake_dependent_option(CURL_USE_WOLFSSL "enable wolfSSL for SSL/TLS" OFF CURL_ENABLE_SSL OFF)
  333. set(openssl_default ON)
  334. if(WIN32 OR CURL_USE_SECTRANSP OR CURL_USE_SCHANNEL OR CURL_USE_MBEDTLS OR CURL_USE_NSS OR CURL_USE_WOLFSSL)
  335. set(openssl_default OFF)
  336. endif()
  337. cmake_dependent_option(CURL_USE_OPENSSL "Use OpenSSL code. Experimental" ${openssl_default} CURL_ENABLE_SSL OFF)
  338. option(CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG "Disable automatic loading of OpenSSL configuration" OFF)
  339. count_true(enabled_ssl_options_count
  340. CURL_USE_SCHANNEL
  341. CURL_USE_SECTRANSP
  342. CURL_USE_OPENSSL
  343. CURL_USE_MBEDTLS
  344. CURL_USE_BEARSSL
  345. CURL_USE_NSS
  346. CURL_USE_WOLFSSL
  347. )
  348. if(enabled_ssl_options_count GREATER "1")
  349. set(CURL_WITH_MULTI_SSL ON)
  350. endif()
  351. if(CURL_USE_SCHANNEL)
  352. set(SSL_ENABLED ON)
  353. set(USE_SCHANNEL ON) # Windows native SSL/TLS support
  354. set(USE_WINDOWS_SSPI ON) # CURL_USE_SCHANNEL implies CURL_WINDOWS_SSPI
  355. endif()
  356. if(CURL_WINDOWS_SSPI)
  357. set(USE_WINDOWS_SSPI ON)
  358. endif()
  359. if(CURL_USE_SECTRANSP)
  360. set(use_core_foundation ON)
  361. find_library(SECURITY_FRAMEWORK "Security")
  362. if(NOT SECURITY_FRAMEWORK)
  363. message(FATAL_ERROR "Security framework not found")
  364. endif()
  365. set(SSL_ENABLED ON)
  366. set(USE_SECTRANSP ON)
  367. list(APPEND CURL_LIBS "-framework Security")
  368. endif()
  369. if(use_core_foundation)
  370. find_library(COREFOUNDATION_FRAMEWORK "CoreFoundation")
  371. if(NOT COREFOUNDATION_FRAMEWORK)
  372. message(FATAL_ERROR "CoreFoundation framework not found")
  373. endif()
  374. list(APPEND CURL_LIBS "-framework CoreFoundation")
  375. endif()
  376. if(CURL_USE_OPENSSL)
  377. find_package(OpenSSL REQUIRED)
  378. set(SSL_ENABLED ON)
  379. set(USE_OPENSSL ON)
  380. # Depend on OpenSSL via imported targets if supported by the running
  381. # version of CMake. This allows our dependents to get our dependencies
  382. # transitively.
  383. if(NOT CMAKE_VERSION VERSION_LESS 3.4)
  384. list(APPEND CURL_LIBS OpenSSL::SSL OpenSSL::Crypto)
  385. else()
  386. list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})
  387. include_directories(${OPENSSL_INCLUDE_DIR})
  388. endif()
  389. if(WIN32)
  390. list(APPEND CURL_LIBS "ws2_32")
  391. if(NOT HAVE_MINGW_ORIGINAL)
  392. list(APPEND CURL_LIBS "bcrypt") # for OpenSSL/LibreSSL
  393. endif()
  394. endif()
  395. set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
  396. if(NOT DEFINED HAVE_RAND_EGD)
  397. check_symbol_exists(RAND_egd "${CURL_INCLUDES}" HAVE_RAND_EGD)
  398. endif()
  399. if(NOT DEFINED HAVE_BORINGSSL)
  400. check_symbol_exists(OPENSSL_IS_BORINGSSL "openssl/base.h" HAVE_BORINGSSL)
  401. endif()
  402. if(NOT DEFINED HAVE_AWSLC)
  403. check_symbol_exists(OPENSSL_IS_AWSLC "openssl/base.h" HAVE_AWSLC)
  404. endif()
  405. endif()
  406. if(CURL_USE_MBEDTLS)
  407. find_package(MbedTLS REQUIRED)
  408. set(SSL_ENABLED ON)
  409. set(USE_MBEDTLS ON)
  410. list(APPEND CURL_LIBS ${MBEDTLS_LIBRARIES})
  411. include_directories(${MBEDTLS_INCLUDE_DIRS})
  412. endif()
  413. if(CURL_USE_BEARSSL)
  414. find_package(BearSSL REQUIRED)
  415. set(SSL_ENABLED ON)
  416. set(USE_BEARSSL ON)
  417. list(APPEND CURL_LIBS ${BEARSSL_LIBRARY})
  418. include_directories(${BEARSSL_INCLUDE_DIRS})
  419. endif()
  420. if(CURL_USE_WOLFSSL)
  421. find_package(WolfSSL REQUIRED)
  422. set(SSL_ENABLED ON)
  423. set(USE_WOLFSSL ON)
  424. list(APPEND CURL_LIBS ${WolfSSL_LIBRARIES})
  425. include_directories(${WolfSSL_INCLUDE_DIRS})
  426. endif()
  427. if(CURL_USE_NSS)
  428. find_package(NSS REQUIRED)
  429. include_directories(${NSS_INCLUDE_DIRS})
  430. list(APPEND CURL_LIBS ${NSS_LIBRARIES})
  431. set(SSL_ENABLED ON)
  432. set(USE_NSS ON)
  433. if(NOT DEFINED HAVE_PK11_CREATEMANAGEDGENERICOBJECT)
  434. cmake_push_check_state()
  435. set(CMAKE_REQUIRED_INCLUDES ${NSS_INCLUDE_DIRS})
  436. set(CMAKE_REQUIRED_LIBRARIES ${NSS_LIBRARIES})
  437. check_symbol_exists(PK11_CreateManagedGenericObject "pk11pub.h" HAVE_PK11_CREATEMANAGEDGENERICOBJECT)
  438. cmake_pop_check_state()
  439. endif()
  440. endif()
  441. # Keep ZLIB detection after TLS detection,
  442. # and before calling CheckQuicSupportInOpenSSL.
  443. set(HAVE_LIBZ OFF)
  444. set(USE_ZLIB OFF)
  445. optional_dependency(ZLIB)
  446. if(ZLIB_FOUND)
  447. set(HAVE_LIBZ ON)
  448. set(USE_ZLIB ON)
  449. # Depend on ZLIB via imported targets if supported by the running
  450. # version of CMake. This allows our dependents to get our dependencies
  451. # transitively.
  452. if(NOT CMAKE_VERSION VERSION_LESS 3.4)
  453. list(APPEND CURL_LIBS ZLIB::ZLIB)
  454. else()
  455. list(APPEND CURL_LIBS ${ZLIB_LIBRARIES})
  456. include_directories(${ZLIB_INCLUDE_DIRS})
  457. endif()
  458. list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
  459. endif()
  460. option(CURL_BROTLI "Set to ON to enable building curl with brotli support." OFF)
  461. set(HAVE_BROTLI OFF)
  462. if(CURL_BROTLI)
  463. find_package(Brotli REQUIRED)
  464. if(BROTLI_FOUND)
  465. set(HAVE_BROTLI ON)
  466. set(CURL_LIBS "${BROTLI_LIBRARIES};${CURL_LIBS}") # For 'ld' linker. Emulate `list(PREPEND ...)` to stay compatible with <v3.15 CMake.
  467. list(APPEND CURL_LIBS ${BROTLI_LIBRARIES})
  468. include_directories(${BROTLI_INCLUDE_DIRS})
  469. list(APPEND CMAKE_REQUIRED_INCLUDES ${BROTLI_INCLUDE_DIRS})
  470. endif()
  471. endif()
  472. option(CURL_ZSTD "Set to ON to enable building curl with zstd support." OFF)
  473. set(HAVE_ZSTD OFF)
  474. if(CURL_ZSTD)
  475. find_package(Zstd REQUIRED)
  476. if (NOT DEFINED HAVE_ZSTD_CREATEDSTREAM)
  477. cmake_push_check_state()
  478. set(CMAKE_REQUIRED_INCLUDES ${Zstd_INCLUDE_DIRS})
  479. set(CMAKE_REQUIRED_LIBRARIES ${Zstd_LIBRARIES})
  480. check_symbol_exists(ZSTD_createDStream "zstd.h" HAVE_ZSTD_CREATEDSTREAM)
  481. cmake_pop_check_state()
  482. endif()
  483. if(Zstd_FOUND AND HAVE_ZSTD_CREATEDSTREAM)
  484. set(HAVE_ZSTD ON)
  485. list(APPEND CURL_LIBS ${Zstd_LIBRARIES})
  486. include_directories(${Zstd_INCLUDE_DIRS})
  487. endif()
  488. endif()
  489. option(USE_NGHTTP2 "Use Nghttp2 library" OFF)
  490. if(USE_NGHTTP2)
  491. find_package(NGHTTP2 REQUIRED)
  492. include_directories(${NGHTTP2_INCLUDE_DIRS})
  493. list(APPEND CURL_LIBS ${NGHTTP2_LIBRARIES})
  494. endif()
  495. function(CheckQuicSupportInOpenSSL)
  496. # Be sure that the OpenSSL/wolfSSL library actually supports QUIC.
  497. if(NOT DEFINED HAVE_SSL_CTX_SET_QUIC_METHOD)
  498. cmake_push_check_state()
  499. if(USE_WOLFSSL)
  500. set(CMAKE_REQUIRED_INCLUDES "${WolfSSL_INCLUDE_DIRS}")
  501. set(CMAKE_REQUIRED_LIBRARIES "${WolfSSL_LIBRARIES}")
  502. if(HAVE_LIBZ)
  503. list(APPEND CMAKE_REQUIRED_INCLUDES "${ZLIB_INCLUDE_DIRS}") # Public wolfSSL headers require zlib headers
  504. list(APPEND CMAKE_REQUIRED_LIBRARIES "${ZLIB_LIBRARIES}")
  505. endif()
  506. if(WIN32)
  507. list(APPEND CMAKE_REQUIRED_LIBRARIES "ws2_32" "crypt32")
  508. endif()
  509. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_UINTPTR_T) # to pull in stdint.h (as of wolfSSL v5.5.4)
  510. check_symbol_exists(wolfSSL_set_quic_method "wolfssl/options.h;wolfssl/openssl/ssl.h" HAVE_SSL_CTX_SET_QUIC_METHOD)
  511. else()
  512. set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}")
  513. set(CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES}")
  514. if(HAVE_LIBZ)
  515. list(APPEND CMAKE_REQUIRED_LIBRARIES "${ZLIB_LIBRARIES}")
  516. endif()
  517. if(WIN32)
  518. list(APPEND CMAKE_REQUIRED_LIBRARIES "ws2_32")
  519. if(NOT HAVE_MINGW_ORIGINAL)
  520. list(APPEND CMAKE_REQUIRED_LIBRARIES "bcrypt") # for OpenSSL/LibreSSL
  521. endif()
  522. endif()
  523. check_symbol_exists(SSL_CTX_set_quic_method "openssl/ssl.h" HAVE_SSL_CTX_SET_QUIC_METHOD)
  524. endif()
  525. cmake_pop_check_state()
  526. endif()
  527. if(NOT HAVE_SSL_CTX_SET_QUIC_METHOD)
  528. message(FATAL_ERROR "QUIC support is missing in OpenSSL/LibreSSL/BoringSSL/wolfSSL. Try setting -DOPENSSL_ROOT_DIR")
  529. endif()
  530. endfunction()
  531. option(USE_NGTCP2 "Use ngtcp2 and nghttp3 libraries for HTTP/3 support" OFF)
  532. if(USE_NGTCP2)
  533. if(USE_OPENSSL OR USE_WOLFSSL)
  534. if(USE_WOLFSSL)
  535. find_package(NGTCP2 REQUIRED wolfSSL)
  536. elseif(HAVE_BORINGSSL)
  537. find_package(NGTCP2 REQUIRED BoringSSL)
  538. else()
  539. find_package(NGTCP2 REQUIRED quictls)
  540. endif()
  541. CheckQuicSupportInOpenSSL()
  542. elseif(USE_GNUTLS)
  543. # TODO add GnuTLS support as vtls library.
  544. find_package(NGTCP2 REQUIRED GnuTLS)
  545. else()
  546. message(FATAL_ERROR "ngtcp2 requires OpenSSL, wolfSSL or GnuTLS")
  547. endif()
  548. set(USE_NGTCP2 ON)
  549. include_directories(${NGTCP2_INCLUDE_DIRS})
  550. list(APPEND CURL_LIBS ${NGTCP2_LIBRARIES})
  551. find_package(NGHTTP3 REQUIRED)
  552. set(USE_NGHTTP3 ON)
  553. include_directories(${NGHTTP3_INCLUDE_DIRS})
  554. list(APPEND CURL_LIBS ${NGHTTP3_LIBRARIES})
  555. endif()
  556. option(USE_QUICHE "Use quiche library for HTTP/3 support" OFF)
  557. if(USE_QUICHE)
  558. if(USE_NGTCP2)
  559. message(FATAL_ERROR "Only one HTTP/3 backend can be selected!")
  560. endif()
  561. find_package(QUICHE REQUIRED)
  562. CheckQuicSupportInOpenSSL()
  563. set(USE_QUICHE ON)
  564. include_directories(${QUICHE_INCLUDE_DIRS})
  565. list(APPEND CURL_LIBS ${QUICHE_LIBRARIES})
  566. if(NOT DEFINED HAVE_QUICHE_CONN_SET_QLOG_FD)
  567. cmake_push_check_state()
  568. set(CMAKE_REQUIRED_INCLUDES "${QUICHE_INCLUDE_DIRS}")
  569. set(CMAKE_REQUIRED_LIBRARIES "${QUICHE_LIBRARIES}")
  570. check_symbol_exists(quiche_conn_set_qlog_fd "quiche.h" HAVE_QUICHE_CONN_SET_QLOG_FD)
  571. cmake_pop_check_state()
  572. endif()
  573. endif()
  574. option(USE_MSH3 "Use msquic library for HTTP/3 support" OFF)
  575. if(USE_MSH3)
  576. if(USE_NGTCP2 OR USE_QUICHE)
  577. message(FATAL_ERROR "Only one HTTP/3 backend can be selected!")
  578. endif()
  579. set(USE_MSH3 ON)
  580. include_directories(${MSH3_INCLUDE_DIRS})
  581. list(APPEND CURL_LIBS ${MSH3_LIBRARIES})
  582. endif()
  583. if(NOT CURL_DISABLE_LDAP)
  584. if(WIN32)
  585. option(USE_WIN32_LDAP "Use Windows LDAP implementation" ON)
  586. if(USE_WIN32_LDAP)
  587. check_library_exists_concat("wldap32" cldap_open HAVE_WLDAP32)
  588. if(NOT HAVE_WLDAP32)
  589. set(USE_WIN32_LDAP OFF)
  590. elseif(NOT CURL_DISABLE_LDAPS)
  591. set(HAVE_LDAP_SSL ON)
  592. endif()
  593. endif()
  594. endif()
  595. option(CURL_USE_OPENLDAP "Use OpenLDAP code." OFF)
  596. mark_as_advanced(CURL_USE_OPENLDAP)
  597. set(CMAKE_LDAP_LIB "ldap" CACHE STRING "Name or full path to ldap library")
  598. set(CMAKE_LBER_LIB "lber" CACHE STRING "Name or full path to lber library")
  599. if(CURL_USE_OPENLDAP AND USE_WIN32_LDAP)
  600. message(FATAL_ERROR "Cannot use USE_WIN32_LDAP and CURL_USE_OPENLDAP at the same time")
  601. endif()
  602. # Now that we know, we're not using windows LDAP...
  603. if(NOT USE_WIN32_LDAP)
  604. # Check for LDAP
  605. set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES})
  606. check_library_exists_concat(${CMAKE_LDAP_LIB} ldap_init HAVE_LIBLDAP)
  607. check_library_exists_concat(${CMAKE_LBER_LIB} ber_init HAVE_LIBLBER)
  608. set(CMAKE_REQUIRED_INCLUDES_BAK ${CMAKE_REQUIRED_INCLUDES})
  609. set(CMAKE_LDAP_INCLUDE_DIR "" CACHE STRING "Path to LDAP include directory")
  610. if(CMAKE_LDAP_INCLUDE_DIR)
  611. list(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_LDAP_INCLUDE_DIR})
  612. endif()
  613. check_include_file_concat("ldap.h" HAVE_LDAP_H)
  614. check_include_file_concat("lber.h" HAVE_LBER_H)
  615. if(NOT HAVE_LDAP_H)
  616. message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON")
  617. set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
  618. set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) #LDAP includes won't be used
  619. elseif(NOT HAVE_LIBLDAP)
  620. message(STATUS "LDAP library '${CMAKE_LDAP_LIB}' not found CURL_DISABLE_LDAP set ON")
  621. set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
  622. set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) #LDAP includes won't be used
  623. else()
  624. if(CURL_USE_OPENLDAP)
  625. set(USE_OPENLDAP ON)
  626. endif()
  627. if(CMAKE_LDAP_INCLUDE_DIR)
  628. include_directories(${CMAKE_LDAP_INCLUDE_DIR})
  629. endif()
  630. set(NEED_LBER_H ON)
  631. set(_HEADER_LIST)
  632. if(HAVE_WINDOWS_H)
  633. list(APPEND _HEADER_LIST "windows.h")
  634. endif()
  635. if(HAVE_SYS_TYPES_H)
  636. list(APPEND _HEADER_LIST "sys/types.h")
  637. endif()
  638. list(APPEND _HEADER_LIST "ldap.h")
  639. set(_SRC_STRING "")
  640. foreach(_HEADER ${_HEADER_LIST})
  641. set(_INCLUDE_STRING "${_INCLUDE_STRING}#include <${_HEADER}>\n")
  642. endforeach()
  643. set(_SRC_STRING
  644. "
  645. ${_INCLUDE_STRING}
  646. int main(int argc, char ** argv)
  647. {
  648. BerValue *bvp = NULL;
  649. BerElement *bep = ber_init(bvp);
  650. ber_free(bep, 1);
  651. return 0;
  652. }"
  653. )
  654. list(APPEND CMAKE_REQUIRED_DEFINITIONS -DLDAP_DEPRECATED=1)
  655. list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB})
  656. if(HAVE_LIBLBER)
  657. list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LBER_LIB})
  658. endif()
  659. check_c_source_compiles("${_SRC_STRING}" NOT_NEED_LBER_H)
  660. unset(CMAKE_REQUIRED_LIBRARIES)
  661. if(NOT_NEED_LBER_H)
  662. set(NEED_LBER_H OFF)
  663. else()
  664. set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -DNEED_LBER_H")
  665. endif()
  666. endif()
  667. endif()
  668. endif()
  669. # No ldap, no ldaps.
  670. if(CURL_DISABLE_LDAP)
  671. if(NOT CURL_DISABLE_LDAPS)
  672. message(STATUS "LDAP needs to be enabled to support LDAPS")
  673. set(CURL_DISABLE_LDAPS ON CACHE BOOL "" FORCE)
  674. endif()
  675. endif()
  676. if(NOT CURL_DISABLE_LDAPS)
  677. check_include_file_concat("ldap_ssl.h" HAVE_LDAP_SSL_H)
  678. endif()
  679. # Check for idn2
  680. option(USE_LIBIDN2 "Use libidn2 for IDN support" ON)
  681. if(USE_LIBIDN2)
  682. check_library_exists_concat("idn2" idn2_lookup_ul HAVE_LIBIDN2)
  683. else()
  684. set(HAVE_LIBIDN2 OFF)
  685. endif()
  686. if(WIN32)
  687. option(USE_WIN32_IDN "Use WinIDN for IDN support" OFF)
  688. if(USE_WIN32_IDN)
  689. list(APPEND CURL_LIBS "normaliz")
  690. endif()
  691. endif()
  692. #libpsl
  693. option(CURL_USE_LIBPSL "Use libPSL" ON)
  694. mark_as_advanced(CURL_USE_LIBPSL)
  695. set(USE_LIBPSL OFF)
  696. if(CURL_USE_LIBPSL)
  697. find_package(LibPSL)
  698. if(LIBPSL_FOUND)
  699. list(APPEND CURL_LIBS ${LIBPSL_LIBRARY})
  700. list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBPSL_INCLUDE_DIR}")
  701. include_directories("${LIBPSL_INCLUDE_DIR}")
  702. set(USE_LIBPSL ON)
  703. endif()
  704. endif()
  705. #libSSH2
  706. option(CURL_USE_LIBSSH2 "Use libSSH2" ON)
  707. mark_as_advanced(CURL_USE_LIBSSH2)
  708. set(USE_LIBSSH2 OFF)
  709. if(CURL_USE_LIBSSH2)
  710. find_package(LibSSH2)
  711. if(LIBSSH2_FOUND)
  712. list(APPEND CURL_LIBS ${LIBSSH2_LIBRARY})
  713. list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIR}")
  714. include_directories("${LIBSSH2_INCLUDE_DIR}")
  715. set(USE_LIBSSH2 ON)
  716. endif()
  717. endif()
  718. # libssh
  719. option(CURL_USE_LIBSSH "Use libSSH" OFF)
  720. mark_as_advanced(CURL_USE_LIBSSH)
  721. if(NOT USE_LIBSSH2 AND CURL_USE_LIBSSH)
  722. find_package(libssh CONFIG)
  723. if(libssh_FOUND)
  724. message(STATUS "Found libssh ${libssh_VERSION}")
  725. # Use imported target for include and library paths.
  726. list(APPEND CURL_LIBS ssh)
  727. set(USE_LIBSSH ON)
  728. endif()
  729. endif()
  730. option(CURL_USE_GSSAPI "Use GSSAPI implementation (right now only Heimdal is supported with CMake build)" OFF)
  731. mark_as_advanced(CURL_USE_GSSAPI)
  732. if(CURL_USE_GSSAPI)
  733. find_package(GSS)
  734. set(HAVE_GSSAPI ${GSS_FOUND})
  735. if(GSS_FOUND)
  736. message(STATUS "Found ${GSS_FLAVOUR} GSSAPI version: \"${GSS_VERSION}\"")
  737. list(APPEND CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIR})
  738. check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H)
  739. check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H)
  740. check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H)
  741. if(GSS_FLAVOUR STREQUAL "Heimdal")
  742. set(HAVE_GSSHEIMDAL ON)
  743. else() # MIT
  744. set(HAVE_GSSMIT ON)
  745. set(_INCLUDE_LIST "")
  746. if(HAVE_GSSAPI_GSSAPI_H)
  747. list(APPEND _INCLUDE_LIST "gssapi/gssapi.h")
  748. endif()
  749. if(HAVE_GSSAPI_GSSAPI_GENERIC_H)
  750. list(APPEND _INCLUDE_LIST "gssapi/gssapi_generic.h")
  751. endif()
  752. if(HAVE_GSSAPI_GSSAPI_KRB5_H)
  753. list(APPEND _INCLUDE_LIST "gssapi/gssapi_krb5.h")
  754. endif()
  755. string(REPLACE ";" " " _COMPILER_FLAGS_STR "${GSS_COMPILER_FLAGS}")
  756. string(REPLACE ";" " " _LINKER_FLAGS_STR "${GSS_LINKER_FLAGS}")
  757. foreach(_dir ${GSS_LINK_DIRECTORIES})
  758. set(_LINKER_FLAGS_STR "${_LINKER_FLAGS_STR} -L\"${_dir}\"")
  759. endforeach()
  760. if(NOT DEFINED HAVE_GSS_C_NT_HOSTBASED_SERVICE)
  761. set(CMAKE_REQUIRED_FLAGS "${_COMPILER_FLAGS_STR} ${_LINKER_FLAGS_STR}")
  762. set(CMAKE_REQUIRED_LIBRARIES ${GSS_LIBRARIES})
  763. check_symbol_exists("GSS_C_NT_HOSTBASED_SERVICE" ${_INCLUDE_LIST} HAVE_GSS_C_NT_HOSTBASED_SERVICE)
  764. unset(CMAKE_REQUIRED_LIBRARIES)
  765. endif()
  766. if(NOT HAVE_GSS_C_NT_HOSTBASED_SERVICE)
  767. set(HAVE_OLD_GSSMIT ON)
  768. endif()
  769. endif()
  770. include_directories(${GSS_INCLUDE_DIR})
  771. link_directories(${GSS_LINK_DIRECTORIES})
  772. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSS_COMPILER_FLAGS}")
  773. string(REPLACE ";" " " GSS_LINKER_FLAGS "${GSS_LINKER_FLAGS}")
  774. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GSS_LINKER_FLAGS}")
  775. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GSS_LINKER_FLAGS}")
  776. set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${GSS_LINKER_FLAGS}")
  777. list(APPEND CURL_LIBS ${GSS_LIBRARIES})
  778. else()
  779. message(WARNING "GSSAPI support has been requested but no supporting libraries found. Skipping.")
  780. endif()
  781. endif()
  782. option(ENABLE_UNIX_SOCKETS "Define if you want Unix domain sockets support" ON)
  783. if(ENABLE_UNIX_SOCKETS)
  784. include(CheckStructHasMember)
  785. if(WIN32)
  786. set(USE_UNIX_SOCKETS ON)
  787. else()
  788. check_struct_has_member("struct sockaddr_un" sun_path "sys/un.h" USE_UNIX_SOCKETS)
  789. endif()
  790. else()
  791. unset(USE_UNIX_SOCKETS CACHE)
  792. endif()
  793. #
  794. # CA handling
  795. #
  796. set(CURL_CA_BUNDLE "auto" CACHE STRING
  797. "Path to the CA bundle. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
  798. set(CURL_CA_FALLBACK OFF CACHE BOOL
  799. "Set ON to use built-in CA store of TLS backend. Defaults to OFF")
  800. set(CURL_CA_PATH "auto" CACHE STRING
  801. "Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
  802. if("${CURL_CA_BUNDLE}" STREQUAL "")
  803. message(FATAL_ERROR "Invalid value of CURL_CA_BUNDLE. Use 'none', 'auto' or file path.")
  804. elseif("${CURL_CA_BUNDLE}" STREQUAL "none")
  805. unset(CURL_CA_BUNDLE CACHE)
  806. elseif("${CURL_CA_BUNDLE}" STREQUAL "auto")
  807. unset(CURL_CA_BUNDLE CACHE)
  808. if(NOT CMAKE_CROSSCOMPILING)
  809. set(CURL_CA_BUNDLE_AUTODETECT TRUE)
  810. endif()
  811. else()
  812. set(CURL_CA_BUNDLE_SET TRUE)
  813. endif()
  814. if("${CURL_CA_PATH}" STREQUAL "")
  815. message(FATAL_ERROR "Invalid value of CURL_CA_PATH. Use 'none', 'auto' or directory path.")
  816. elseif("${CURL_CA_PATH}" STREQUAL "none")
  817. unset(CURL_CA_PATH CACHE)
  818. elseif("${CURL_CA_PATH}" STREQUAL "auto")
  819. unset(CURL_CA_PATH CACHE)
  820. if(NOT CMAKE_CROSSCOMPILING AND NOT USE_NSS)
  821. set(CURL_CA_PATH_AUTODETECT TRUE)
  822. endif()
  823. else()
  824. set(CURL_CA_PATH_SET TRUE)
  825. endif()
  826. if(CURL_CA_BUNDLE_SET AND CURL_CA_PATH_AUTODETECT)
  827. # Skip autodetection of unset CA path because CA bundle is set explicitly
  828. elseif(CURL_CA_PATH_SET AND CURL_CA_BUNDLE_AUTODETECT)
  829. # Skip autodetection of unset CA bundle because CA path is set explicitly
  830. elseif(CURL_CA_PATH_AUTODETECT OR CURL_CA_BUNDLE_AUTODETECT)
  831. # first try autodetecting a CA bundle, then a CA path
  832. if(CURL_CA_BUNDLE_AUTODETECT)
  833. set(SEARCH_CA_BUNDLE_PATHS
  834. /etc/ssl/certs/ca-certificates.crt
  835. /etc/pki/tls/certs/ca-bundle.crt
  836. /usr/share/ssl/certs/ca-bundle.crt
  837. /usr/local/share/certs/ca-root-nss.crt
  838. /etc/ssl/cert.pem)
  839. foreach(SEARCH_CA_BUNDLE_PATH ${SEARCH_CA_BUNDLE_PATHS})
  840. if(EXISTS "${SEARCH_CA_BUNDLE_PATH}")
  841. message(STATUS "Found CA bundle: ${SEARCH_CA_BUNDLE_PATH}")
  842. set(CURL_CA_BUNDLE "${SEARCH_CA_BUNDLE_PATH}" CACHE STRING
  843. "Path to the CA bundle. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
  844. set(CURL_CA_BUNDLE_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
  845. break()
  846. endif()
  847. endforeach()
  848. endif()
  849. if(CURL_CA_PATH_AUTODETECT AND (NOT CURL_CA_PATH_SET))
  850. if(EXISTS "/etc/ssl/certs")
  851. set(CURL_CA_PATH "/etc/ssl/certs" CACHE STRING
  852. "Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
  853. set(CURL_CA_PATH_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
  854. endif()
  855. endif()
  856. endif()
  857. if(CURL_CA_PATH_SET AND NOT USE_OPENSSL AND NOT USE_MBEDTLS)
  858. message(STATUS
  859. "CA path only supported by OpenSSL, GnuTLS or mbed TLS. "
  860. "Set CURL_CA_PATH=none or enable one of those TLS backends.")
  861. endif()
  862. # Check for header files
  863. if(NOT UNIX)
  864. check_include_file_concat("windows.h" HAVE_WINDOWS_H)
  865. check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H)
  866. check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H)
  867. check_include_file_concat("wincrypt.h" HAVE_WINCRYPT_H)
  868. endif()
  869. check_include_file_concat("inttypes.h" HAVE_INTTYPES_H)
  870. check_include_file_concat("sys/filio.h" HAVE_SYS_FILIO_H)
  871. check_include_file_concat("sys/ioctl.h" HAVE_SYS_IOCTL_H)
  872. check_include_file_concat("sys/param.h" HAVE_SYS_PARAM_H)
  873. check_include_file_concat("sys/poll.h" HAVE_SYS_POLL_H)
  874. check_include_file_concat("sys/resource.h" HAVE_SYS_RESOURCE_H)
  875. check_include_file_concat("sys/select.h" HAVE_SYS_SELECT_H)
  876. check_include_file_concat("sys/socket.h" HAVE_SYS_SOCKET_H)
  877. check_include_file_concat("sys/sockio.h" HAVE_SYS_SOCKIO_H)
  878. check_include_file_concat("sys/stat.h" HAVE_SYS_STAT_H)
  879. check_include_file_concat("sys/time.h" HAVE_SYS_TIME_H)
  880. check_include_file_concat("sys/types.h" HAVE_SYS_TYPES_H)
  881. check_include_file_concat("sys/un.h" HAVE_SYS_UN_H)
  882. check_include_file_concat("sys/utime.h" HAVE_SYS_UTIME_H)
  883. check_include_file_concat("sys/xattr.h" HAVE_SYS_XATTR_H)
  884. check_include_file_concat("arpa/inet.h" HAVE_ARPA_INET_H)
  885. check_include_file_concat("arpa/tftp.h" HAVE_ARPA_TFTP_H)
  886. check_include_file_concat("fcntl.h" HAVE_FCNTL_H)
  887. check_include_file_concat("idn2.h" HAVE_IDN2_H)
  888. check_include_file_concat("ifaddrs.h" HAVE_IFADDRS_H)
  889. check_include_file_concat("io.h" HAVE_IO_H)
  890. check_include_file_concat("libgen.h" HAVE_LIBGEN_H)
  891. check_include_file_concat("locale.h" HAVE_LOCALE_H)
  892. check_include_file_concat("net/if.h" HAVE_NET_IF_H)
  893. check_include_file_concat("netdb.h" HAVE_NETDB_H)
  894. check_include_file_concat("netinet/in.h" HAVE_NETINET_IN_H)
  895. check_include_file_concat("netinet/tcp.h" HAVE_NETINET_TCP_H)
  896. check_include_file("linux/tcp.h" HAVE_LINUX_TCP_H)
  897. check_include_file_concat("poll.h" HAVE_POLL_H)
  898. check_include_file_concat("pwd.h" HAVE_PWD_H)
  899. check_include_file_concat("setjmp.h" HAVE_SETJMP_H)
  900. check_include_file_concat("signal.h" HAVE_SIGNAL_H)
  901. check_include_file_concat("ssl.h" HAVE_SSL_H)
  902. check_include_file_concat("stdatomic.h" HAVE_STDATOMIC_H)
  903. check_include_file_concat("stdbool.h" HAVE_STDBOOL_H)
  904. check_include_file_concat("stdint.h" HAVE_STDINT_H)
  905. check_include_file_concat("stdlib.h" HAVE_STDLIB_H)
  906. check_include_file_concat("string.h" HAVE_STRING_H)
  907. check_include_file_concat("strings.h" HAVE_STRINGS_H)
  908. check_include_file_concat("stropts.h" HAVE_STROPTS_H)
  909. check_include_file_concat("termio.h" HAVE_TERMIO_H)
  910. check_include_file_concat("termios.h" HAVE_TERMIOS_H)
  911. check_include_file_concat("time.h" HAVE_TIME_H)
  912. check_include_file_concat("unistd.h" HAVE_UNISTD_H)
  913. check_include_file_concat("utime.h" HAVE_UTIME_H)
  914. check_include_file_concat("stddef.h" HAVE_STDDEF_H)
  915. check_include_file_concat("sys/utsname.h" HAVE_SYS_UTSNAME_H)
  916. check_type_size(size_t SIZEOF_SIZE_T)
  917. check_type_size(ssize_t SIZEOF_SSIZE_T)
  918. check_type_size("long long" SIZEOF_LONG_LONG)
  919. check_type_size("long" SIZEOF_LONG)
  920. check_type_size("int" SIZEOF_INT)
  921. check_type_size("__int64" SIZEOF___INT64)
  922. check_type_size("time_t" SIZEOF_TIME_T)
  923. if(NOT HAVE_SIZEOF_SSIZE_T)
  924. if(SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
  925. set(ssize_t long)
  926. endif()
  927. if(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
  928. set(ssize_t __int64)
  929. endif()
  930. endif()
  931. # off_t is sized later, after the HAVE_FILE_OFFSET_BITS test
  932. if(HAVE_SIZEOF_LONG_LONG)
  933. set(HAVE_LONGLONG 1)
  934. endif()
  935. if(NOT CMAKE_CROSSCOMPILING)
  936. find_file(RANDOM_FILE urandom /dev)
  937. mark_as_advanced(RANDOM_FILE)
  938. endif()
  939. # Check for some functions that are used
  940. if(HAVE_LIBWS2_32)
  941. set(CMAKE_REQUIRED_LIBRARIES ws2_32)
  942. elseif(HAVE_LIBSOCKET)
  943. set(CMAKE_REQUIRED_LIBRARIES socket)
  944. endif()
  945. check_symbol_exists(fchmod "${CURL_INCLUDES}" HAVE_FCHMOD)
  946. check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME)
  947. check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET)
  948. check_symbol_exists(socketpair "${CURL_INCLUDES}" HAVE_SOCKETPAIR)
  949. check_symbol_exists(recv "${CURL_INCLUDES}" HAVE_RECV)
  950. check_symbol_exists(send "${CURL_INCLUDES}" HAVE_SEND)
  951. check_symbol_exists(sendmsg "${CURL_INCLUDES}" HAVE_SENDMSG)
  952. check_symbol_exists(select "${CURL_INCLUDES}" HAVE_SELECT)
  953. check_symbol_exists(strdup "${CURL_INCLUDES}" HAVE_STRDUP)
  954. check_symbol_exists(strtok_r "${CURL_INCLUDES}" HAVE_STRTOK_R)
  955. check_symbol_exists(strcasecmp "${CURL_INCLUDES}" HAVE_STRCASECMP)
  956. check_symbol_exists(stricmp "${CURL_INCLUDES}" HAVE_STRICMP)
  957. check_symbol_exists(strcmpi "${CURL_INCLUDES}" HAVE_STRCMPI)
  958. check_symbol_exists(alarm "${CURL_INCLUDES}" HAVE_ALARM)
  959. check_symbol_exists(getppid "${CURL_INCLUDES}" HAVE_GETPPID)
  960. check_symbol_exists(utimes "${CURL_INCLUDES}" HAVE_UTIMES)
  961. check_symbol_exists(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY)
  962. check_symbol_exists(closesocket "${CURL_INCLUDES}" HAVE_CLOSESOCKET)
  963. check_symbol_exists(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP)
  964. check_symbol_exists(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R)
  965. check_symbol_exists(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID)
  966. check_symbol_exists(getpwuid_r "${CURL_INCLUDES}" HAVE_GETPWUID_R)
  967. check_symbol_exists(geteuid "${CURL_INCLUDES}" HAVE_GETEUID)
  968. check_symbol_exists(utime "${CURL_INCLUDES}" HAVE_UTIME)
  969. check_symbol_exists(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R)
  970. check_symbol_exists(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R)
  971. check_symbol_exists(signal "${CURL_INCLUDES}" HAVE_SIGNAL)
  972. check_symbol_exists(strtoll "${CURL_INCLUDES}" HAVE_STRTOLL)
  973. check_symbol_exists(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R)
  974. check_symbol_exists(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT)
  975. check_symbol_exists(getaddrinfo "${CURL_INCLUDES}" HAVE_GETADDRINFO)
  976. if(WIN32)
  977. set(HAVE_GETADDRINFO_THREADSAFE ${HAVE_GETADDRINFO})
  978. endif()
  979. check_symbol_exists(freeaddrinfo "${CURL_INCLUDES}" HAVE_FREEADDRINFO)
  980. check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE)
  981. check_symbol_exists(ftruncate "${CURL_INCLUDES}" HAVE_FTRUNCATE)
  982. check_symbol_exists(getpeername "${CURL_INCLUDES}" HAVE_GETPEERNAME)
  983. check_symbol_exists(getsockname "${CURL_INCLUDES}" HAVE_GETSOCKNAME)
  984. check_symbol_exists(if_nametoindex "${CURL_INCLUDES}" HAVE_IF_NAMETOINDEX)
  985. check_symbol_exists(getrlimit "${CURL_INCLUDES}" HAVE_GETRLIMIT)
  986. check_symbol_exists(setlocale "${CURL_INCLUDES}" HAVE_SETLOCALE)
  987. check_symbol_exists(setmode "${CURL_INCLUDES}" HAVE_SETMODE)
  988. check_symbol_exists(setrlimit "${CURL_INCLUDES}" HAVE_SETRLIMIT)
  989. if(NOT MSVC OR (MSVC_VERSION GREATER_EQUAL 1900))
  990. # earlier MSVC compilers had faulty snprintf implementations
  991. check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
  992. endif()
  993. check_function_exists(mach_absolute_time HAVE_MACH_ABSOLUTE_TIME)
  994. check_symbol_exists(inet_ntop "${CURL_INCLUDES}" HAVE_INET_NTOP)
  995. if(MSVC AND (MSVC_VERSION LESS_EQUAL 1600))
  996. set(HAVE_INET_NTOP OFF)
  997. endif()
  998. check_symbol_exists(inet_pton "${CURL_INCLUDES}" HAVE_INET_PTON)
  999. check_symbol_exists(fsetxattr "${CURL_INCLUDES}" HAVE_FSETXATTR)
  1000. if(HAVE_FSETXATTR)
  1001. foreach(CURL_TEST HAVE_FSETXATTR_5 HAVE_FSETXATTR_6)
  1002. curl_internal_test(${CURL_TEST})
  1003. endforeach()
  1004. endif()
  1005. set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h")
  1006. check_type_size("sa_family_t" SIZEOF_SA_FAMILY_T)
  1007. set(HAVE_SA_FAMILY_T ${HAVE_SIZEOF_SA_FAMILY_T})
  1008. set(CMAKE_EXTRA_INCLUDE_FILES "")
  1009. set(CMAKE_EXTRA_INCLUDE_FILES "ws2def.h")
  1010. check_type_size("ADDRESS_FAMILY" SIZEOF_ADDRESS_FAMILY)
  1011. set(HAVE_ADDRESS_FAMILY ${HAVE_SIZEOF_ADDRESS_FAMILY})
  1012. set(CMAKE_EXTRA_INCLUDE_FILES "")
  1013. # sigaction and sigsetjmp are special. Use special mechanism for
  1014. # detecting those, but only if previous attempt failed.
  1015. if(HAVE_SIGNAL_H)
  1016. check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
  1017. endif()
  1018. if(NOT HAVE_SIGSETJMP)
  1019. if(HAVE_SETJMP_H)
  1020. check_symbol_exists(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP)
  1021. if(HAVE_MACRO_SIGSETJMP)
  1022. set(HAVE_SIGSETJMP 1)
  1023. endif()
  1024. endif()
  1025. endif()
  1026. # If there is no stricmp(), do not allow LDAP to parse URLs
  1027. if(NOT HAVE_STRICMP)
  1028. set(HAVE_LDAP_URL_PARSE 1)
  1029. endif()
  1030. # Do curl specific tests
  1031. foreach(CURL_TEST
  1032. HAVE_FCNTL_O_NONBLOCK
  1033. HAVE_IOCTLSOCKET
  1034. HAVE_IOCTLSOCKET_CAMEL
  1035. HAVE_IOCTLSOCKET_CAMEL_FIONBIO
  1036. HAVE_IOCTLSOCKET_FIONBIO
  1037. HAVE_IOCTL_FIONBIO
  1038. HAVE_IOCTL_SIOCGIFADDR
  1039. HAVE_SETSOCKOPT_SO_NONBLOCK
  1040. TIME_WITH_SYS_TIME
  1041. HAVE_O_NONBLOCK
  1042. HAVE_GETHOSTBYNAME_R_3
  1043. HAVE_GETHOSTBYNAME_R_5
  1044. HAVE_GETHOSTBYNAME_R_6
  1045. HAVE_GETHOSTBYNAME_R_3_REENTRANT
  1046. HAVE_GETHOSTBYNAME_R_5_REENTRANT
  1047. HAVE_GETHOSTBYNAME_R_6_REENTRANT
  1048. HAVE_IN_ADDR_T
  1049. HAVE_BOOL_T
  1050. STDC_HEADERS
  1051. HAVE_FILE_OFFSET_BITS
  1052. HAVE_VARIADIC_MACROS_C99
  1053. HAVE_VARIADIC_MACROS_GCC
  1054. HAVE_ATOMIC
  1055. )
  1056. curl_internal_test(${CURL_TEST})
  1057. endforeach()
  1058. if(HAVE_FILE_OFFSET_BITS)
  1059. set(_FILE_OFFSET_BITS 64)
  1060. set(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64")
  1061. endif()
  1062. check_type_size("off_t" SIZEOF_OFF_T)
  1063. # include this header to get the type
  1064. set(CMAKE_REQUIRED_INCLUDES "${CURL_SOURCE_DIR}/include")
  1065. set(CMAKE_EXTRA_INCLUDE_FILES "curl/system.h")
  1066. check_type_size("curl_off_t" SIZEOF_CURL_OFF_T)
  1067. set(CMAKE_EXTRA_INCLUDE_FILES "curl/curl.h")
  1068. check_type_size("curl_socket_t" SIZEOF_CURL_SOCKET_T)
  1069. set(CMAKE_EXTRA_INCLUDE_FILES "")
  1070. if(WIN32)
  1071. # detect actual value of _WIN32_WINNT and store as HAVE_WIN32_WINNT
  1072. curl_internal_test(HAVE_WIN32_WINNT)
  1073. if(HAVE_WIN32_WINNT)
  1074. string(REGEX MATCH ".*_WIN32_WINNT=0x[0-9a-fA-F]+" OUTPUT "${OUTPUT}")
  1075. string(REGEX REPLACE ".*_WIN32_WINNT=" "" HAVE_WIN32_WINNT "${OUTPUT}")
  1076. message(STATUS "Found _WIN32_WINNT=${HAVE_WIN32_WINNT}")
  1077. endif()
  1078. # avoid storing HAVE_WIN32_WINNT in CMake cache
  1079. unset(HAVE_WIN32_WINNT CACHE)
  1080. endif()
  1081. set(CMAKE_REQUIRED_FLAGS)
  1082. option(ENABLE_WEBSOCKETS "Set to ON to enable EXPERIMENTAL websockets" OFF)
  1083. if(ENABLE_WEBSOCKETS)
  1084. if(${SIZEOF_CURL_OFF_T} GREATER "4")
  1085. set(USE_WEBSOCKETS ON)
  1086. else()
  1087. message(WARNING "curl_off_t is too small to enable WebSockets")
  1088. endif()
  1089. endif()
  1090. foreach(CURL_TEST
  1091. HAVE_GLIBC_STRERROR_R
  1092. HAVE_POSIX_STRERROR_R
  1093. )
  1094. curl_internal_test(${CURL_TEST})
  1095. endforeach()
  1096. # Check for reentrant
  1097. foreach(CURL_TEST
  1098. HAVE_GETHOSTBYNAME_R_3
  1099. HAVE_GETHOSTBYNAME_R_5
  1100. HAVE_GETHOSTBYNAME_R_6)
  1101. if(NOT ${CURL_TEST})
  1102. if(${CURL_TEST}_REENTRANT)
  1103. set(NEED_REENTRANT 1)
  1104. endif()
  1105. endif()
  1106. endforeach()
  1107. if(NEED_REENTRANT)
  1108. foreach(CURL_TEST
  1109. HAVE_GETHOSTBYNAME_R_3
  1110. HAVE_GETHOSTBYNAME_R_5
  1111. HAVE_GETHOSTBYNAME_R_6)
  1112. set(${CURL_TEST} 0)
  1113. if(${CURL_TEST}_REENTRANT)
  1114. set(${CURL_TEST} 1)
  1115. endif()
  1116. endforeach()
  1117. endif()
  1118. # Check clock_gettime(CLOCK_MONOTONIC, x) support
  1119. curl_internal_test(HAVE_CLOCK_GETTIME_MONOTONIC)
  1120. # Check compiler support of __builtin_available()
  1121. curl_internal_test(HAVE_BUILTIN_AVAILABLE)
  1122. # Some other minor tests
  1123. if(NOT HAVE_IN_ADDR_T)
  1124. set(in_addr_t "unsigned long")
  1125. endif()
  1126. # Check for nonblocking
  1127. set(HAVE_DISABLED_NONBLOCKING 1)
  1128. if(HAVE_FIONBIO OR
  1129. HAVE_IOCTLSOCKET OR
  1130. HAVE_IOCTLSOCKET_CASE OR
  1131. HAVE_O_NONBLOCK)
  1132. set(HAVE_DISABLED_NONBLOCKING)
  1133. endif()
  1134. if(CMAKE_COMPILER_IS_GNUCC AND APPLE)
  1135. include(CheckCCompilerFlag)
  1136. check_c_compiler_flag(-Wno-long-double HAVE_C_FLAG_Wno_long_double)
  1137. if(HAVE_C_FLAG_Wno_long_double)
  1138. # The Mac version of GCC warns about use of long double. Disable it.
  1139. get_source_file_property(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS)
  1140. if(MPRINTF_COMPILE_FLAGS)
  1141. set(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double")
  1142. else()
  1143. set(MPRINTF_COMPILE_FLAGS "-Wno-long-double")
  1144. endif()
  1145. set_source_files_properties(mprintf.c PROPERTIES
  1146. COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS})
  1147. endif()
  1148. endif()
  1149. # TODO test which of these headers are required
  1150. if(WIN32)
  1151. set(CURL_PULL_WS2TCPIP_H ${HAVE_WS2TCPIP_H})
  1152. else()
  1153. set(CURL_PULL_SYS_TYPES_H ${HAVE_SYS_TYPES_H})
  1154. set(CURL_PULL_SYS_SOCKET_H ${HAVE_SYS_SOCKET_H})
  1155. set(CURL_PULL_SYS_POLL_H ${HAVE_SYS_POLL_H})
  1156. endif()
  1157. include(CMake/OtherTests.cmake)
  1158. add_definitions(-DHAVE_CONFIG_H)
  1159. # For Windows, all compilers used by CMake should support large files
  1160. if(WIN32)
  1161. set(USE_WIN32_LARGE_FILES ON)
  1162. # Use the manifest embedded in the Windows Resource
  1163. set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DCURL_EMBED_MANIFEST")
  1164. # Check if crypto functions in wincrypt.h are actually available
  1165. if(HAVE_WINCRYPT_H)
  1166. check_symbol_exists(CryptAcquireContext "windows.h;wincrypt.h" USE_WINCRYPT)
  1167. endif()
  1168. if(USE_WINCRYPT)
  1169. set(USE_WIN32_CRYPTO ON)
  1170. endif()
  1171. # Link required libraries for USE_WIN32_CRYPTO or USE_SCHANNEL
  1172. if(USE_WIN32_CRYPTO OR USE_SCHANNEL)
  1173. list(APPEND CURL_LIBS "advapi32" "crypt32")
  1174. endif()
  1175. if(NOT HAVE_MINGW_ORIGINAL)
  1176. list(APPEND CURL_LIBS "bcrypt")
  1177. else()
  1178. set(HAVE_FTRUNCATE OFF)
  1179. endif()
  1180. endif()
  1181. if(MSVC)
  1182. # Disable default manifest added by CMake
  1183. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
  1184. add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
  1185. if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
  1186. string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
  1187. else()
  1188. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
  1189. endif()
  1190. # Use multithreaded compilation on VS 2008+
  1191. if(MSVC_VERSION GREATER_EQUAL 1500)
  1192. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
  1193. endif()
  1194. endif()
  1195. if(CURL_WERROR)
  1196. if(MSVC_VERSION)
  1197. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
  1198. else()
  1199. # this assumes clang or gcc style options
  1200. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
  1201. endif()
  1202. endif()
  1203. if(CURL_LTO)
  1204. if(CMAKE_VERSION VERSION_LESS 3.9)
  1205. message(FATAL_ERROR "Requested LTO but your cmake version ${CMAKE_VERSION} is to old. You need at least 3.9")
  1206. endif()
  1207. cmake_policy(SET CMP0069 NEW)
  1208. include(CheckIPOSupported)
  1209. check_ipo_supported(RESULT CURL_HAS_LTO OUTPUT CURL_LTO_ERROR LANGUAGES C)
  1210. if(CURL_HAS_LTO)
  1211. message(STATUS "LTO supported and enabled")
  1212. else()
  1213. message(FATAL_ERROR "LTO was requested - but compiler doesn't support it\n${CURL_LTO_ERROR}")
  1214. endif()
  1215. endif()
  1216. # Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it).
  1217. function(transform_makefile_inc INPUT_FILE OUTPUT_FILE)
  1218. file(READ ${INPUT_FILE} MAKEFILE_INC_TEXT)
  1219. string(REPLACE "$(top_srcdir)" "\${CURL_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  1220. string(REPLACE "$(top_builddir)" "\${CURL_BINARY_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  1221. string(REGEX REPLACE "\\\\\n" "!π!α!" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  1222. string(REGEX REPLACE "([a-zA-Z_][a-zA-Z0-9_]*)[\t ]*=[\t ]*([^\n]*)" "SET(\\1 \\2)" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  1223. string(REPLACE "!π!α!" "\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  1224. string(REGEX REPLACE "\\$\\(([a-zA-Z_][a-zA-Z0-9_]*)\\)" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace $() with ${}
  1225. 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.
  1226. file(WRITE ${OUTPUT_FILE} ${MAKEFILE_INC_TEXT})
  1227. set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${INPUT_FILE}")
  1228. endfunction()
  1229. include(GNUInstallDirs)
  1230. set(CURL_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
  1231. set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
  1232. set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
  1233. set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
  1234. set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
  1235. if(USE_MANUAL)
  1236. add_subdirectory(docs)
  1237. endif()
  1238. add_subdirectory(lib)
  1239. if(BUILD_CURL_EXE)
  1240. add_subdirectory(src)
  1241. endif()
  1242. cmake_dependent_option(BUILD_TESTING "Build tests"
  1243. ON "PERL_FOUND;NOT CURL_DISABLE_TESTS"
  1244. OFF)
  1245. if(BUILD_TESTING)
  1246. add_subdirectory(tests)
  1247. endif()
  1248. # Helper to populate a list (_items) with a label when conditions (the remaining
  1249. # args) are satisfied
  1250. macro(_add_if label)
  1251. # needs to be a macro to allow this indirection
  1252. if(${ARGN})
  1253. set(_items ${_items} "${label}")
  1254. endif()
  1255. endmacro()
  1256. # NTLM support requires crypto function adaptions from various SSL libs
  1257. # TODO alternative SSL libs tests for SSP1, GNUTLS, NSS
  1258. if(NOT (CURL_DISABLE_CRYPTO_AUTH OR CURL_DISABLE_NTLM) AND
  1259. (USE_OPENSSL OR USE_MBEDTLS OR USE_DARWINSSL OR USE_WIN32_CRYPTO))
  1260. set(use_curl_ntlm_core ON)
  1261. endif()
  1262. # Clear list and try to detect available features
  1263. set(_items)
  1264. _add_if("SSL" SSL_ENABLED)
  1265. _add_if("IPv6" ENABLE_IPV6)
  1266. _add_if("unixsockets" USE_UNIX_SOCKETS)
  1267. _add_if("libz" HAVE_LIBZ)
  1268. _add_if("brotli" HAVE_BROTLI)
  1269. _add_if("zstd" HAVE_ZSTD)
  1270. _add_if("AsynchDNS" USE_ARES OR USE_THREADS_POSIX OR USE_THREADS_WIN32)
  1271. _add_if("IDN" HAVE_LIBIDN2 OR USE_WIN32_IDN)
  1272. _add_if("Largefile" (SIZEOF_CURL_OFF_T GREATER 4) AND
  1273. ((SIZEOF_OFF_T GREATER 4) OR USE_WIN32_LARGE_FILES))
  1274. # TODO SSP1 (Schannel) check is missing
  1275. _add_if("SSPI" USE_WINDOWS_SSPI)
  1276. _add_if("GSS-API" HAVE_GSSAPI)
  1277. _add_if("alt-svc" NOT CURL_DISABLE_ALTSVC)
  1278. _add_if("HSTS" NOT CURL_DISABLE_HSTS)
  1279. # TODO SSP1 missing for SPNEGO
  1280. _add_if("SPNEGO" NOT CURL_DISABLE_CRYPTO_AUTH AND
  1281. (HAVE_GSSAPI OR USE_WINDOWS_SSPI))
  1282. _add_if("Kerberos" NOT CURL_DISABLE_CRYPTO_AUTH AND
  1283. (HAVE_GSSAPI OR USE_WINDOWS_SSPI))
  1284. # NTLM support requires crypto function adaptions from various SSL libs
  1285. # TODO alternative SSL libs tests for SSP1, GNUTLS, NSS
  1286. _add_if("NTLM" NOT (CURL_DISABLE_CRYPTO_AUTH OR CURL_DISABLE_NTLM) AND
  1287. (use_curl_ntlm_core OR USE_WINDOWS_SSPI))
  1288. # TODO missing option (autoconf: --enable-ntlm-wb)
  1289. _add_if("NTLM_WB" NOT (CURL_DISABLE_CRYPTO_AUTH OR CURL_DISABLE_NTLM) AND
  1290. (use_curl_ntlm_core OR USE_WINDOWS_SSPI) AND
  1291. NOT CURL_DISABLE_HTTP AND NTLM_WB_ENABLED)
  1292. # TODO missing option (--enable-tls-srp), depends on GNUTLS_SRP/OPENSSL_SRP
  1293. _add_if("TLS-SRP" USE_TLS_SRP)
  1294. # TODO option --with-nghttp2 tests for nghttp2 lib and nghttp2/nghttp2.h header
  1295. _add_if("HTTP2" USE_NGHTTP2)
  1296. _add_if("HTTP3" USE_NGTCP2 OR USE_QUICHE)
  1297. _add_if("MultiSSL" CURL_WITH_MULTI_SSL)
  1298. # TODO wolfSSL only support this from v5.0.0 onwards
  1299. _add_if("HTTPS-proxy" SSL_ENABLED AND (USE_OPENSSL OR USE_GNUTLS OR USE_NSS
  1300. OR USE_SCHANNEL OR USE_RUSTLS OR USE_BEARSSL OR
  1301. USE_MBEDTLS OR USE_SECTRANSP))
  1302. _add_if("unicode" ENABLE_UNICODE)
  1303. _add_if("threadsafe" HAVE_ATOMIC OR (WIN32 AND
  1304. HAVE_WIN32_WINNT GREATER_EQUAL 0x600))
  1305. _add_if("PSL" USE_LIBPSL)
  1306. string(REPLACE ";" " " SUPPORT_FEATURES "${_items}")
  1307. message(STATUS "Enabled features: ${SUPPORT_FEATURES}")
  1308. # Clear list and try to detect available protocols
  1309. set(_items)
  1310. _add_if("HTTP" NOT CURL_DISABLE_HTTP)
  1311. _add_if("HTTPS" NOT CURL_DISABLE_HTTP AND SSL_ENABLED)
  1312. _add_if("FTP" NOT CURL_DISABLE_FTP)
  1313. _add_if("FTPS" NOT CURL_DISABLE_FTP AND SSL_ENABLED)
  1314. _add_if("FILE" NOT CURL_DISABLE_FILE)
  1315. _add_if("TELNET" NOT CURL_DISABLE_TELNET)
  1316. _add_if("LDAP" NOT CURL_DISABLE_LDAP)
  1317. # CURL_DISABLE_LDAP implies CURL_DISABLE_LDAPS
  1318. # TODO check HAVE_LDAP_SSL (in autoconf this is enabled with --enable-ldaps)
  1319. _add_if("LDAPS" NOT CURL_DISABLE_LDAPS AND
  1320. ((USE_OPENLDAP AND SSL_ENABLED) OR
  1321. (NOT USE_OPENLDAP AND HAVE_LDAP_SSL)))
  1322. _add_if("DICT" NOT CURL_DISABLE_DICT)
  1323. _add_if("TFTP" NOT CURL_DISABLE_TFTP)
  1324. _add_if("GOPHER" NOT CURL_DISABLE_GOPHER)
  1325. _add_if("GOPHERS" NOT CURL_DISABLE_GOPHER AND SSL_ENABLED)
  1326. _add_if("POP3" NOT CURL_DISABLE_POP3)
  1327. _add_if("POP3S" NOT CURL_DISABLE_POP3 AND SSL_ENABLED)
  1328. _add_if("IMAP" NOT CURL_DISABLE_IMAP)
  1329. _add_if("IMAPS" NOT CURL_DISABLE_IMAP AND SSL_ENABLED)
  1330. _add_if("SMB" NOT CURL_DISABLE_SMB AND
  1331. use_curl_ntlm_core AND (SIZEOF_CURL_OFF_T GREATER 4))
  1332. _add_if("SMBS" NOT CURL_DISABLE_SMB AND SSL_ENABLED AND
  1333. use_curl_ntlm_core AND (SIZEOF_CURL_OFF_T GREATER 4))
  1334. _add_if("SMTP" NOT CURL_DISABLE_SMTP)
  1335. _add_if("SMTPS" NOT CURL_DISABLE_SMTP AND SSL_ENABLED)
  1336. _add_if("SCP" USE_LIBSSH2 OR USE_LIBSSH)
  1337. _add_if("SFTP" USE_LIBSSH2 OR USE_LIBSSH)
  1338. _add_if("RTSP" NOT CURL_DISABLE_RTSP)
  1339. _add_if("RTMP" USE_LIBRTMP)
  1340. _add_if("MQTT" NOT CURL_DISABLE_MQTT)
  1341. _add_if("WS" USE_WEBSOCKETS)
  1342. _add_if("WSS" USE_WEBSOCKETS)
  1343. if(_items)
  1344. list(SORT _items)
  1345. endif()
  1346. string(REPLACE ";" " " SUPPORT_PROTOCOLS "${_items}")
  1347. message(STATUS "Enabled protocols: ${SUPPORT_PROTOCOLS}")
  1348. # Clear list and collect SSL backends
  1349. set(_items)
  1350. _add_if("Schannel" SSL_ENABLED AND USE_SCHANNEL)
  1351. _add_if("OpenSSL" SSL_ENABLED AND USE_OPENSSL)
  1352. _add_if("Secure Transport" SSL_ENABLED AND USE_SECTRANSP)
  1353. _add_if("mbedTLS" SSL_ENABLED AND USE_MBEDTLS)
  1354. _add_if("BearSSL" SSL_ENABLED AND USE_BEARSSL)
  1355. _add_if("NSS" SSL_ENABLED AND USE_NSS)
  1356. _add_if("wolfSSL" SSL_ENABLED AND USE_WOLFSSL)
  1357. if(_items)
  1358. list(SORT _items)
  1359. endif()
  1360. string(REPLACE ";" " " SSL_BACKENDS "${_items}")
  1361. message(STATUS "Enabled SSL backends: ${SSL_BACKENDS}")
  1362. # curl-config needs the following options to be set.
  1363. set(CC "${CMAKE_C_COMPILER}")
  1364. # TODO probably put a -D... options here?
  1365. set(CONFIGURE_OPTIONS "")
  1366. # TODO when to set "-DCURL_STATICLIB" for CPPFLAG_CURL_STATICLIB?
  1367. set(CPPFLAG_CURL_STATICLIB "")
  1368. set(CURLVERSION "${CURL_VERSION}")
  1369. set(exec_prefix "\${prefix}")
  1370. set(includedir "\${prefix}/include")
  1371. set(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
  1372. set(LIBCURL_LIBS "")
  1373. set(libdir "${CMAKE_INSTALL_PREFIX}/lib")
  1374. foreach(_lib ${CMAKE_C_IMPLICIT_LINK_LIBRARIES} ${CURL_LIBS})
  1375. if(TARGET "${_lib}")
  1376. set(_libname "${_lib}")
  1377. get_target_property(_imported "${_libname}" IMPORTED)
  1378. if(NOT _imported)
  1379. # Reading the LOCATION property on non-imported target will error out.
  1380. # Assume the user won't need this information in the .pc file.
  1381. continue()
  1382. endif()
  1383. get_target_property(_lib "${_libname}" LOCATION)
  1384. if(NOT _lib)
  1385. message(WARNING "Bad lib in library list: ${_libname}")
  1386. continue()
  1387. endif()
  1388. endif()
  1389. if(_lib MATCHES ".*/.*" OR _lib MATCHES "^-")
  1390. set(LIBCURL_LIBS "${LIBCURL_LIBS} ${_lib}")
  1391. else()
  1392. set(LIBCURL_LIBS "${LIBCURL_LIBS} -l${_lib}")
  1393. endif()
  1394. endforeach()
  1395. if(BUILD_SHARED_LIBS)
  1396. set(ENABLE_SHARED "yes")
  1397. set(ENABLE_STATIC "no")
  1398. set(LIBCURL_NO_SHARED "")
  1399. else()
  1400. set(ENABLE_SHARED "no")
  1401. set(ENABLE_STATIC "yes")
  1402. set(LIBCURL_NO_SHARED "${LIBCURL_LIBS}")
  1403. endif()
  1404. # "a" (Linux) or "lib" (Windows)
  1405. string(REPLACE "." "" libext "${CMAKE_STATIC_LIBRARY_SUFFIX}")
  1406. set(prefix "${CMAKE_INSTALL_PREFIX}")
  1407. # Set this to "yes" to append all libraries on which -lcurl is dependent
  1408. set(REQUIRE_LIB_DEPS "no")
  1409. # SUPPORT_FEATURES
  1410. # SUPPORT_PROTOCOLS
  1411. set(VERSIONNUM "${CURL_VERSION_NUM}")
  1412. # Finally generate a "curl-config" matching this config
  1413. # Use:
  1414. # * ENABLE_SHARED
  1415. # * ENABLE_STATIC
  1416. configure_file("${CURL_SOURCE_DIR}/curl-config.in"
  1417. "${CURL_BINARY_DIR}/curl-config" @ONLY)
  1418. install(FILES "${CURL_BINARY_DIR}/curl-config"
  1419. DESTINATION ${CMAKE_INSTALL_BINDIR}
  1420. PERMISSIONS
  1421. OWNER_READ OWNER_WRITE OWNER_EXECUTE
  1422. GROUP_READ GROUP_EXECUTE
  1423. WORLD_READ WORLD_EXECUTE)
  1424. # Finally generate a pkg-config file matching this config
  1425. configure_file("${CURL_SOURCE_DIR}/libcurl.pc.in"
  1426. "${CURL_BINARY_DIR}/libcurl.pc" @ONLY)
  1427. install(FILES "${CURL_BINARY_DIR}/libcurl.pc"
  1428. DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
  1429. # install headers
  1430. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/curl"
  1431. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
  1432. FILES_MATCHING PATTERN "*.h")
  1433. include(CMakePackageConfigHelpers)
  1434. write_basic_package_version_file(
  1435. "${version_config}"
  1436. VERSION ${CURL_VERSION}
  1437. COMPATIBILITY SameMajorVersion
  1438. )
  1439. file(READ "${version_config}" generated_version_config)
  1440. file(WRITE "${version_config}"
  1441. "if(NOT PACKAGE_FIND_VERSION_RANGE AND PACKAGE_FIND_VERSION_MAJOR STREQUAL \"7\")
  1442. # Version 8 satisfies version 7... requirements
  1443. set(PACKAGE_FIND_VERSION_MAJOR 8)
  1444. set(PACKAGE_FIND_VERSION_COUNT 1)
  1445. endif()
  1446. ${generated_version_config}"
  1447. )
  1448. # Use:
  1449. # * TARGETS_EXPORT_NAME
  1450. # * PROJECT_NAME
  1451. configure_package_config_file(CMake/curl-config.cmake.in
  1452. "${project_config}"
  1453. INSTALL_DESTINATION ${CURL_INSTALL_CMAKE_DIR}
  1454. )
  1455. if(CURL_ENABLE_EXPORT_TARGET)
  1456. install(
  1457. EXPORT "${TARGETS_EXPORT_NAME}"
  1458. NAMESPACE "${PROJECT_NAME}::"
  1459. DESTINATION ${CURL_INSTALL_CMAKE_DIR}
  1460. )
  1461. endif()
  1462. install(
  1463. FILES ${version_config} ${project_config}
  1464. DESTINATION ${CURL_INSTALL_CMAKE_DIR}
  1465. )
  1466. # Workaround for MSVS10 to avoid the Dialog Hell
  1467. # FIXME: This could be removed with future version of CMake.
  1468. if(MSVC_VERSION EQUAL 1600)
  1469. set(CURL_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/CURL.sln")
  1470. if(EXISTS "${CURL_SLN_FILENAME}")
  1471. file(APPEND "${CURL_SLN_FILENAME}" "\n# This should be regenerated!\n")
  1472. endif()
  1473. endif()
  1474. if(NOT TARGET curl_uninstall)
  1475. configure_file(
  1476. ${CMAKE_CURRENT_SOURCE_DIR}/CMake/cmake_uninstall.cmake.in
  1477. ${CMAKE_CURRENT_BINARY_DIR}/CMake/cmake_uninstall.cmake
  1478. IMMEDIATE @ONLY)
  1479. add_custom_target(curl_uninstall
  1480. COMMAND ${CMAKE_COMMAND} -P
  1481. ${CMAKE_CURRENT_BINARY_DIR}/CMake/cmake_uninstall.cmake)
  1482. endif()