CMakeLists.txt 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, 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)
  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. # Yellowtab Zeta needs different libraries than BeOS 5.
  302. if(BEOS)
  303. set(NOT_NEED_LIBNSL 1)
  304. check_library_exists_concat("bind" gethostbyname HAVE_LIBBIND)
  305. check_library_exists_concat("bnetapi" closesocket HAVE_LIBBNETAPI)
  306. endif()
  307. if(NOT NOT_NEED_LIBNSL)
  308. check_library_exists_concat("nsl" gethostbyname HAVE_LIBNSL)
  309. endif()
  310. check_function_exists(gethostname HAVE_GETHOSTNAME)
  311. if(WIN32)
  312. check_library_exists_concat("ws2_32" getch HAVE_LIBWS2_32)
  313. check_library_exists_concat("winmm" getch HAVE_LIBWINMM)
  314. endif()
  315. # check SSL libraries
  316. # TODO support GnuTLS
  317. option(CURL_ENABLE_SSL "Enable SSL support" ON)
  318. if(CMAKE_USE_WINSSL)
  319. message(FATAL_ERROR "The cmake option CMAKE_USE_WINSSL was renamed to CMAKE_USE_SCHANNEL.")
  320. endif()
  321. if(APPLE)
  322. cmake_dependent_option(CMAKE_USE_SECTRANSP "enable Apple OS native SSL/TLS" OFF CURL_ENABLE_SSL OFF)
  323. endif()
  324. if(WIN32)
  325. cmake_dependent_option(CMAKE_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. CMAKE_USE_SCHANNEL OFF)
  328. endif()
  329. cmake_dependent_option(CMAKE_USE_MBEDTLS "Enable mbedTLS for SSL/TLS" OFF CURL_ENABLE_SSL OFF)
  330. cmake_dependent_option(CMAKE_USE_BEARSSL "Enable BearSSL for SSL/TLS" OFF CURL_ENABLE_SSL OFF)
  331. cmake_dependent_option(CMAKE_USE_NSS "Enable NSS for SSL/TLS" OFF CURL_ENABLE_SSL OFF)
  332. cmake_dependent_option(CMAKE_USE_WOLFSSL "enable wolfSSL for SSL/TLS" OFF CURL_ENABLE_SSL OFF)
  333. set(openssl_default ON)
  334. if(WIN32 OR CMAKE_USE_SECTRANSP OR CMAKE_USE_SCHANNEL OR CMAKE_USE_MBEDTLS OR CMAKE_USE_NSS OR CMAKE_USE_WOLFSSL)
  335. set(openssl_default OFF)
  336. endif()
  337. cmake_dependent_option(CMAKE_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. CMAKE_USE_SCHANNEL
  341. CMAKE_USE_SECTRANSP
  342. CMAKE_USE_OPENSSL
  343. CMAKE_USE_MBEDTLS
  344. CMAKE_USE_BEARSSL
  345. CMAKE_USE_NSS
  346. CMAKE_USE_WOLFSSL
  347. )
  348. if(enabled_ssl_options_count GREATER "1")
  349. set(CURL_WITH_MULTI_SSL ON)
  350. endif()
  351. if(CMAKE_USE_SCHANNEL)
  352. set(SSL_ENABLED ON)
  353. set(USE_SCHANNEL ON) # Windows native SSL/TLS support
  354. set(USE_WINDOWS_SSPI ON) # CMAKE_USE_SCHANNEL implies CURL_WINDOWS_SSPI
  355. endif()
  356. if(CURL_WINDOWS_SSPI)
  357. set(USE_WINDOWS_SSPI ON)
  358. set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DSECURITY_WIN32")
  359. endif()
  360. if(CMAKE_USE_DARWINSSL)
  361. message(FATAL_ERROR "The cmake option CMAKE_USE_DARWINSSL was renamed to CMAKE_USE_SECTRANSP.")
  362. endif()
  363. if(CMAKE_USE_SECTRANSP)
  364. set(use_core_foundation ON)
  365. find_library(SECURITY_FRAMEWORK "Security")
  366. if(NOT SECURITY_FRAMEWORK)
  367. message(FATAL_ERROR "Security framework not found")
  368. endif()
  369. set(SSL_ENABLED ON)
  370. set(USE_SECTRANSP ON)
  371. list(APPEND CURL_LIBS "-framework Security")
  372. endif()
  373. if(use_core_foundation)
  374. find_library(COREFOUNDATION_FRAMEWORK "CoreFoundation")
  375. if(NOT COREFOUNDATION_FRAMEWORK)
  376. message(FATAL_ERROR "CoreFoundation framework not found")
  377. endif()
  378. list(APPEND CURL_LIBS "-framework CoreFoundation")
  379. endif()
  380. if(CMAKE_USE_OPENSSL)
  381. find_package(OpenSSL REQUIRED)
  382. set(SSL_ENABLED ON)
  383. set(USE_OPENSSL ON)
  384. # Depend on OpenSSL via imported targets if supported by the running
  385. # version of CMake. This allows our dependents to get our dependencies
  386. # transitively.
  387. if(NOT CMAKE_VERSION VERSION_LESS 3.4)
  388. list(APPEND CURL_LIBS OpenSSL::SSL OpenSSL::Crypto)
  389. else()
  390. list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})
  391. include_directories(${OPENSSL_INCLUDE_DIR})
  392. endif()
  393. set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
  394. check_include_file("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H)
  395. check_include_file("openssl/err.h" HAVE_OPENSSL_ERR_H)
  396. check_include_file("openssl/pem.h" HAVE_OPENSSL_PEM_H)
  397. check_include_file("openssl/rsa.h" HAVE_OPENSSL_RSA_H)
  398. check_include_file("openssl/ssl.h" HAVE_OPENSSL_SSL_H)
  399. check_include_file("openssl/x509.h" HAVE_OPENSSL_X509_H)
  400. check_include_file("openssl/rand.h" HAVE_OPENSSL_RAND_H)
  401. check_symbol_exists(RAND_status "${CURL_INCLUDES}" HAVE_RAND_STATUS)
  402. check_symbol_exists(RAND_screen "${CURL_INCLUDES}" HAVE_RAND_SCREEN)
  403. check_symbol_exists(RAND_egd "${CURL_INCLUDES}" HAVE_RAND_EGD)
  404. add_definitions(-DOPENSSL_SUPPRESS_DEPRECATED)
  405. endif()
  406. if(CMAKE_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(CMAKE_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(CMAKE_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(CMAKE_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. cmake_push_check_state()
  434. set(CMAKE_REQUIRED_INCLUDES ${NSS_INCLUDE_DIRS})
  435. set(CMAKE_REQUIRED_LIBRARIES ${NSS_LIBRARIES})
  436. check_symbol_exists(PK11_CreateManagedGenericObject "pk11pub.h" HAVE_PK11_CREATEMANAGEDGENERICOBJECT)
  437. cmake_pop_check_state()
  438. endif()
  439. option(USE_NGHTTP2 "Use Nghttp2 library" OFF)
  440. if(USE_NGHTTP2)
  441. find_package(NGHTTP2 REQUIRED)
  442. include_directories(${NGHTTP2_INCLUDE_DIRS})
  443. list(APPEND CURL_LIBS ${NGHTTP2_LIBRARIES})
  444. endif()
  445. function(CheckQuicSupportInOpenSSL)
  446. # Be sure that the OpenSSL library actually supports QUIC.
  447. cmake_push_check_state()
  448. set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}")
  449. set(CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES}")
  450. check_symbol_exists(SSL_CTX_set_quic_method "openssl/ssl.h" HAVE_SSL_CTX_SET_QUIC_METHOD)
  451. if(NOT HAVE_SSL_CTX_SET_QUIC_METHOD)
  452. message(FATAL_ERROR "QUIC support is missing in OpenSSL/boringssl. Try setting -DOPENSSL_ROOT_DIR")
  453. endif()
  454. cmake_pop_check_state()
  455. endfunction()
  456. option(USE_NGTCP2 "Use ngtcp2 and nghttp3 libraries for HTTP/3 support" OFF)
  457. if(USE_NGTCP2)
  458. if(USE_OPENSSL)
  459. find_package(NGTCP2 REQUIRED OpenSSL)
  460. CheckQuicSupportInOpenSSL()
  461. elseif(USE_GNUTLS)
  462. # TODO add GnuTLS support as vtls library.
  463. find_package(NGTCP2 REQUIRED GnuTLS)
  464. else()
  465. message(FATAL_ERROR "ngtcp2 requires OpenSSL or GnuTLS")
  466. endif()
  467. set(USE_NGTCP2 ON)
  468. include_directories(${NGTCP2_INCLUDE_DIRS})
  469. list(APPEND CURL_LIBS ${NGTCP2_LIBRARIES})
  470. find_package(NGHTTP3 REQUIRED)
  471. set(USE_NGHTTP3 ON)
  472. include_directories(${NGHTTP3_INCLUDE_DIRS})
  473. list(APPEND CURL_LIBS ${NGHTTP3_LIBRARIES})
  474. endif()
  475. option(USE_QUICHE "Use quiche library for HTTP/3 support" OFF)
  476. if(USE_QUICHE)
  477. if(USE_NGTCP2)
  478. message(FATAL_ERROR "Only one HTTP/3 backend can be selected!")
  479. endif()
  480. find_package(QUICHE REQUIRED)
  481. CheckQuicSupportInOpenSSL()
  482. set(USE_QUICHE ON)
  483. include_directories(${QUICHE_INCLUDE_DIRS})
  484. list(APPEND CURL_LIBS ${QUICHE_LIBRARIES})
  485. cmake_push_check_state()
  486. set(CMAKE_REQUIRED_INCLUDES "${QUICHE_INCLUDE_DIRS}")
  487. set(CMAKE_REQUIRED_LIBRARIES "${QUICHE_LIBRARIES}")
  488. check_symbol_exists(quiche_conn_set_qlog_fd "quiche.h" HAVE_QUICHE_CONN_SET_QLOG_FD)
  489. cmake_pop_check_state()
  490. endif()
  491. if(NOT CURL_DISABLE_LDAP)
  492. if(WIN32)
  493. option(USE_WIN32_LDAP "Use Windows LDAP implementation" ON)
  494. if(USE_WIN32_LDAP)
  495. check_library_exists_concat("wldap32" cldap_open HAVE_WLDAP32)
  496. if(NOT HAVE_WLDAP32)
  497. set(USE_WIN32_LDAP OFF)
  498. endif()
  499. endif()
  500. endif()
  501. option(CMAKE_USE_OPENLDAP "Use OpenLDAP code." OFF)
  502. mark_as_advanced(CMAKE_USE_OPENLDAP)
  503. set(CMAKE_LDAP_LIB "ldap" CACHE STRING "Name or full path to ldap library")
  504. set(CMAKE_LBER_LIB "lber" CACHE STRING "Name or full path to lber library")
  505. if(CMAKE_USE_OPENLDAP AND USE_WIN32_LDAP)
  506. message(FATAL_ERROR "Cannot use USE_WIN32_LDAP and CMAKE_USE_OPENLDAP at the same time")
  507. endif()
  508. # Now that we know, we're not using windows LDAP...
  509. if(USE_WIN32_LDAP)
  510. check_include_file_concat("winldap.h" HAVE_WINLDAP_H)
  511. check_include_file_concat("winber.h" HAVE_WINBER_H)
  512. else()
  513. # Check for LDAP
  514. set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES})
  515. check_library_exists_concat(${CMAKE_LDAP_LIB} ldap_init HAVE_LIBLDAP)
  516. check_library_exists_concat(${CMAKE_LBER_LIB} ber_init HAVE_LIBLBER)
  517. set(CMAKE_REQUIRED_INCLUDES_BAK ${CMAKE_REQUIRED_INCLUDES})
  518. set(CMAKE_LDAP_INCLUDE_DIR "" CACHE STRING "Path to LDAP include directory")
  519. if(CMAKE_LDAP_INCLUDE_DIR)
  520. list(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_LDAP_INCLUDE_DIR})
  521. endif()
  522. check_include_file_concat("ldap.h" HAVE_LDAP_H)
  523. check_include_file_concat("lber.h" HAVE_LBER_H)
  524. if(NOT HAVE_LDAP_H)
  525. message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON")
  526. set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
  527. set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) #LDAP includes won't be used
  528. elseif(NOT HAVE_LIBLDAP)
  529. message(STATUS "LDAP library '${CMAKE_LDAP_LIB}' not found CURL_DISABLE_LDAP set ON")
  530. set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
  531. set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) #LDAP includes won't be used
  532. else()
  533. if(CMAKE_USE_OPENLDAP)
  534. set(USE_OPENLDAP ON)
  535. endif()
  536. if(CMAKE_LDAP_INCLUDE_DIR)
  537. include_directories(${CMAKE_LDAP_INCLUDE_DIR})
  538. endif()
  539. set(NEED_LBER_H ON)
  540. set(_HEADER_LIST)
  541. if(HAVE_WINDOWS_H)
  542. list(APPEND _HEADER_LIST "windows.h")
  543. endif()
  544. if(HAVE_SYS_TYPES_H)
  545. list(APPEND _HEADER_LIST "sys/types.h")
  546. endif()
  547. list(APPEND _HEADER_LIST "ldap.h")
  548. set(_SRC_STRING "")
  549. foreach(_HEADER ${_HEADER_LIST})
  550. set(_INCLUDE_STRING "${_INCLUDE_STRING}#include <${_HEADER}>\n")
  551. endforeach()
  552. set(_SRC_STRING
  553. "
  554. ${_INCLUDE_STRING}
  555. int main(int argc, char ** argv)
  556. {
  557. BerValue *bvp = NULL;
  558. BerElement *bep = ber_init(bvp);
  559. ber_free(bep, 1);
  560. return 0;
  561. }"
  562. )
  563. set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DLDAP_DEPRECATED=1")
  564. list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB})
  565. if(HAVE_LIBLBER)
  566. list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LBER_LIB})
  567. endif()
  568. check_c_source_compiles("${_SRC_STRING}" NOT_NEED_LBER_H)
  569. unset(CMAKE_REQUIRED_LIBRARIES)
  570. if(NOT_NEED_LBER_H)
  571. set(NEED_LBER_H OFF)
  572. else()
  573. set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -DNEED_LBER_H")
  574. endif()
  575. endif()
  576. endif()
  577. endif()
  578. # No ldap, no ldaps.
  579. if(CURL_DISABLE_LDAP)
  580. if(NOT CURL_DISABLE_LDAPS)
  581. message(STATUS "LDAP needs to be enabled to support LDAPS")
  582. set(CURL_DISABLE_LDAPS ON CACHE BOOL "" FORCE)
  583. endif()
  584. endif()
  585. if(NOT CURL_DISABLE_LDAPS)
  586. check_include_file_concat("ldap_ssl.h" HAVE_LDAP_SSL_H)
  587. check_include_file_concat("ldapssl.h" HAVE_LDAPSSL_H)
  588. endif()
  589. # Check for idn
  590. option(USE_LIBIDN2 "Use libidn2 for IDN support" ON)
  591. set(HAVE_LIBIDN2 OFF)
  592. if(USE_LIBIDN2)
  593. check_library_exists_concat("idn2" idn2_lookup_ul HAVE_LIBIDN2)
  594. endif()
  595. if(WIN32)
  596. option(USE_WIN32_IDN "Use WinIDN for IDN support" OFF)
  597. if(USE_WIN32_IDN)
  598. list(APPEND CURL_LIBS "Normaliz")
  599. set(WANT_IDN_PROTOTYPES ON)
  600. endif()
  601. endif()
  602. # Check for symbol dlopen (same as HAVE_LIBDL)
  603. check_library_exists("${CURL_LIBS}" dlopen "" HAVE_DLOPEN)
  604. set(HAVE_LIBZ OFF)
  605. set(HAVE_ZLIB_H OFF)
  606. set(USE_ZLIB OFF)
  607. optional_dependency(ZLIB)
  608. if(ZLIB_FOUND)
  609. set(HAVE_ZLIB_H ON)
  610. set(HAVE_LIBZ ON)
  611. set(USE_ZLIB ON)
  612. # Depend on ZLIB via imported targets if supported by the running
  613. # version of CMake. This allows our dependents to get our dependencies
  614. # transitively.
  615. if(NOT CMAKE_VERSION VERSION_LESS 3.4)
  616. list(APPEND CURL_LIBS ZLIB::ZLIB)
  617. else()
  618. list(APPEND CURL_LIBS ${ZLIB_LIBRARIES})
  619. include_directories(${ZLIB_INCLUDE_DIRS})
  620. endif()
  621. list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
  622. endif()
  623. option(CURL_BROTLI "Set to ON to enable building curl with brotli support." OFF)
  624. set(HAVE_BROTLI OFF)
  625. if(CURL_BROTLI)
  626. find_package(Brotli QUIET)
  627. if(BROTLI_FOUND)
  628. set(HAVE_BROTLI ON)
  629. list(APPEND CURL_LIBS ${BROTLI_LIBRARIES})
  630. include_directories(${BROTLI_INCLUDE_DIRS})
  631. list(APPEND CMAKE_REQUIRED_INCLUDES ${BROTLI_INCLUDE_DIRS})
  632. endif()
  633. endif()
  634. option(CURL_ZSTD "Set to ON to enable building curl with zstd support." OFF)
  635. set(HAVE_ZSTD OFF)
  636. if(CURL_ZSTD)
  637. find_package(Zstd REQUIRED)
  638. cmake_push_check_state()
  639. set(CMAKE_REQUIRED_INCLUDES ${Zstd_INCLUDE_DIRS})
  640. set(CMAKE_REQUIRED_LIBRARIES ${Zstd_LIBRARIES})
  641. check_symbol_exists(ZSTD_createDStream "zstd.h" HAVE_ZSTD_CREATEDSTREAM)
  642. cmake_pop_check_state()
  643. if(Zstd_FOUND AND HAVE_ZSTD_CREATEDSTREAM)
  644. set(HAVE_ZSTD ON)
  645. list(APPEND CURL_LIBS ${Zstd_LIBRARIES})
  646. include_directories(${Zstd_INCLUDE_DIRS})
  647. endif()
  648. endif()
  649. #libSSH2
  650. option(CMAKE_USE_LIBSSH2 "Use libSSH2" ON)
  651. mark_as_advanced(CMAKE_USE_LIBSSH2)
  652. set(USE_LIBSSH2 OFF)
  653. set(HAVE_LIBSSH2 OFF)
  654. set(HAVE_LIBSSH2_H OFF)
  655. if(CMAKE_USE_LIBSSH2)
  656. find_package(LibSSH2)
  657. if(LIBSSH2_FOUND)
  658. list(APPEND CURL_LIBS ${LIBSSH2_LIBRARY})
  659. set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH2_LIBRARY})
  660. list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIR}")
  661. include_directories("${LIBSSH2_INCLUDE_DIR}")
  662. set(HAVE_LIBSSH2 ON)
  663. set(USE_LIBSSH2 ON)
  664. # find_package has already found the headers
  665. set(HAVE_LIBSSH2_H ON)
  666. set(CURL_INCLUDES ${CURL_INCLUDES} "${LIBSSH2_INCLUDE_DIR}/libssh2.h")
  667. set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -DHAVE_LIBSSH2_H")
  668. unset(CMAKE_REQUIRED_LIBRARIES)
  669. endif()
  670. endif()
  671. # libssh
  672. option(CMAKE_USE_LIBSSH "Use libSSH" OFF)
  673. mark_as_advanced(CMAKE_USE_LIBSSH)
  674. if(NOT HAVE_LIBSSH2 AND CMAKE_USE_LIBSSH)
  675. find_package(libssh CONFIG)
  676. if(libssh_FOUND)
  677. message(STATUS "Found libssh ${libssh_VERSION}")
  678. # Use imported target for include and library paths.
  679. list(APPEND CURL_LIBS ssh)
  680. set(USE_LIBSSH ON)
  681. set(HAVE_LIBSSH_LIBSSH_H 1)
  682. endif()
  683. endif()
  684. option(CMAKE_USE_GSSAPI "Use GSSAPI implementation (right now only Heimdal is supported with CMake build)" OFF)
  685. mark_as_advanced(CMAKE_USE_GSSAPI)
  686. if(CMAKE_USE_GSSAPI)
  687. find_package(GSS)
  688. set(HAVE_GSSAPI ${GSS_FOUND})
  689. if(GSS_FOUND)
  690. message(STATUS "Found ${GSS_FLAVOUR} GSSAPI version: \"${GSS_VERSION}\"")
  691. list(APPEND CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIR})
  692. check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H)
  693. check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H)
  694. check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H)
  695. if(GSS_FLAVOUR STREQUAL "Heimdal")
  696. set(HAVE_GSSHEIMDAL ON)
  697. else() # MIT
  698. set(HAVE_GSSMIT ON)
  699. set(_INCLUDE_LIST "")
  700. if(HAVE_GSSAPI_GSSAPI_H)
  701. list(APPEND _INCLUDE_LIST "gssapi/gssapi.h")
  702. endif()
  703. if(HAVE_GSSAPI_GSSAPI_GENERIC_H)
  704. list(APPEND _INCLUDE_LIST "gssapi/gssapi_generic.h")
  705. endif()
  706. if(HAVE_GSSAPI_GSSAPI_KRB5_H)
  707. list(APPEND _INCLUDE_LIST "gssapi/gssapi_krb5.h")
  708. endif()
  709. string(REPLACE ";" " " _COMPILER_FLAGS_STR "${GSS_COMPILER_FLAGS}")
  710. string(REPLACE ";" " " _LINKER_FLAGS_STR "${GSS_LINKER_FLAGS}")
  711. foreach(_dir ${GSS_LINK_DIRECTORIES})
  712. set(_LINKER_FLAGS_STR "${_LINKER_FLAGS_STR} -L\"${_dir}\"")
  713. endforeach()
  714. set(CMAKE_REQUIRED_FLAGS "${_COMPILER_FLAGS_STR} ${_LINKER_FLAGS_STR}")
  715. set(CMAKE_REQUIRED_LIBRARIES ${GSS_LIBRARIES})
  716. check_symbol_exists("GSS_C_NT_HOSTBASED_SERVICE" ${_INCLUDE_LIST} HAVE_GSS_C_NT_HOSTBASED_SERVICE)
  717. if(NOT HAVE_GSS_C_NT_HOSTBASED_SERVICE)
  718. set(HAVE_OLD_GSSMIT ON)
  719. endif()
  720. unset(CMAKE_REQUIRED_LIBRARIES)
  721. endif()
  722. include_directories(${GSS_INCLUDE_DIR})
  723. link_directories(${GSS_LINK_DIRECTORIES})
  724. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSS_COMPILER_FLAGS}")
  725. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GSS_LINKER_FLAGS}")
  726. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GSS_LINKER_FLAGS}")
  727. set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${GSS_LINKER_FLAGS}")
  728. list(APPEND CURL_LIBS ${GSS_LIBRARIES})
  729. else()
  730. message(WARNING "GSSAPI support has been requested but no supporting libraries found. Skipping.")
  731. endif()
  732. endif()
  733. option(ENABLE_UNIX_SOCKETS "Define if you want Unix domain sockets support" ON)
  734. if(ENABLE_UNIX_SOCKETS)
  735. include(CheckStructHasMember)
  736. if(WIN32)
  737. set(USE_UNIX_SOCKETS ON)
  738. else()
  739. check_struct_has_member("struct sockaddr_un" sun_path "sys/un.h" USE_UNIX_SOCKETS)
  740. endif()
  741. else()
  742. unset(USE_UNIX_SOCKETS CACHE)
  743. endif()
  744. #
  745. # CA handling
  746. #
  747. set(CURL_CA_BUNDLE "auto" CACHE STRING
  748. "Path to the CA bundle. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
  749. set(CURL_CA_FALLBACK OFF CACHE BOOL
  750. "Set ON to use built-in CA store of TLS backend. Defaults to OFF")
  751. set(CURL_CA_PATH "auto" CACHE STRING
  752. "Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
  753. if("${CURL_CA_BUNDLE}" STREQUAL "")
  754. message(FATAL_ERROR "Invalid value of CURL_CA_BUNDLE. Use 'none', 'auto' or file path.")
  755. elseif("${CURL_CA_BUNDLE}" STREQUAL "none")
  756. unset(CURL_CA_BUNDLE CACHE)
  757. elseif("${CURL_CA_BUNDLE}" STREQUAL "auto")
  758. unset(CURL_CA_BUNDLE CACHE)
  759. set(CURL_CA_BUNDLE_AUTODETECT TRUE)
  760. else()
  761. set(CURL_CA_BUNDLE_SET TRUE)
  762. endif()
  763. if("${CURL_CA_PATH}" STREQUAL "")
  764. message(FATAL_ERROR "Invalid value of CURL_CA_PATH. Use 'none', 'auto' or directory path.")
  765. elseif("${CURL_CA_PATH}" STREQUAL "none")
  766. unset(CURL_CA_PATH CACHE)
  767. elseif("${CURL_CA_PATH}" STREQUAL "auto")
  768. unset(CURL_CA_PATH CACHE)
  769. if(NOT USE_NSS)
  770. set(CURL_CA_PATH_AUTODETECT TRUE)
  771. endif()
  772. else()
  773. set(CURL_CA_PATH_SET TRUE)
  774. endif()
  775. if(CURL_CA_BUNDLE_SET AND CURL_CA_PATH_AUTODETECT)
  776. # Skip autodetection of unset CA path because CA bundle is set explicitly
  777. elseif(CURL_CA_PATH_SET AND CURL_CA_BUNDLE_AUTODETECT)
  778. # Skip autodetection of unset CA bundle because CA path is set explicitly
  779. elseif(CURL_CA_PATH_AUTODETECT OR CURL_CA_BUNDLE_AUTODETECT)
  780. # first try autodetecting a CA bundle, then a CA path
  781. if(CURL_CA_BUNDLE_AUTODETECT)
  782. set(SEARCH_CA_BUNDLE_PATHS
  783. /etc/ssl/certs/ca-certificates.crt
  784. /etc/pki/tls/certs/ca-bundle.crt
  785. /usr/share/ssl/certs/ca-bundle.crt
  786. /usr/local/share/certs/ca-root-nss.crt
  787. /etc/ssl/cert.pem)
  788. foreach(SEARCH_CA_BUNDLE_PATH ${SEARCH_CA_BUNDLE_PATHS})
  789. if(EXISTS "${SEARCH_CA_BUNDLE_PATH}")
  790. message(STATUS "Found CA bundle: ${SEARCH_CA_BUNDLE_PATH}")
  791. set(CURL_CA_BUNDLE "${SEARCH_CA_BUNDLE_PATH}" CACHE STRING
  792. "Path to the CA bundle. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
  793. set(CURL_CA_BUNDLE_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
  794. break()
  795. endif()
  796. endforeach()
  797. endif()
  798. if(CURL_CA_PATH_AUTODETECT AND (NOT CURL_CA_PATH_SET))
  799. if(EXISTS "/etc/ssl/certs")
  800. set(CURL_CA_PATH "/etc/ssl/certs" CACHE STRING
  801. "Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
  802. set(CURL_CA_PATH_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
  803. endif()
  804. endif()
  805. endif()
  806. if(CURL_CA_PATH_SET AND NOT USE_OPENSSL AND NOT USE_MBEDTLS)
  807. message(STATUS
  808. "CA path only supported by OpenSSL, GnuTLS or mbed TLS. "
  809. "Set CURL_CA_PATH=none or enable one of those TLS backends.")
  810. endif()
  811. # Check for header files
  812. if(NOT UNIX)
  813. check_include_file_concat("windows.h" HAVE_WINDOWS_H)
  814. check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H)
  815. check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H)
  816. check_include_file_concat("wincrypt.h" HAVE_WINCRYPT_H)
  817. endif()
  818. check_include_file_concat("stdio.h" HAVE_STDIO_H)
  819. check_include_file_concat("inttypes.h" HAVE_INTTYPES_H)
  820. check_include_file_concat("sys/filio.h" HAVE_SYS_FILIO_H)
  821. check_include_file_concat("sys/ioctl.h" HAVE_SYS_IOCTL_H)
  822. check_include_file_concat("sys/param.h" HAVE_SYS_PARAM_H)
  823. check_include_file_concat("sys/poll.h" HAVE_SYS_POLL_H)
  824. check_include_file_concat("sys/resource.h" HAVE_SYS_RESOURCE_H)
  825. check_include_file_concat("sys/select.h" HAVE_SYS_SELECT_H)
  826. check_include_file_concat("sys/socket.h" HAVE_SYS_SOCKET_H)
  827. check_include_file_concat("sys/sockio.h" HAVE_SYS_SOCKIO_H)
  828. check_include_file_concat("sys/stat.h" HAVE_SYS_STAT_H)
  829. check_include_file_concat("sys/time.h" HAVE_SYS_TIME_H)
  830. check_include_file_concat("sys/types.h" HAVE_SYS_TYPES_H)
  831. check_include_file_concat("sys/uio.h" HAVE_SYS_UIO_H)
  832. check_include_file_concat("sys/un.h" HAVE_SYS_UN_H)
  833. check_include_file_concat("sys/utime.h" HAVE_SYS_UTIME_H)
  834. check_include_file_concat("sys/xattr.h" HAVE_SYS_XATTR_H)
  835. check_include_file_concat("alloca.h" HAVE_ALLOCA_H)
  836. check_include_file_concat("arpa/inet.h" HAVE_ARPA_INET_H)
  837. check_include_file_concat("arpa/tftp.h" HAVE_ARPA_TFTP_H)
  838. check_include_file_concat("assert.h" HAVE_ASSERT_H)
  839. check_include_file_concat("errno.h" HAVE_ERRNO_H)
  840. check_include_file_concat("fcntl.h" HAVE_FCNTL_H)
  841. check_include_file_concat("idn2.h" HAVE_IDN2_H)
  842. check_include_file_concat("ifaddrs.h" HAVE_IFADDRS_H)
  843. check_include_file_concat("io.h" HAVE_IO_H)
  844. check_include_file_concat("krb.h" HAVE_KRB_H)
  845. check_include_file_concat("libgen.h" HAVE_LIBGEN_H)
  846. check_include_file_concat("locale.h" HAVE_LOCALE_H)
  847. check_include_file_concat("net/if.h" HAVE_NET_IF_H)
  848. check_include_file_concat("netdb.h" HAVE_NETDB_H)
  849. check_include_file_concat("netinet/in.h" HAVE_NETINET_IN_H)
  850. check_include_file_concat("netinet/tcp.h" HAVE_NETINET_TCP_H)
  851. check_include_file("linux/tcp.h" HAVE_LINUX_TCP_H)
  852. check_include_file_concat("pem.h" HAVE_PEM_H)
  853. check_include_file_concat("poll.h" HAVE_POLL_H)
  854. check_include_file_concat("pwd.h" HAVE_PWD_H)
  855. check_include_file_concat("setjmp.h" HAVE_SETJMP_H)
  856. check_include_file_concat("signal.h" HAVE_SIGNAL_H)
  857. check_include_file_concat("ssl.h" HAVE_SSL_H)
  858. check_include_file_concat("stdbool.h" HAVE_STDBOOL_H)
  859. check_include_file_concat("stdint.h" HAVE_STDINT_H)
  860. check_include_file_concat("stdio.h" HAVE_STDIO_H)
  861. check_include_file_concat("stdlib.h" HAVE_STDLIB_H)
  862. check_include_file_concat("string.h" HAVE_STRING_H)
  863. check_include_file_concat("strings.h" HAVE_STRINGS_H)
  864. check_include_file_concat("stropts.h" HAVE_STROPTS_H)
  865. check_include_file_concat("termio.h" HAVE_TERMIO_H)
  866. check_include_file_concat("termios.h" HAVE_TERMIOS_H)
  867. check_include_file_concat("time.h" HAVE_TIME_H)
  868. check_include_file_concat("unistd.h" HAVE_UNISTD_H)
  869. check_include_file_concat("utime.h" HAVE_UTIME_H)
  870. check_include_file_concat("x509.h" HAVE_X509_H)
  871. check_include_file_concat("process.h" HAVE_PROCESS_H)
  872. check_include_file_concat("stddef.h" HAVE_STDDEF_H)
  873. check_include_file_concat("dlfcn.h" HAVE_DLFCN_H)
  874. check_include_file_concat("malloc.h" HAVE_MALLOC_H)
  875. check_include_file_concat("memory.h" HAVE_MEMORY_H)
  876. check_include_file_concat("netinet/if_ether.h" HAVE_NETINET_IF_ETHER_H)
  877. check_include_file_concat("stdint.h" HAVE_STDINT_H)
  878. check_include_file_concat("sockio.h" HAVE_SOCKIO_H)
  879. check_include_file_concat("sys/utsname.h" HAVE_SYS_UTSNAME_H)
  880. check_type_size(size_t SIZEOF_SIZE_T)
  881. check_type_size(ssize_t SIZEOF_SSIZE_T)
  882. check_type_size("long long" SIZEOF_LONG_LONG)
  883. check_type_size("long" SIZEOF_LONG)
  884. check_type_size("short" SIZEOF_SHORT)
  885. check_type_size("int" SIZEOF_INT)
  886. check_type_size("__int64" SIZEOF___INT64)
  887. check_type_size("long double" SIZEOF_LONG_DOUBLE)
  888. check_type_size("time_t" SIZEOF_TIME_T)
  889. if(NOT HAVE_SIZEOF_SSIZE_T)
  890. if(SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
  891. set(ssize_t long)
  892. endif()
  893. if(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
  894. set(ssize_t __int64)
  895. endif()
  896. endif()
  897. # off_t is sized later, after the HAVE_FILE_OFFSET_BITS test
  898. if(HAVE_SIZEOF_LONG_LONG)
  899. set(HAVE_LONGLONG 1)
  900. set(HAVE_LL 1)
  901. endif()
  902. find_file(RANDOM_FILE urandom /dev)
  903. mark_as_advanced(RANDOM_FILE)
  904. # Check for some functions that are used
  905. if(HAVE_LIBWS2_32)
  906. set(CMAKE_REQUIRED_LIBRARIES ws2_32)
  907. elseif(HAVE_LIBSOCKET)
  908. set(CMAKE_REQUIRED_LIBRARIES socket)
  909. endif()
  910. check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME)
  911. check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET)
  912. check_symbol_exists(select "${CURL_INCLUDES}" HAVE_SELECT)
  913. check_symbol_exists(poll "${CURL_INCLUDES}" HAVE_POLL)
  914. check_symbol_exists(strdup "${CURL_INCLUDES}" HAVE_STRDUP)
  915. check_symbol_exists(strstr "${CURL_INCLUDES}" HAVE_STRSTR)
  916. check_symbol_exists(strtok_r "${CURL_INCLUDES}" HAVE_STRTOK_R)
  917. check_symbol_exists(strftime "${CURL_INCLUDES}" HAVE_STRFTIME)
  918. check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME)
  919. check_symbol_exists(strcasecmp "${CURL_INCLUDES}" HAVE_STRCASECMP)
  920. check_symbol_exists(stricmp "${CURL_INCLUDES}" HAVE_STRICMP)
  921. check_symbol_exists(strcmpi "${CURL_INCLUDES}" HAVE_STRCMPI)
  922. check_symbol_exists(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI)
  923. check_symbol_exists(alarm "${CURL_INCLUDES}" HAVE_ALARM)
  924. if(NOT HAVE_STRNCMPI)
  925. set(HAVE_STRCMPI)
  926. endif()
  927. check_symbol_exists(getppid "${CURL_INCLUDES}" HAVE_GETPPID)
  928. check_symbol_exists(utimes "${CURL_INCLUDES}" HAVE_UTIMES)
  929. check_symbol_exists(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY)
  930. check_symbol_exists(inet_addr "${CURL_INCLUDES}" HAVE_INET_ADDR)
  931. check_symbol_exists(closesocket "${CURL_INCLUDES}" HAVE_CLOSESOCKET)
  932. check_symbol_exists(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP)
  933. check_symbol_exists(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R)
  934. check_symbol_exists(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID)
  935. check_symbol_exists(getpwuid_r "${CURL_INCLUDES}" HAVE_GETPWUID_R)
  936. check_symbol_exists(geteuid "${CURL_INCLUDES}" HAVE_GETEUID)
  937. check_symbol_exists(usleep "${CURL_INCLUDES}" HAVE_USLEEP)
  938. check_symbol_exists(utime "${CURL_INCLUDES}" HAVE_UTIME)
  939. check_symbol_exists(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R)
  940. check_symbol_exists(localtime_r "${CURL_INCLUDES}" HAVE_LOCALTIME_R)
  941. check_symbol_exists(gethostbyname "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME)
  942. check_symbol_exists(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R)
  943. check_symbol_exists(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC)
  944. check_symbol_exists(SIGALRM "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO)
  945. if(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
  946. set(HAVE_SIGNAL 1)
  947. endif()
  948. check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME)
  949. check_symbol_exists(strtoll "${CURL_INCLUDES}" HAVE_STRTOLL)
  950. check_symbol_exists(_strtoi64 "${CURL_INCLUDES}" HAVE__STRTOI64)
  951. check_symbol_exists(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R)
  952. check_symbol_exists(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT)
  953. check_symbol_exists(getaddrinfo "${CURL_INCLUDES}" HAVE_GETADDRINFO)
  954. check_symbol_exists(freeaddrinfo "${CURL_INCLUDES}" HAVE_FREEADDRINFO)
  955. check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE)
  956. check_symbol_exists(ftruncate "${CURL_INCLUDES}" HAVE_FTRUNCATE)
  957. check_symbol_exists(getprotobyname "${CURL_INCLUDES}" HAVE_GETPROTOBYNAME)
  958. check_symbol_exists(getpeername "${CURL_INCLUDES}" HAVE_GETPEERNAME)
  959. check_symbol_exists(getsockname "${CURL_INCLUDES}" HAVE_GETSOCKNAME)
  960. check_symbol_exists(if_nametoindex "${CURL_INCLUDES}" HAVE_IF_NAMETOINDEX)
  961. check_symbol_exists(getrlimit "${CURL_INCLUDES}" HAVE_GETRLIMIT)
  962. check_symbol_exists(setlocale "${CURL_INCLUDES}" HAVE_SETLOCALE)
  963. check_symbol_exists(setmode "${CURL_INCLUDES}" HAVE_SETMODE)
  964. check_symbol_exists(setrlimit "${CURL_INCLUDES}" HAVE_SETRLIMIT)
  965. check_symbol_exists(fcntl "${CURL_INCLUDES}" HAVE_FCNTL)
  966. check_symbol_exists(ioctl "${CURL_INCLUDES}" HAVE_IOCTL)
  967. check_symbol_exists(setsockopt "${CURL_INCLUDES}" HAVE_SETSOCKOPT)
  968. check_function_exists(mach_absolute_time HAVE_MACH_ABSOLUTE_TIME)
  969. check_symbol_exists(inet_pton "${CURL_INCLUDES}" HAVE_INET_PTON)
  970. check_symbol_exists(fsetxattr "${CURL_INCLUDES}" HAVE_FSETXATTR)
  971. if(HAVE_FSETXATTR)
  972. foreach(CURL_TEST HAVE_FSETXATTR_5 HAVE_FSETXATTR_6)
  973. curl_internal_test(${CURL_TEST})
  974. endforeach()
  975. endif()
  976. set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h")
  977. check_type_size("sa_family_t" SIZEOF_SA_FAMILY_T)
  978. set(HAVE_SA_FAMILY_T ${HAVE_SIZEOF_SA_FAMILY_T})
  979. set(CMAKE_EXTRA_INCLUDE_FILES "")
  980. set(CMAKE_EXTRA_INCLUDE_FILES "ws2def.h")
  981. check_type_size("ADDRESS_FAMILY" SIZEOF_ADDRESS_FAMILY)
  982. set(HAVE_ADDRESS_FAMILY ${HAVE_SIZEOF_ADDRESS_FAMILY})
  983. set(CMAKE_EXTRA_INCLUDE_FILES "")
  984. # sigaction and sigsetjmp are special. Use special mechanism for
  985. # detecting those, but only if previous attempt failed.
  986. if(HAVE_SIGNAL_H)
  987. check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
  988. endif()
  989. if(NOT HAVE_SIGSETJMP)
  990. if(HAVE_SETJMP_H)
  991. check_symbol_exists(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP)
  992. if(HAVE_MACRO_SIGSETJMP)
  993. set(HAVE_SIGSETJMP 1)
  994. endif()
  995. endif()
  996. endif()
  997. # If there is no stricmp(), do not allow LDAP to parse URLs
  998. if(NOT HAVE_STRICMP)
  999. set(HAVE_LDAP_URL_PARSE 1)
  1000. endif()
  1001. # Do curl specific tests
  1002. foreach(CURL_TEST
  1003. HAVE_FCNTL_O_NONBLOCK
  1004. HAVE_IOCTLSOCKET
  1005. HAVE_IOCTLSOCKET_CAMEL
  1006. HAVE_IOCTLSOCKET_CAMEL_FIONBIO
  1007. HAVE_IOCTLSOCKET_FIONBIO
  1008. HAVE_IOCTL_FIONBIO
  1009. HAVE_IOCTL_SIOCGIFADDR
  1010. HAVE_SETSOCKOPT_SO_NONBLOCK
  1011. HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
  1012. TIME_WITH_SYS_TIME
  1013. HAVE_O_NONBLOCK
  1014. HAVE_GETHOSTBYNAME_R_3
  1015. HAVE_GETHOSTBYNAME_R_5
  1016. HAVE_GETHOSTBYNAME_R_6
  1017. HAVE_GETHOSTBYNAME_R_3_REENTRANT
  1018. HAVE_GETHOSTBYNAME_R_5_REENTRANT
  1019. HAVE_GETHOSTBYNAME_R_6_REENTRANT
  1020. HAVE_IN_ADDR_T
  1021. HAVE_BOOL_T
  1022. STDC_HEADERS
  1023. HAVE_GETADDRINFO
  1024. HAVE_FILE_OFFSET_BITS
  1025. HAVE_VARIADIC_MACROS_C99
  1026. HAVE_VARIADIC_MACROS_GCC
  1027. )
  1028. curl_internal_test(${CURL_TEST})
  1029. endforeach()
  1030. if(HAVE_FILE_OFFSET_BITS)
  1031. set(_FILE_OFFSET_BITS 64)
  1032. set(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64")
  1033. endif()
  1034. check_type_size("off_t" SIZEOF_OFF_T)
  1035. # include this header to get the type
  1036. set(CMAKE_REQUIRED_INCLUDES "${CURL_SOURCE_DIR}/include")
  1037. set(CMAKE_EXTRA_INCLUDE_FILES "curl/system.h")
  1038. check_type_size("curl_off_t" SIZEOF_CURL_OFF_T)
  1039. set(CMAKE_EXTRA_INCLUDE_FILES "")
  1040. set(CMAKE_REQUIRED_FLAGS)
  1041. foreach(CURL_TEST
  1042. HAVE_GLIBC_STRERROR_R
  1043. HAVE_POSIX_STRERROR_R
  1044. )
  1045. curl_internal_test(${CURL_TEST})
  1046. endforeach()
  1047. # Check for reentrant
  1048. foreach(CURL_TEST
  1049. HAVE_GETHOSTBYNAME_R_3
  1050. HAVE_GETHOSTBYNAME_R_5
  1051. HAVE_GETHOSTBYNAME_R_6)
  1052. if(NOT ${CURL_TEST})
  1053. if(${CURL_TEST}_REENTRANT)
  1054. set(NEED_REENTRANT 1)
  1055. endif()
  1056. endif()
  1057. endforeach()
  1058. if(NEED_REENTRANT)
  1059. foreach(CURL_TEST
  1060. HAVE_GETHOSTBYNAME_R_3
  1061. HAVE_GETHOSTBYNAME_R_5
  1062. HAVE_GETHOSTBYNAME_R_6)
  1063. set(${CURL_TEST} 0)
  1064. if(${CURL_TEST}_REENTRANT)
  1065. set(${CURL_TEST} 1)
  1066. endif()
  1067. endforeach()
  1068. endif()
  1069. # Check clock_gettime(CLOCK_MONOTONIC, x) support
  1070. curl_internal_test(HAVE_CLOCK_GETTIME_MONOTONIC)
  1071. # Check compiler support of __builtin_available()
  1072. curl_internal_test(HAVE_BUILTIN_AVAILABLE)
  1073. # Some other minor tests
  1074. if(NOT HAVE_IN_ADDR_T)
  1075. set(in_addr_t "unsigned long")
  1076. endif()
  1077. # Fix libz / zlib.h
  1078. if(NOT CURL_SPECIAL_LIBZ)
  1079. if(NOT HAVE_LIBZ)
  1080. set(HAVE_ZLIB_H 0)
  1081. endif()
  1082. if(NOT HAVE_ZLIB_H)
  1083. set(HAVE_LIBZ 0)
  1084. endif()
  1085. endif()
  1086. # Check for nonblocking
  1087. set(HAVE_DISABLED_NONBLOCKING 1)
  1088. if(HAVE_FIONBIO OR
  1089. HAVE_IOCTLSOCKET OR
  1090. HAVE_IOCTLSOCKET_CASE OR
  1091. HAVE_O_NONBLOCK)
  1092. set(HAVE_DISABLED_NONBLOCKING)
  1093. endif()
  1094. if(CMAKE_COMPILER_IS_GNUCC AND APPLE)
  1095. include(CheckCCompilerFlag)
  1096. check_c_compiler_flag(-Wno-long-double HAVE_C_FLAG_Wno_long_double)
  1097. if(HAVE_C_FLAG_Wno_long_double)
  1098. # The Mac version of GCC warns about use of long double. Disable it.
  1099. get_source_file_property(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS)
  1100. if(MPRINTF_COMPILE_FLAGS)
  1101. set(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double")
  1102. else()
  1103. set(MPRINTF_COMPILE_FLAGS "-Wno-long-double")
  1104. endif()
  1105. set_source_files_properties(mprintf.c PROPERTIES
  1106. COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS})
  1107. endif()
  1108. endif()
  1109. # TODO test which of these headers are required
  1110. if(WIN32)
  1111. set(CURL_PULL_WS2TCPIP_H ${HAVE_WS2TCPIP_H})
  1112. else()
  1113. set(CURL_PULL_SYS_TYPES_H ${HAVE_SYS_TYPES_H})
  1114. set(CURL_PULL_SYS_SOCKET_H ${HAVE_SYS_SOCKET_H})
  1115. set(CURL_PULL_SYS_POLL_H ${HAVE_SYS_POLL_H})
  1116. endif()
  1117. set(CURL_PULL_STDINT_H ${HAVE_STDINT_H})
  1118. set(CURL_PULL_INTTYPES_H ${HAVE_INTTYPES_H})
  1119. include(CMake/OtherTests.cmake)
  1120. add_definitions(-DHAVE_CONFIG_H)
  1121. # For Windows, all compilers used by CMake should support large files
  1122. if(WIN32)
  1123. set(USE_WIN32_LARGE_FILES ON)
  1124. # Use the manifest embedded in the Windows Resource
  1125. set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DCURL_EMBED_MANIFEST")
  1126. # Check if crypto functions in wincrypt.h are actually available
  1127. if(HAVE_WINCRYPT_H)
  1128. check_symbol_exists(CryptAcquireContext "${CURL_INCLUDES}" USE_WINCRYPT)
  1129. endif()
  1130. if(USE_WINCRYPT)
  1131. set(USE_WIN32_CRYPTO ON)
  1132. endif()
  1133. # Link required libraries for USE_WIN32_CRYPTO or USE_SCHANNEL
  1134. if(USE_WIN32_CRYPTO OR USE_SCHANNEL)
  1135. list(APPEND CURL_LIBS "advapi32" "crypt32")
  1136. endif()
  1137. endif()
  1138. if(MSVC)
  1139. # Disable default manifest added by CMake
  1140. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
  1141. add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
  1142. if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
  1143. string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
  1144. else()
  1145. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
  1146. endif()
  1147. # Use multithreaded compilation on VS 2008+
  1148. if(MSVC_VERSION GREATER_EQUAL 1500)
  1149. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
  1150. endif()
  1151. endif()
  1152. if(CURL_WERROR)
  1153. if(MSVC_VERSION)
  1154. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
  1155. else()
  1156. # this assumes clang or gcc style options
  1157. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
  1158. endif()
  1159. endif()
  1160. if(CURL_LTO)
  1161. if(CMAKE_VERSION VERSION_LESS 3.9)
  1162. message(FATAL_ERROR "Requested LTO but your cmake version ${CMAKE_VERSION} is to old. You need at least 3.9")
  1163. endif()
  1164. cmake_policy(SET CMP0069 NEW)
  1165. include(CheckIPOSupported)
  1166. check_ipo_supported(RESULT CURL_HAS_LTO OUTPUT CURL_LTO_ERROR LANGUAGES C)
  1167. if(CURL_HAS_LTO)
  1168. message(STATUS "LTO supported and enabled")
  1169. else()
  1170. message(FATAL_ERROR "LTO was requested - but compiler doesn't support it\n${CURL_LTO_ERROR}")
  1171. endif()
  1172. endif()
  1173. # Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it).
  1174. function(transform_makefile_inc INPUT_FILE OUTPUT_FILE)
  1175. file(READ ${INPUT_FILE} MAKEFILE_INC_TEXT)
  1176. string(REPLACE "$(top_srcdir)" "\${CURL_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  1177. string(REPLACE "$(top_builddir)" "\${CURL_BINARY_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  1178. string(REGEX REPLACE "\\\\\n" "!π!α!" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  1179. string(REGEX REPLACE "([a-zA-Z_][a-zA-Z0-9_]*)[\t ]*=[\t ]*([^\n]*)" "SET(\\1 \\2)" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  1180. string(REPLACE "!π!α!" "\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  1181. string(REGEX REPLACE "\\$\\(([a-zA-Z_][a-zA-Z0-9_]*)\\)" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace $() with ${}
  1182. 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.
  1183. file(WRITE ${OUTPUT_FILE} ${MAKEFILE_INC_TEXT})
  1184. set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${INPUT_FILE}")
  1185. endfunction()
  1186. include(GNUInstallDirs)
  1187. set(CURL_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
  1188. set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
  1189. set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
  1190. set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
  1191. set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
  1192. if(USE_MANUAL)
  1193. add_subdirectory(docs)
  1194. endif()
  1195. add_subdirectory(lib)
  1196. if(BUILD_CURL_EXE)
  1197. add_subdirectory(src)
  1198. endif()
  1199. cmake_dependent_option(BUILD_TESTING "Build tests"
  1200. ON "PERL_FOUND;NOT CURL_DISABLE_TESTS"
  1201. OFF)
  1202. if(BUILD_TESTING)
  1203. add_subdirectory(tests)
  1204. endif()
  1205. # Helper to populate a list (_items) with a label when conditions (the remaining
  1206. # args) are satisfied
  1207. macro(_add_if label)
  1208. # needs to be a macro to allow this indirection
  1209. if(${ARGN})
  1210. set(_items ${_items} "${label}")
  1211. endif()
  1212. endmacro()
  1213. # NTLM support requires crypto function adaptions from various SSL libs
  1214. # TODO alternative SSL libs tests for SSP1, GNUTLS, NSS
  1215. if(NOT (CURL_DISABLE_CRYPTO_AUTH OR CURL_DISABLE_NTLM) AND
  1216. (USE_OPENSSL OR USE_MBEDTLS OR USE_DARWINSSL OR USE_WIN32_CRYPTO))
  1217. set(use_curl_ntlm_core ON)
  1218. endif()
  1219. # Clear list and try to detect available features
  1220. set(_items)
  1221. _add_if("SSL" SSL_ENABLED)
  1222. _add_if("IPv6" ENABLE_IPV6)
  1223. _add_if("unixsockets" USE_UNIX_SOCKETS)
  1224. _add_if("libz" HAVE_LIBZ)
  1225. _add_if("brotli" HAVE_BROTLI)
  1226. _add_if("zstd" HAVE_ZSTD)
  1227. _add_if("AsynchDNS" USE_ARES OR USE_THREADS_POSIX OR USE_THREADS_WIN32)
  1228. _add_if("IDN" HAVE_LIBIDN2 OR USE_WIN32_IDN)
  1229. _add_if("Largefile" (SIZEOF_CURL_OFF_T GREATER 4) AND
  1230. ((SIZEOF_OFF_T GREATER 4) OR USE_WIN32_LARGE_FILES))
  1231. # TODO SSP1 (Schannel) check is missing
  1232. _add_if("SSPI" USE_WINDOWS_SSPI)
  1233. _add_if("GSS-API" HAVE_GSSAPI)
  1234. _add_if("alt-svc" NOT CURL_DISABLE_ALTSVC)
  1235. _add_if("HSTS" NOT CURL_DISABLE_HSTS)
  1236. # TODO SSP1 missing for SPNEGO
  1237. _add_if("SPNEGO" NOT CURL_DISABLE_CRYPTO_AUTH AND
  1238. (HAVE_GSSAPI OR USE_WINDOWS_SSPI))
  1239. _add_if("Kerberos" NOT CURL_DISABLE_CRYPTO_AUTH AND
  1240. (HAVE_GSSAPI OR USE_WINDOWS_SSPI))
  1241. # NTLM support requires crypto function adaptions from various SSL libs
  1242. # TODO alternative SSL libs tests for SSP1, GNUTLS, NSS
  1243. _add_if("NTLM" NOT (CURL_DISABLE_CRYPTO_AUTH OR CURL_DISABLE_NTLM) AND
  1244. (use_curl_ntlm_core OR USE_WINDOWS_SSPI))
  1245. # TODO missing option (autoconf: --enable-ntlm-wb)
  1246. _add_if("NTLM_WB" NOT (CURL_DISABLE_CRYPTO_AUTH OR CURL_DISABLE_NTLM) AND
  1247. (use_curl_ntlm_core OR USE_WINDOWS_SSPI) AND
  1248. NOT CURL_DISABLE_HTTP AND NTLM_WB_ENABLED)
  1249. # TODO missing option (--enable-tls-srp), depends on GNUTLS_SRP/OPENSSL_SRP
  1250. _add_if("TLS-SRP" USE_TLS_SRP)
  1251. # TODO option --with-nghttp2 tests for nghttp2 lib and nghttp2/nghttp2.h header
  1252. _add_if("HTTP2" USE_NGHTTP2)
  1253. _add_if("HTTP3" USE_NGTCP2 OR USE_QUICHE)
  1254. _add_if("MultiSSL" CURL_WITH_MULTI_SSL)
  1255. _add_if("HTTPS-proxy" SSL_ENABLED AND (USE_OPENSSL OR USE_GNUTLS OR USE_NSS))
  1256. _add_if("unicode" ENABLE_UNICODE)
  1257. string(REPLACE ";" " " SUPPORT_FEATURES "${_items}")
  1258. message(STATUS "Enabled features: ${SUPPORT_FEATURES}")
  1259. # Clear list and try to detect available protocols
  1260. set(_items)
  1261. _add_if("HTTP" NOT CURL_DISABLE_HTTP)
  1262. _add_if("HTTPS" NOT CURL_DISABLE_HTTP AND SSL_ENABLED)
  1263. _add_if("FTP" NOT CURL_DISABLE_FTP)
  1264. _add_if("FTPS" NOT CURL_DISABLE_FTP AND SSL_ENABLED)
  1265. _add_if("FILE" NOT CURL_DISABLE_FILE)
  1266. _add_if("TELNET" NOT CURL_DISABLE_TELNET)
  1267. _add_if("LDAP" NOT CURL_DISABLE_LDAP)
  1268. # CURL_DISABLE_LDAP implies CURL_DISABLE_LDAPS
  1269. # TODO check HAVE_LDAP_SSL (in autoconf this is enabled with --enable-ldaps)
  1270. _add_if("LDAPS" NOT CURL_DISABLE_LDAPS AND
  1271. ((USE_OPENLDAP AND SSL_ENABLED) OR
  1272. (NOT USE_OPENLDAP AND HAVE_LDAP_SSL)))
  1273. _add_if("DICT" NOT CURL_DISABLE_DICT)
  1274. _add_if("TFTP" NOT CURL_DISABLE_TFTP)
  1275. _add_if("GOPHER" NOT CURL_DISABLE_GOPHER)
  1276. _add_if("GOPHERS" NOT CURL_DISABLE_GOPHER AND SSL_ENABLED)
  1277. _add_if("POP3" NOT CURL_DISABLE_POP3)
  1278. _add_if("POP3S" NOT CURL_DISABLE_POP3 AND SSL_ENABLED)
  1279. _add_if("IMAP" NOT CURL_DISABLE_IMAP)
  1280. _add_if("IMAPS" NOT CURL_DISABLE_IMAP AND SSL_ENABLED)
  1281. _add_if("SMB" NOT CURL_DISABLE_SMB AND
  1282. use_curl_ntlm_core AND (SIZEOF_CURL_OFF_T GREATER 4))
  1283. _add_if("SMBS" NOT CURL_DISABLE_SMB AND SSL_ENABLED AND
  1284. use_curl_ntlm_core AND (SIZEOF_CURL_OFF_T GREATER 4))
  1285. _add_if("SMTP" NOT CURL_DISABLE_SMTP)
  1286. _add_if("SMTPS" NOT CURL_DISABLE_SMTP AND SSL_ENABLED)
  1287. _add_if("SCP" USE_LIBSSH2 OR USE_LIBSSH)
  1288. _add_if("SFTP" USE_LIBSSH2 OR USE_LIBSSH)
  1289. _add_if("RTSP" NOT CURL_DISABLE_RTSP)
  1290. _add_if("RTMP" USE_LIBRTMP)
  1291. _add_if("MQTT" NOT CURL_DISABLE_MQTT)
  1292. if(_items)
  1293. list(SORT _items)
  1294. endif()
  1295. string(REPLACE ";" " " SUPPORT_PROTOCOLS "${_items}")
  1296. message(STATUS "Enabled protocols: ${SUPPORT_PROTOCOLS}")
  1297. # Clear list and collect SSL backends
  1298. set(_items)
  1299. _add_if("Schannel" SSL_ENABLED AND USE_SCHANNEL)
  1300. _add_if("OpenSSL" SSL_ENABLED AND USE_OPENSSL)
  1301. _add_if("Secure Transport" SSL_ENABLED AND USE_SECTRANSP)
  1302. _add_if("mbedTLS" SSL_ENABLED AND USE_MBEDTLS)
  1303. _add_if("BearSSL" SSL_ENABLED AND USE_BEARSSL)
  1304. _add_if("NSS" SSL_ENABLED AND USE_NSS)
  1305. _add_if("wolfSSL" SSL_ENABLED AND USE_WOLFSSL)
  1306. if(_items)
  1307. list(SORT _items)
  1308. endif()
  1309. string(REPLACE ";" " " SSL_BACKENDS "${_items}")
  1310. message(STATUS "Enabled SSL backends: ${SSL_BACKENDS}")
  1311. # curl-config needs the following options to be set.
  1312. set(CC "${CMAKE_C_COMPILER}")
  1313. # TODO probably put a -D... options here?
  1314. set(CONFIGURE_OPTIONS "")
  1315. # TODO when to set "-DCURL_STATICLIB" for CPPFLAG_CURL_STATICLIB?
  1316. set(CPPFLAG_CURL_STATICLIB "")
  1317. set(CURLVERSION "${CURL_VERSION}")
  1318. set(exec_prefix "\${prefix}")
  1319. set(includedir "\${prefix}/include")
  1320. set(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
  1321. set(LIBCURL_LIBS "")
  1322. set(libdir "${CMAKE_INSTALL_PREFIX}/lib")
  1323. foreach(_lib ${CMAKE_C_IMPLICIT_LINK_LIBRARIES} ${CURL_LIBS})
  1324. if(TARGET "${_lib}")
  1325. set(_libname "${_lib}")
  1326. get_target_property(_imported "${_libname}" IMPORTED)
  1327. if(NOT _imported)
  1328. # Reading the LOCATION property on non-imported target will error out.
  1329. # Assume the user won't need this information in the .pc file.
  1330. continue()
  1331. endif()
  1332. get_target_property(_lib "${_libname}" LOCATION)
  1333. if(NOT _lib)
  1334. message(WARNING "Bad lib in library list: ${_libname}")
  1335. continue()
  1336. endif()
  1337. endif()
  1338. if(_lib MATCHES ".*/.*" OR _lib MATCHES "^-")
  1339. set(LIBCURL_LIBS "${LIBCURL_LIBS} ${_lib}")
  1340. else()
  1341. set(LIBCURL_LIBS "${LIBCURL_LIBS} -l${_lib}")
  1342. endif()
  1343. endforeach()
  1344. if(BUILD_SHARED_LIBS)
  1345. set(ENABLE_SHARED "yes")
  1346. set(ENABLE_STATIC "no")
  1347. set(LIBCURL_NO_SHARED "")
  1348. else()
  1349. set(ENABLE_SHARED "no")
  1350. set(ENABLE_STATIC "yes")
  1351. set(LIBCURL_NO_SHARED "${LIBCURL_LIBS}")
  1352. endif()
  1353. # "a" (Linux) or "lib" (Windows)
  1354. string(REPLACE "." "" libext "${CMAKE_STATIC_LIBRARY_SUFFIX}")
  1355. set(prefix "${CMAKE_INSTALL_PREFIX}")
  1356. # Set this to "yes" to append all libraries on which -lcurl is dependent
  1357. set(REQUIRE_LIB_DEPS "no")
  1358. # SUPPORT_FEATURES
  1359. # SUPPORT_PROTOCOLS
  1360. set(VERSIONNUM "${CURL_VERSION_NUM}")
  1361. # Finally generate a "curl-config" matching this config
  1362. # Use:
  1363. # * ENABLE_SHARED
  1364. # * ENABLE_STATIC
  1365. configure_file("${CURL_SOURCE_DIR}/curl-config.in"
  1366. "${CURL_BINARY_DIR}/curl-config" @ONLY)
  1367. install(FILES "${CURL_BINARY_DIR}/curl-config"
  1368. DESTINATION ${CMAKE_INSTALL_BINDIR}
  1369. PERMISSIONS
  1370. OWNER_READ OWNER_WRITE OWNER_EXECUTE
  1371. GROUP_READ GROUP_EXECUTE
  1372. WORLD_READ WORLD_EXECUTE)
  1373. # Finally generate a pkg-config file matching this config
  1374. configure_file("${CURL_SOURCE_DIR}/libcurl.pc.in"
  1375. "${CURL_BINARY_DIR}/libcurl.pc" @ONLY)
  1376. install(FILES "${CURL_BINARY_DIR}/libcurl.pc"
  1377. DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
  1378. # install headers
  1379. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/curl"
  1380. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
  1381. FILES_MATCHING PATTERN "*.h")
  1382. include(CMakePackageConfigHelpers)
  1383. write_basic_package_version_file(
  1384. "${version_config}"
  1385. VERSION ${CURL_VERSION}
  1386. COMPATIBILITY SameMajorVersion
  1387. )
  1388. # Use:
  1389. # * TARGETS_EXPORT_NAME
  1390. # * PROJECT_NAME
  1391. configure_package_config_file(CMake/curl-config.cmake.in
  1392. "${project_config}"
  1393. INSTALL_DESTINATION ${CURL_INSTALL_CMAKE_DIR}
  1394. )
  1395. if(CURL_ENABLE_EXPORT_TARGET)
  1396. install(
  1397. EXPORT "${TARGETS_EXPORT_NAME}"
  1398. NAMESPACE "${PROJECT_NAME}::"
  1399. DESTINATION ${CURL_INSTALL_CMAKE_DIR}
  1400. )
  1401. endif()
  1402. install(
  1403. FILES ${version_config} ${project_config}
  1404. DESTINATION ${CURL_INSTALL_CMAKE_DIR}
  1405. )
  1406. # Workaround for MSVS10 to avoid the Dialog Hell
  1407. # FIXME: This could be removed with future version of CMake.
  1408. if(MSVC_VERSION EQUAL 1600)
  1409. set(CURL_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/CURL.sln")
  1410. if(EXISTS "${CURL_SLN_FILENAME}")
  1411. file(APPEND "${CURL_SLN_FILENAME}" "\n# This should be regenerated!\n")
  1412. endif()
  1413. endif()
  1414. if(NOT TARGET uninstall)
  1415. configure_file(
  1416. ${CMAKE_CURRENT_SOURCE_DIR}/CMake/cmake_uninstall.cmake.in
  1417. ${CMAKE_CURRENT_BINARY_DIR}/CMake/cmake_uninstall.cmake
  1418. IMMEDIATE @ONLY)
  1419. add_custom_target(uninstall
  1420. COMMAND ${CMAKE_COMMAND} -P
  1421. ${CMAKE_CURRENT_BINARY_DIR}/CMake/cmake_uninstall.cmake)
  1422. endif()