CMakeLists.txt 59 KB

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