CMakeLists.txt 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122
  1. # CMakeList.txt
  2. #
  3. # Copyright (C) 2006-2020 wolfSSL Inc.
  4. #
  5. # This file is part of wolfSSL. (formerly known as CyaSSL)
  6. #
  7. # Usage:
  8. # $ mkdir build
  9. # $ cd build
  10. # $ cmake ..
  11. # $ cmake --build .
  12. #
  13. # To build with debugging use:
  14. # $ cmake .. -DCMAKE_BUILD_TYPE=Debug
  15. #
  16. # See "Building with CMake" in INSTALL for more.
  17. ####################################################
  18. # Project
  19. ####################################################
  20. cmake_minimum_required(VERSION 3.16)
  21. if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
  22. message(FATAL_ERROR "In-source builds are not allowed.\
  23. Run cmake from a separate directory from where CMakeLists.txt lives.\
  24. NOTE: cmake will now create CMakeCache.txt and CMakeFiles/*.\
  25. You must delete them, or cmake will refuse to work.")
  26. endif()
  27. project(wolfssl VERSION 5.2.0 LANGUAGES C ASM)
  28. # shared library versioning
  29. # increment if interfaces have been added, removed or changed
  30. set(LIBTOOL_CURRENT 32)
  31. # increment if source code has changed set to zero if current is incremented
  32. set(LIBTOOL_REVISION 0)
  33. # increment if interfaces have been added set to zero if interfaces have been
  34. # removed or changed
  35. set(LIBTOOL_AGE 0)
  36. math(EXPR LIBTOOL_SO_VERSION "${LIBTOOL_CURRENT} - ${LIBTOOL_AGE}")
  37. set(LIBTOOL_FULL_VERSION ${LIBTOOL_SO_VERSION}.${LIBTOOL_AGE}.${LIBTOOL_REVISION})
  38. set(WOLFSSL_DEFINITIONS)
  39. set(WOLFSSL_LINK_LIBS)
  40. include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/functions.cmake)
  41. ####################################################
  42. # Compiler
  43. ####################################################
  44. # Let CMake choose default compiler
  45. # TODO: See gl_VISIBILITY in visibility.m4. Need to perform
  46. # the same checks.
  47. # TODO: Turn on warnings.
  48. if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
  49. # Silence ranlib warning "has no symbols"
  50. set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
  51. set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
  52. set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
  53. set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
  54. endif()
  55. include(CheckIncludeFile)
  56. check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
  57. check_include_file("fcntl.h" HAVE_FCNTL_H)
  58. check_include_file("limits.h" HAVE_LIMITS_H)
  59. check_include_file("netdb.h" HAVE_NETDB_H)
  60. check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
  61. check_include_file("stddef.h" HAVE_STDDEF_H)
  62. check_include_file("time.h" HAVE_TIME_H)
  63. check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
  64. check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
  65. check_include_file("sys/time.h" HAVE_SYS_TIME_H)
  66. check_include_file("errno.h" HAVE_ERRNO_H)
  67. check_include_file("dlfcn.h" HAVE_DLFCN_H)
  68. check_include_file("inttypes.h" HAVE_INTTYPES_H)
  69. check_include_file("memory.h" HAVE_MEMORY_H)
  70. check_include_file("stdint.h" HAVE_STDINT_H)
  71. check_include_file("stdlib.h" HAVE_STDLIB_H)
  72. check_include_file("string.h" HAVE_STRING_H)
  73. check_include_file("strings.h" HAVE_STRINGS_H)
  74. check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
  75. check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
  76. check_include_file("unistd.h" HAVE_UNISTD_H)
  77. include(CheckFunctionExists)
  78. # TODO: Also check if these functions are declared by the
  79. # expected headers. See comments around
  80. # AC_CHECK_FUNCS/AC_CHECK_DECLS in configure.ac.
  81. check_function_exists("gethostbyname" HAVE_GETHOSTBYNAME)
  82. check_function_exists("getaddrinfo" HAVE_GETADDRINFO)
  83. check_function_exists("gettimeofday" HAVE_GETTIMEOFDAY)
  84. check_function_exists("gmtime_r" HAVE_GMTIME_R)
  85. check_function_exists("inet_ntoa" HAVE_INET_NTOA)
  86. check_function_exists("memset" HAVE_MEMSET)
  87. check_function_exists("socket" HAVE_SOCKET)
  88. check_function_exists("strftime" HAVE_STRFTIME)
  89. include(CheckTypeSize)
  90. check_type_size("__uint128_t" __UINT128_T)
  91. check_type_size("long long" SIZEOF_LONG_LONG)
  92. check_type_size("long" SIZEOF_LONG)
  93. check_type_size("time_t" SIZEOF_TIME_T)
  94. # By default, HAVE___UINT128_T gets defined as TRUE,
  95. # but we want it as 1.
  96. if(HAVE___UINT128_T)
  97. set(HAVE___UINT128_T "1" CACHE INTERNAL "Result of TRY_COMPILE" FORCE)
  98. endif()
  99. include(TestBigEndian)
  100. test_big_endian(WORDS_BIGENDIAN)
  101. # Thread local storage
  102. include(CheckCSourceCompiles)
  103. set(TLS_KEYWORDS "__thread" "__declspec(thread)")
  104. foreach(TLS_KEYWORD IN LISTS TLS_KEYWORDS)
  105. set(TLS_CODE "#include <stdlib.h>
  106. static void foo(void) {
  107. static ${TLS_KEYWORD} int bar\;
  108. exit(1)\;
  109. }
  110. int main() {
  111. return 0\;
  112. }"
  113. )
  114. check_c_source_compiles(${TLS_CODE} THREAD_LS_ON)
  115. if(THREAD_LS_ON)
  116. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_THREAD_LS")
  117. break()
  118. else()
  119. # THREAD_LS_ON is cached after each call to
  120. # check_c_source_compiles, and the function
  121. # won't run subsequent times if the variable
  122. # is in the cache. To make it run again, we
  123. # need to remove the variable from the cache.
  124. unset(THREAD_LS_ON CACHE)
  125. endif()
  126. endforeach()
  127. # TODO: AX_PTHREAD does a lot. Need to implement the
  128. # rest of its logic.
  129. find_package(Threads)
  130. ####################################################
  131. # Cross Compile Example
  132. ####################################################
  133. #set(CMAKE_SYSTEM_NAME Linux)
  134. #set(CMAKE_SYSTEM_PROCESSOR arm)
  135. #set(CMAKE_C_COMPILER "/opt/arm-linux-musleabihf-cross/bin/arm-linux-musleabihf-gcc")
  136. #set(CMAKE_CXX_COMPILER "/opt/arm-linux-musleabihf-cross/bin/arm-linux-musleabihf-g++")
  137. #set(CMAKE_SYSROOT "/opt/arm-linux-musleabihf-cross/arm-linux-musleabihf/")
  138. # Example for setting CFLAGS
  139. #set(CMAKE_C_FLAGS "-std=gnu89 ${CMAKE_C_FLAGS}")
  140. # Example for map file and custom linker script
  141. #set(CMAKE_EXE_LINKER_FLAGS " -Xlinker -Map=output.map -T\"${CMAKE_CURRENT_SOURCE_DIR}/linker.ld\"")
  142. ####################################################
  143. # Build Options
  144. ####################################################
  145. # TODO: - FIPS
  146. # - Distro
  147. # - Linux Kernel Module
  148. # - Single precision math
  149. # - Enable all
  150. # - Enable all crypto
  151. # For reproducible build, gate out from the build anything that might
  152. # introduce semantically frivolous jitter, maximizing chance of
  153. # identical object files.
  154. add_option("WOLFSSL_REPRODUCIBLE_BUILD"
  155. "Enable maximally reproducible build (default: disabled)"
  156. "no" "yes;no")
  157. if(WOLFSSL_REPRODUCIBLE_BUILD)
  158. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_REPRODUCIBLE_BUILD")
  159. set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>")
  160. set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> Dq <TARGET> <LINK_FLAGS> <OBJECTS>")
  161. set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
  162. endif()
  163. # Support for forcing 32-bit mode
  164. # TODO: detect platform from other options
  165. add_option("WOLFSSL_32BIT"
  166. "Enables 32-bit support (default: disabled)"
  167. "no" "yes;no")
  168. # 16-bit compiler support
  169. add_option("WOLFSSL_16BIT"
  170. "Enables 16-bit support (default: disabled)"
  171. "no" "yes;no")
  172. if(WOLFSSL_16BIT)
  173. list(APPEND WOLFSSL_DEFINITIONS "-DWC_16BIT_CPU")
  174. endif()
  175. # Support for disabling all ASM
  176. add_option("WOLFSSL_ASM"
  177. "Enables option for assembly (default: enabled)"
  178. "yes" "yes;no")
  179. if(NOT WOLFSSL_ASM)
  180. list(APPEND WOLFSSL_DEFINITIONS
  181. "-DTFM_NO_ASM"
  182. "-DWOLFSSL_NO_ASM")
  183. endif()
  184. # Enable Debugging
  185. add_option("WOLFSSL_DEBUG"
  186. "Enables option for debug (default: disabled)"
  187. "no" "yes;no")
  188. if(WOLFSSL_DEBUG)
  189. set(CMAKE_C_FLAGS "-g ${CMAKE_C_FLAGS}")
  190. list(APPEND WOLFSSL_DEFINITIONS
  191. "-DDEBUG_WOLFSSL"
  192. "-DDEBUG")
  193. endif()
  194. # Single threaded
  195. add_option("WOLFSSL_SINGLE_THREADED"
  196. "Enable wolfSSL single threaded (default: disabled)"
  197. "no" "yes;no")
  198. # TODO: Logic here isn't complete, yet (see AX_PTHREAD)
  199. if(NOT WOLFSSL_SINGLE_THREADED)
  200. if(CMAKE_USE_PTHREADS_INIT)
  201. list(APPEND WOLFSSL_LINK_LIBS Threads::Threads)
  202. set(HAVE_PTHREAD 1)
  203. list(APPEND WOLFSSL_DEFINITIONS
  204. "-DHAVE_PTHREAD"
  205. "-D_POSIX_THREADS")
  206. endif()
  207. endif()
  208. # DTLS
  209. add_option("WOLFSSL_DTLS"
  210. "Enables wolfSSL DTLS (default: disabled)"
  211. "no" "yes;no")
  212. if(WOLFSSL_DTLS)
  213. list(APPEND WOLFSSL_DEFINITIONS
  214. "-DWOLFSSL_DTLS")
  215. endif()
  216. # TLS v1.3
  217. add_option("WOLFSSL_TLS13"
  218. "Enable wolfSSL TLS v1.3 (default: enabled)"
  219. "yes" "yes;no")
  220. if("${FIPS_VERSION}" STREQUAL "v1")
  221. override_cache(WOLFSSL_TLS13 "no")
  222. endif()
  223. # Post-handshake authentication
  224. add_option("WOLFSSL_POSTAUTH"
  225. "Enable wolfSSL Post-handshake Authentication (default: disabled)"
  226. "no" "yes;no")
  227. if(WOLFSSL_POSTAUTH)
  228. if(NOT WOLFSSL_TLS13)
  229. message(WARNING "TLS 1.3 is disabled - disabling Post-handshake Authentication")
  230. override_cache(WOLFSSL_POSTAUTH "no")
  231. else()
  232. list(APPEND WOLFSSL_DEFINITIONS
  233. "-DWOLFSSL_POST_HANDSHAKE_AUTH")
  234. endif()
  235. endif()
  236. # Hello Retry Request Cookie
  237. add_option("WOLFSSL_HRR_COOKIE"
  238. "Enable the server to send Cookie Extension in HRR with state (default: disabled)"
  239. "no" "yes;no")
  240. if(WOLFSSL_HRR_COOKIE)
  241. if(NOT WOLFSSL_TLS13)
  242. message(WARNING "TLS 1.3 is disabled - disabling HRR Cookie")
  243. override_cache(WOLFSSL_HRR_COOKIE "no")
  244. else()
  245. list(APPEND WOLFSSL_DEFINITIONS
  246. "-DWOLFSSL_SEND_HRR_COOKIE")
  247. endif()
  248. endif()
  249. # RNG
  250. add_option("WOLFSSL_RNG"
  251. "Enable compiling and using RNG (default: enabled)"
  252. "yes" "yes;no")
  253. if(NOT WOLFSSL_RNG)
  254. list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_RNG")
  255. endif()
  256. # TODO: - DTLS-SCTP
  257. # - DTLS multicast
  258. # - OpenSSH
  259. # - OpenVPN
  260. # - Nginx
  261. # - HAProxy
  262. # - wpa_supplicant
  263. # - Fortress
  264. # - libwebsockets
  265. # - IP alternative name
  266. # - Qt
  267. # - SSL bump
  268. # - sniffer
  269. # - Signal
  270. # - OpenSSL coexist
  271. # - OpenSSL compatibility all
  272. # - OpenSSL compatibility extra
  273. # - Max strength
  274. # Harden, enable Timing Resistance and Blinding by default
  275. add_option("WOLFSSL_HARDEN"
  276. "Enable Hardened build, Enables Timing Resistance and Blinding (default: enabled)"
  277. "yes" "yes;no")
  278. if(WOLFSSL_HARDEN)
  279. list(APPEND WOLFSSL_DEFINITIONS "-DTFM_TIMING_RESISTANT" "-DECC_TIMING_RESISTANT")
  280. if(WOLFSSL_RNG)
  281. list(APPEND WOLFSSL_DEFINITIONS "-DWC_RSA_BLINDING")
  282. endif()
  283. else()
  284. list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_HARDEN")
  285. endif()
  286. add_option(WOLFSSL_OPENSSLEXTRA
  287. "Enable extra OpenSSL API, size+ (default: disabled)"
  288. "no" "yes;no")
  289. if (WOLFSSL_OPENSSLEXTRA AND NOT WOLFSSL_OPENSSLCOEXIST)
  290. list(APPEND WOLFSSL_DEFINITIONS
  291. "-DOPENSSL_EXTRA"
  292. "-DWOLFSSL_ALWAYS_VERIFY_CB"
  293. "-DWOLFSSL_VERIFY_CB_ALL_CERTS"
  294. "-DWOLFSSL_EXTRA_ALERTS"
  295. "-DHAVE_EXT_CACHE"
  296. "-DWOLFSSL_FORCE_CACHE_ON_TICKET")
  297. endif()
  298. # TODO: - IPv6 test apps
  299. set(WOLFSSL_SLOW_MATH "yes")
  300. # TODO: - Lean PSK
  301. # - Lean TLS
  302. # - Low resource
  303. # - Titan cache
  304. # - Huge cache
  305. # - Big cache
  306. # - Small cache
  307. # - Persistent session cache
  308. # - Persistent cert cache
  309. # - Write duplicate
  310. # - Atomic user record layer
  311. # - Public key callbacks
  312. # - Microchip/Atmel CryptoAuthLib
  313. # AES-CBC
  314. add_option("WOLFSSL_AESCBC"
  315. "Enable wolfSSL AES-CBC support (default: enabled)"
  316. "yes" "yes;no")
  317. if(NOT WOLFSSL_AESCBC)
  318. list(APPEND WOLFSSL_DEFINITIONS "-DNO_AES_CBC")
  319. endif()
  320. # AES-GCM
  321. add_option("WOLFSSL_AESGCM"
  322. "Enable wolfSSL AES-GCM support (default: enabled)"
  323. "yes" "yes;no;table;small;word32;4bit")
  324. # leanpsk and leantls don't need gcm
  325. if(WOLFSSL_LEAN_PSK OR (WOLFSSL_LEAN_TLS AND NOT WOLFSSL_TLS13))
  326. override_cache(WOLFSSL_AESGCM "no")
  327. endif()
  328. if(WOLFSSL_AESGCM AND NOT WORDS_BIGENDIAN)
  329. override_cache(WOLFSSL_AESGCM "4bit")
  330. endif()
  331. if(WOLFSSL_AESGCM)
  332. if("${WOLFSSL_AESGCM}" STREQUAL "word32")
  333. list(APPEND WOLFSSL_DEFINITIONS "-DGCM_WORD32")
  334. override_cache(WOLFSSL_AESGCM "yes")
  335. endif()
  336. if(("${WOLFSSL_AESGCM}" STREQUAL "small") OR WOLFSSL_LOW_RESOURCE)
  337. list(APPEND WOLFSSL_DEFINITIONS "-DGCM_SMALL")
  338. override_cache(WOLFSSL_AESGCM "yes")
  339. endif()
  340. if("${WOLFSSL_AESGCM}" STREQUAL "table")
  341. list(APPEND WOLFSSL_DEFINITIONS "-DGCM_TABLE")
  342. override_cache(WOLFSSL_AESGCM "yes")
  343. endif()
  344. if("${WOLFSSL_AESGCM}" STREQUAL "4bit")
  345. list(APPEND WOLFSSL_DEFINITIONS "-DGCM_TABLE_4BIT")
  346. override_cache(WOLFSSL_AESGCM "yes")
  347. endif()
  348. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_AESGCM")
  349. endif()
  350. # AES-SIV
  351. add_option("WOLFSSL_AESSIV"
  352. "Enable wolfSSL AES-SIV support (default: disabled)"
  353. "no" "yes;no")
  354. if(WOLFSSL_AESSIV)
  355. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_AES_SIV")
  356. endif()
  357. # AES-CTR
  358. add_option("WOLFSSL_AESCTR"
  359. "Enable wolfSSL AES-CTR support (default: disabled)"
  360. "no" "yes;no")
  361. if(WOLFSSL_OPENVPN OR
  362. WOLFSSL_LIBSSH2 OR
  363. WOLFSSL_AESSIV)
  364. override_cache(WOLFSSL_AESCTR "yes")
  365. endif()
  366. if(WOLFSSL_AESCTR AND NOT WOLFSSL_FORTRESS)
  367. list(APPEND WOLFSSL_DEFINITIONS
  368. "-DWOLFSSL_AES_COUNTER"
  369. "-DWOLFSSL_AES_DIRECT")
  370. endif()
  371. # AES-CCM
  372. add_option("WOLFSSL_AESCCM"
  373. "Enable wolfSSL AES-CCM support (default: disabled)"
  374. "no" "yes;no")
  375. # AES-OFB
  376. add_option("WOLFSSL_AESOFB"
  377. "Enable wolfSSL AES-OFB support (default: disabled)"
  378. "no" "yes;no")
  379. # TODO: - AES-GCM stream
  380. # - AES-ARM
  381. # - Xilinx hardened crypto
  382. # - Intel AES-NI
  383. # - Intel ASM
  384. # - Intel RDRAND
  385. # - Linux af_alg
  386. # - Linux dev crpyto calls
  387. # - Camellia
  388. # - MD2
  389. # - NULL cipher
  390. # - RIPEMD
  391. # - BLAKE2
  392. add_option("WOLFSSL_AESCFB"
  393. "Enable wolfSSL AES-CFB support (default: disabled)"
  394. "no" "yes;no")
  395. # Align data
  396. add_option("WOLFSSL_ALIGN_DATA"
  397. "Align data for ciphers (default: enabled)"
  398. "yes" "yes;no")
  399. if(WOLFSSL_ALIGN_DATA)
  400. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_USE_ALIGN")
  401. endif()
  402. # SHA224
  403. set(SHA224_DEFAULT "no")
  404. if(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") OR
  405. ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
  406. if(NOT WOLFSSL_AFALG AND NOT WOLFSSL_DEVCRYPTO AND
  407. (NOT WOLFSSL_FIPS OR ("${FIPS_VERSION}" STREQUAL "v2")))
  408. set(SHA224_DEFAULT "yes")
  409. endif()
  410. endif()
  411. add_option("WOLFSSL_SHA224"
  412. "Enable wolfSSL SHA-224 support (default: enabled on x86_64/aarch64)"
  413. ${SHA224_DEFAULT} "yes;no")
  414. # SHA3
  415. set(SHA3_DEFAULT "no")
  416. if(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") OR
  417. ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
  418. if(NOT WOLFSSL_FIPS OR ("${FIPS_VERSION}" STREQUAL "v2"))
  419. set(SHA3_DEFAULT "yes")
  420. endif()
  421. endif()
  422. add_option("WOLFSSL_SHA3"
  423. "Enable wolfSSL SHA-3 support (default: enabled on x86_64/aarch64)"
  424. ${SHA3_DEFAULT} "yes;no;small")
  425. # SHAKE256
  426. add_option("WOLFSSL_SHAKE256"
  427. "Enable wolfSSL SHAKE256 support (default: enabled on x86_64/aarch64)"
  428. "no" "yes;no;small")
  429. # SHA512
  430. add_option("WOLFSSL_SHA512"
  431. "Enable wolfSSL SHA-512 support (default: enabled)"
  432. "yes" "yes;no")
  433. # options that don't require sha512
  434. if(WOLFSSL_LEAN_PSK OR
  435. WOLFSSL_LEAN_TLS OR
  436. WOLFSSL_32BIT OR
  437. WOLFSSL_16BIT)
  438. override_cache(WOLFSSL_SHA512 "no")
  439. endif()
  440. # options that require sha512
  441. if(WOLFSSL_OPENSSH OR
  442. WOLFSSL_WPAS OR
  443. WOLFSSL_FORTRESS)
  444. override_cache(WOLFSSL_SHA512 "yes")
  445. endif()
  446. if(WOLFSSL_SHA512)
  447. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHA512")
  448. endif()
  449. # SHA384
  450. add_option("WOLFSSL_SHA384"
  451. "Enable wolfSSL SHA-384 support (default: enabled)"
  452. "yes" "yes;no")
  453. # options that don't require sha384
  454. if(WOLFSSL_LEAN_PSK OR
  455. WOLFSSL_LEAN_TLS OR
  456. WOLFSSL_32BIT OR
  457. WOLFSSL_16BIT)
  458. override_cache(WOLFSSL_SHA384 "no")
  459. endif()
  460. # options that require sha384
  461. if(WOLFSSL_OPENSSH OR
  462. WOLFSSL_WPAS OR
  463. WOLFSSL_FORTRESS)
  464. override_cache(WOLFSSL_SHA384 "yes")
  465. endif()
  466. if(WOLFSSL_SHA384)
  467. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHA384")
  468. endif()
  469. # TODO: - Session certs
  470. # - SEP
  471. add_option("WOLFSSL_KEYGEN"
  472. "Enable key generation (default: disabled)])"
  473. "no" "yes;no")
  474. add_option("WOLFSSL_CERTGEN"
  475. "Enable cert generation (default: disabled)"
  476. "no" "yes;no")
  477. add_option("WOLFSSL_CERTREQ"
  478. "Enable cert request generation (default: disabled)"
  479. "no" "yes;no")
  480. add_option("WOLFSSL_CERTEXT"
  481. "Enable cert request extensions (default: disabled)"
  482. "no" "yes;no")
  483. add_option("WOLFSSL_CERTGENCACHE"
  484. "Enable decoded cert caching (default: disabled)"
  485. "no" "yes;no")
  486. # HKDF
  487. add_option("WOLFSSL_HKDF"
  488. "Enable HKDF (HMAC-KDF) support (default: disabled)"
  489. "no" "yes;no")
  490. if(WOLFSSL_TLS13)
  491. override_cache(WOLFSSL_HKDF "yes")
  492. endif()
  493. if(WOLFSSL_HKDF)
  494. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_HKDF")
  495. endif()
  496. # DSA
  497. add_option("WOLFSSL_DSA"
  498. "Enable DSA (default: disabled)"
  499. "no" "yes;no")
  500. if(NOT WOLFSSL_DSA AND NOT WOLFSSL_OPENSSH)
  501. list(APPEND WOLFSSL_DEFINITIONS "-DNO_DSA")
  502. endif()
  503. # ECC Shamir
  504. add_option("WOLFSSL_ECCSHAMIR"
  505. "Enable ECC Shamir (default: enabled)"
  506. "yes" "yes;no")
  507. # ECC
  508. add_option("WOLFSSL_ECC"
  509. "Enable ECC (default: enabled)"
  510. "yes" "yes;no;nonblock")
  511. # lean psk doesn't need ecc
  512. if(WOLFSSL_LEAN_PSK)
  513. override_cache(WOLFSSL_ECC "no")
  514. endif()
  515. if(WOLFSSL_OPENSSH OR
  516. WOLFSSL_NGINX OR
  517. WOLFSSL_SIGNAL)
  518. override_cache(WOLFSSL_ECC "yes")
  519. endif()
  520. if(WOLFSSL_ECC)
  521. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ECC" "-DTFM_ECC256")
  522. if(WOLFSSL_ECCSHAMIR AND NOT WOLFSSL_LOW_RESOURCE)
  523. list(APPEND WOLFSSL_DEFINITIONS "-DECC_SHAMIR")
  524. endif()
  525. if("${WOLFSSL_ECC}" STREQUAL "nonblock")
  526. list(APPEND WOLFSSL_DEFINITIONS "-DWC_ECC_NONBLOCK")
  527. endif()
  528. endif()
  529. # TODO: - ECC custom curves
  530. # - Compressed key
  531. # - FP ECC, fixed point cache ECC
  532. # - ECC encrypt
  533. # - PSK
  534. # - Single PSK identity
  535. # CURVE25519
  536. set(WOLFSSL_CURVE25519_SMALL "no")
  537. add_option("WOLFSSL_CURVE25519"
  538. "Enable Curve25519 (default: disabled)"
  539. "no" "yes;no;small;no128bit")
  540. if(WOLFSSL_OPENSSH)
  541. override_cache(WOLFSSL_CURVE25519 "yes")
  542. endif()
  543. if(WOLFSSL_CURVE25519)
  544. if("${WOLFSSL_CURVE25519}" STREQUAL "small" OR WOLFSSL_LOW_RESOURCE)
  545. list(APPEND WOLFSSL_DEFINITIONS "-DCURVE25519_SMALL")
  546. set(WOLFSSL_CURVE25519_SMALL "yes")
  547. endif()
  548. if("${WOLFSSL_CURVE25519}" STREQUAL "no128bit" OR WOLFSSL_32BIT)
  549. list(APPEND WOLFSSL_DEFINITIONS "-DNO_CURVED25519_128BIT")
  550. endif()
  551. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CURVE25519")
  552. set(WOLFSSL_FEMATH "yes")
  553. endif()
  554. # ED25519
  555. set(WOLFSSL_ED25519_SMALL "no")
  556. add_option("WOLFSSL_ED25519"
  557. "Enable ED25519 (default: disabled)"
  558. "no" "yes;no")
  559. if(WOLFSSL_OPENSSH)
  560. override_cache(WOLFSSL_ED25519 "yes")
  561. endif()
  562. if(WOLFSSL_ED25519 AND NOT WOLFSSL_32BIT)
  563. if("${WOLFSSL_ED25519}" STREQUAL "small" OR WOLFSSL_LOW_RESOURCE)
  564. list(APPEND WOLFSSL_DEFINITIONS "-DED25519_SMALL")
  565. set(WOLFSSL_ED25519_SMALL "yes")
  566. set(WOLFSSL_CURVE25519_SMALL "yes")
  567. endif()
  568. if(NOT WOLFSSL_SHA512)
  569. message(FATAL_ERROR "cannot enable ed25519 without enabling sha512.")
  570. endif()
  571. set(WOLFSSL_FEMATH "yes")
  572. set(WOLFSSL_GEMATH "yes")
  573. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ED25519")
  574. endif()
  575. # CURVE448
  576. set(WOLFSSL_CURVE448_SMALL "no")
  577. add_option("WOLFSSL_CURVE448"
  578. "Enable Curve448 (default: disabled)"
  579. "no" "yes;no;small")
  580. if(WOLFSSL_CURVE448)
  581. if("${WOLFSSL_CURVE448}" STREQUAL "small" OR WOLFSSL_LOW_RESOURCE)
  582. list(APPEND WOLFSSL_DEFINITIONS "-DCURVE448_SMALL")
  583. set(WOLFSSL_CURVE448_SMALL "yes")
  584. endif()
  585. if("${WOLFSSL_CURVE448}" STREQUAL "no128bit" OR WOLFSSL_32BIT)
  586. list(APPEND WOLFSSL_DEFINITIONS "-DNO_CURVED448_128BIT")
  587. endif()
  588. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CURVE448")
  589. set(WOLFSSL_FE448 "yes")
  590. endif()
  591. # ED448
  592. set(WOLFSSL_ED448_SMALL "no")
  593. add_option("WOLFSSL_ED448"
  594. "Enable ED448 (default: disabled)"
  595. "no" "yes;no;small")
  596. if(WOLFSSL_ED448 AND NOT WOLFSSL_32BIT)
  597. if("${WOLFSSL_ED448}" STREQUAL "small" OR WOLFSSL_LOW_RESOURCE)
  598. list(APPEND WOLFSSL_DEFINITIONS "-DED448_SMALL")
  599. set(WOLFSSL_ED448_SMALL "yes")
  600. set(WOLFSSL_CURVE448_SMALL "yes")
  601. endif()
  602. if(NOT WOLFSSL_SHA512)
  603. message(FATAL_ERROR "cannot enable ed448 without enabling sha512.")
  604. endif()
  605. set(WOLFSSL_FE448 "yes")
  606. set(WOLFSSL_GE448 "yes")
  607. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ED448")
  608. # EdDSA448 requires SHAKE256 which requires SHA-3
  609. override_cache(WOLFSSL_SHAKE256 "yes")
  610. endif()
  611. # Error strings
  612. add_option("WOLFSSL_ERROR_STRINGS"
  613. "Enable error strings table (default: enabled)"
  614. "yes" "yes;no")
  615. if(NOT WOLFSSL_ERROR_STRINGS)
  616. list(APPEND WOLFSSL_DEFINITIONS "-DNO_ERROR_STRINGS")
  617. else()
  618. # turn off error strings if leanpsk or leantls on
  619. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  620. list(APPEND WOLFSSL_DEFINITIONS "-DNO_ERROR_STRINGS")
  621. override_cache(WOLFSSL_ERROR_STRINGS "no")
  622. endif()
  623. endif()
  624. # Error queue
  625. add_option("WOLFSSL_ERROR_QUEUE"
  626. "Enables adding nodes to error queue when compiled with OPENSSL_EXTRA (default: enabled)"
  627. "yes" "yes;no")
  628. if(NOT WOLFSSL_ERROR_QUEUE)
  629. list(APPEND WOLFSSL_DEFINITIONS "-DNO_ERROR_QUEUE")
  630. endif()
  631. # Old TLS
  632. add_option("WOLFSSL_OLD_TLS"
  633. "Enable old TLS versions < 1.2 (default: enabled)"
  634. "yes" "yes;no")
  635. if(NOT WOLFSSL_OLD_TLS)
  636. list(APPEND WOLFSSL_DEFINITIONS "-DNO_OLD_TLS")
  637. else()
  638. # turn off old if leanpsk or leantls on
  639. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  640. list(APPEND WOLFSSL_DEFINITIONS "-DNO_OLD_TLS")
  641. override_cache(WOLFSSL_OLD_TLS "no")
  642. endif()
  643. endif()
  644. # TLSv1.2
  645. add_option("WOLFSSL_TLSV12"
  646. "Enable TLS versions 1.2 (default: enabled)"
  647. "yes" "yes;no")
  648. if(NOT WOLFSSL_TLSV12)
  649. list(APPEND WOLFSSL_DEFINITIONS
  650. "-DWOLFSSL_NO_TLS12"
  651. "-DNO_OLD_TLS")
  652. endif()
  653. # TODO: - TLSv1.0
  654. # - SSLv3
  655. # - Stack size
  656. # - Stack size verbose
  657. # Memory
  658. add_option("WOLFSSL_MEMORY"
  659. "Enable memory callbacks (default: enabled)"
  660. "yes" "yes;no")
  661. if(NOT WOLFSSL_MEMORY)
  662. list(APPEND WOLFSSL_DEFINITIONS "-DNO_WOLFSSL_MEMORY")
  663. else()
  664. # turn off memory cb if leanpsk or leantls on
  665. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  666. # but don't turn on NO_WOLFSSL_MEMORY because using own
  667. override_cache(WOLFSSL_MEMORY "no")
  668. endif()
  669. endif()
  670. # TODO: - Track memory
  671. # - Memory log
  672. # - Stack log
  673. # RSA
  674. add_option("WOLFSSL_RSA"
  675. "Enable RSA (default: enabled)"
  676. "yes" "yes;no")
  677. if(NOT WOLFSSL_RSA)
  678. list(APPEND WOLFSSL_DEFINITIONS "-DNO_RSA")
  679. else()
  680. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  681. list(APPEND WOLFSSL_DEFINITIONS "-DNO_RSA")
  682. override_cache(WOLFSSL_RSA "no")
  683. endif()
  684. endif()
  685. # OAEP
  686. add_option("WOLFSSL_OAEP"
  687. "Enable RSA OAEP (default: enabled)"
  688. "yes" "yes;no")
  689. if(NOT WOLFSSL_OAEP)
  690. list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_RSA_OAEP")
  691. endif()
  692. # TODO: - RSA public only
  693. # - RSA verify inline only
  694. # RSA-PSS
  695. add_option("WOLFSSL_RSA_PSS"
  696. "Enable RSA-PSS (default: disabled)"
  697. "no" "yes;no")
  698. if(NOT WOLFSSL_RSA)
  699. override_cache(WOLFSSL_RSA_PSS "no")
  700. else()
  701. if(WOLFSSL_TLS13)
  702. override_cache(WOLFSSL_RSA_PSS "yes")
  703. endif()
  704. endif()
  705. if(WOLFSSL_RSA_PSS)
  706. list(APPEND WOLFSSL_DEFINITIONS "-DWC_RSA_PSS")
  707. endif()
  708. # DH
  709. add_option("WOLFSSL_DH"
  710. "Enable DH (default: enabled)"
  711. "yes" "yes;no")
  712. if(WOLFSSL_OPENSSH)
  713. override_cache(WOLFSSL_DH "yes")
  714. endif()
  715. if(NOT WOLFSSL_DH)
  716. list(APPEND WOLFSSL_DEFINITIONS "-DNO_DH")
  717. else()
  718. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  719. list(APPEND WOLFSSL_DEFINITIONS "-DNO_DH")
  720. override_cache(WOLFSSL_DH "no")
  721. endif()
  722. endif()
  723. # TODO: - Anonymous
  724. # ASN
  725. # turn off asn, which means no certs, no rsa, no dsa, no ecc,
  726. # and no big int (unless dh is on)
  727. add_option("WOLFSSL_ASN"
  728. "Enable ASN (default: enabled)"
  729. "yes" "yes;no")
  730. if(NOT WOLFSSL_ASN)
  731. list(APPEND WOLFSSL_DEFINITIONS "-DNO_ASN" "-DNO_CERTS")
  732. if(NOT WOLFSSL_DH AND NOT WOLFSSL_ECC)
  733. # DH and ECC need bigint
  734. list(APPEND WOLFSSL_DEFINITIONS "-DNO_BIG_INT")
  735. endif()
  736. else()
  737. # turn off ASN if leanpsk on
  738. if(WOLFSSL_LEAN_PSK)
  739. list(APPEND WOLFSSL_DEFINITIONS
  740. "-DNO_ASN"
  741. "-DNO_CERTS"
  742. "-DNO_BIG_INT")
  743. override_cache(WOLFSSL_ASN "no")
  744. else()
  745. if("${WOLFSSL_ASN}" STREQUAL "nocrypt")
  746. list(APPEND WOLFSSL_DEFINITIONS "-DNO_ASN_CRYPT")
  747. # TODO: verify that this is correct
  748. override_cache(WOLFSSL_PWDBASED "no")
  749. endif()
  750. endif()
  751. endif()
  752. if(WOLFSSL_RSA AND NOT WOLFSSL_RSA_VFY AND NOT WOLFSSL_ASN)
  753. message(FATAL_ERROR "please disable rsa if disabling asn.")
  754. endif()
  755. if(WOLFSSL_DSA AND NOT WOLFSSL_ASN)
  756. message(FATAL_ERROR "please disable dsa if disabling asn.")
  757. endif()
  758. # DH and ECC need bigint
  759. if(NOT WOLFSSL_ASN AND
  760. NOT WOLFSSL_DH AND
  761. NOT WOLFSSL_ECC AND
  762. NOT WOLFSSL_RSA)
  763. override_cache(WOLFSSL_FAST_MATH "no")
  764. set(WOLFSSL_SLOWMATH "no")
  765. endif()
  766. # AES
  767. add_option("WOLFSSL_AES"
  768. "Enable AES (default: enabled)"
  769. "yes" "yes;no")
  770. if(NOT WOLFSSL_AES)
  771. list(APPEND WOLFSSL_DEFINITIONS "-DNO_AES")
  772. if(WOLFSSL_FORTRESS)
  773. message(FATAL_ERROR "fortress requires aes")
  774. endif()
  775. if(WOLFSSL_ECC_ENCRYPT)
  776. message(FATAL_ERROR "cannot enable eccencrypt and hkdf without aes.")
  777. endif()
  778. if(WOLFSSL_AESGCM)
  779. message(FATAL_ERROR "AESGCM requires AES.")
  780. endif()
  781. if(WOLFSSL_AESCCM)
  782. message(FATAL_ERROR "AESCCM requires AES.")
  783. endif()
  784. if(WOLFSSL_AESCTR)
  785. message(FATAL_ERROR "AESCTR requires AES.")
  786. endif()
  787. else()
  788. if(WOLFSSL_LEAN_PSK)
  789. list(APPEND WOLFSSL_DEFINITIONS "-DNO_AES")
  790. override_cache(WOLFSSL_AES "no")
  791. endif()
  792. endif()
  793. # Coding
  794. add_option("WOLFSSL_CODING"
  795. "Enable coding base 16/64 (default: enabled)"
  796. "yes" "yes;no")
  797. if(NOT WOLFSSL_CODING)
  798. list(APPEND WOLFSSL_DEFINITIONS "-DNO_CODING")
  799. else()
  800. # turn off CODING if leanpsk on
  801. if(WOLFSSL_LEAN_PSK)
  802. list(APPEND WOLFSSL_DEFINITIONS "-DNO_CODING")
  803. override_cache(WOLFSSL_CODING "no")
  804. endif()
  805. endif()
  806. # Base64
  807. set(BASE64_ENCODE_DEFAULT "no")
  808. if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
  809. set(BASE64_ENCODE_DEFAULT "yes")
  810. endif()
  811. set(WOLFSSL_BASE64_ENCODE_HELP_STRING "Enable Base64 encoding (default: enabled on x86_64)")
  812. add_option("WOLFSSL_BASE64_ENCODE" ${WOLFSSL_BASE64_ENCODE_HELP_STRING} ${BASE64_ENCODE_DEFAULT} "yes;no")
  813. if(WOLFSSL_BASE64_ENCODE)
  814. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_BASE64_ENCODE")
  815. endif()
  816. # TODO: - Base16
  817. # DES3
  818. set(WOLFSSL_DES3_HELP_STRING "Enable DES3 (default: disabled)")
  819. add_option("WOLFSSL_DES3" ${WOLFSSL_DES3_HELP_STRING} "no" "yes;no")
  820. if(WOLFSSL_OPENSSH OR
  821. WOLFSSL_QT OR
  822. WOLFSSL_OPENVPN OR
  823. WOLFSSL_WPAS)
  824. override_cache(WOLFSSL_DES3 "yes")
  825. endif()
  826. # ARC4
  827. set(WOLFSSL_ARC4_HELP_STRING "Enable ARC4 (default: disabled)")
  828. add_option("WOLFSSL_ARC4" ${WOLFSSL_ARC4_HELP_STRING} "no" "yes;no")
  829. if(WOLFSSL_OPENSSH OR WOLFSSL_WPAS)
  830. override_cache(WOLFSSL_ARC4 "yes")
  831. endif()
  832. # MD5
  833. set(WOLFSSL_MD5_HELP_STRING "Enable MD5 (default: enabled)")
  834. add_option("WOLFSSL_MD5" ${WOLFSSL_MD5_HELP_STRING} "yes" "yes;no")
  835. if(NOT WOLFSSL_MD5)
  836. list(APPEND WOLFSSL_DEFINITIONS "-DNO_MD5" "-DNO_OLD_TLS")
  837. else()
  838. # turn off MD5 if leanpsk or leantls on
  839. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  840. list(APPEND WOLFSSL_DEFINITIONS "-DNO_MD5" "-DNO_OLD_TLS")
  841. override_cache(WOLFSSL_MD5 "no")
  842. endif()
  843. endif()
  844. # SHA
  845. add_option("WOLFSSL_SHA"
  846. "Enable SHA (default: enabled)"
  847. "yes" "yes;no")
  848. if(NOT WOLFSSL_SHA)
  849. list(APPEND WOLFSSL_DEFINITIONS "-DNO_SHA" "-DNO_OLD_TLS")
  850. else()
  851. # turn off SHA if leanpsk or leantls on
  852. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  853. list(APPEND WOLFSSL_DEFINITIONS "-DNO_SHA" "-DNO_OLD_TLS")
  854. override_cache(WOLFSSL_SHA "no")
  855. endif()
  856. endif()
  857. # TODO: - AES-XTS
  858. # - Web server
  859. # - Web client
  860. add_option("WOLFSSL_CMAC"
  861. "Enable CMAC (default: disabled)"
  862. "no" "yes;no")
  863. if(WOLFSSL_WPAS OR
  864. WOLFSSL_NTP OR
  865. WOLFSSL_AESSIV)
  866. override_cache(WOLFSSL_CMAC "yes")
  867. endif()
  868. if(WOLFSSL_CMAC)
  869. if (NOT WOLFSSL_AES)
  870. message(FATAL_ERROR "Cannot use CMAC without AES.")
  871. else()
  872. list(APPEND WOLFSSL_DEFINITIONS
  873. "-DWOLFSSL_CMAC"
  874. "-DWOLFSSL_AES_DIRECT")
  875. endif()
  876. endif()
  877. # TODO: - RC2
  878. # - FIPS, again (there's more logic for FIPS in configure.ac)
  879. # - Selftest
  880. # SHA224
  881. if(WOLFSSL_SHA224)
  882. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHA224")
  883. endif()
  884. # SHA3
  885. if("${WOLFSSL_SHA3}" STREQUAL "small")
  886. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHA3_SMALL")
  887. override_cache(WOLFSSL_SHA3 "yes")
  888. endif()
  889. if(WOLFSSL_SHA3 AND NOT WOLFSSL_32BIT)
  890. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHA3")
  891. endif()
  892. # SHAKE256
  893. if(WOLFSSL_SHAKE256)
  894. if(NOT WOLFSSL_32BIT)
  895. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHAKE256")
  896. if(NOT WOLFSSL_SHA3)
  897. message(FATAL_ERROR "Must have SHA-3 enabled: --enable-sha3")
  898. endif()
  899. endif()
  900. endif()
  901. # POLY1305
  902. set(POLY1305_DEFAULT "yes")
  903. if(WOLFSSL_FIPS)
  904. set(POLY1305_DEFAULT "no")
  905. endif()
  906. set(WOLFSSL_POLY1305_HELP_STRING "Enable wolfSSL POLY1305 support (default: enabled)")
  907. add_option("WOLFSSL_POLY1305" ${WOLFSSL_POLY1305_HELP_STRING} ${POLY1305_DEFAULT} "yes;no")
  908. # leanpsk and leantls don't need poly1305
  909. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  910. override_cache(WOLFSSL_POLY1305 "no")
  911. endif()
  912. if(WOLFSSL_POLY1305)
  913. list(APPEND WOLFSSL_DEFINITIONS
  914. "-DHAVE_POLY1305"
  915. "-DHAVE_ONE_TIME_AUTH")
  916. endif()
  917. # CHACHA
  918. set(CHACHA_DEFAULT "yes")
  919. if(WOLFSSL_FIPS)
  920. set(CHACHA_DEFAULT "no")
  921. endif()
  922. add_option("WOLFSSL_CHACHA"
  923. "Enable CHACHA (default: enabled). Use `=noasm` to disable ASM AVX/AVX2 speedups"
  924. ${CHACHA_DEFAULT} "yes;no;noasm")
  925. # leanpsk and leantls don't need chacha
  926. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  927. override_cache(WOLFSSL_CHACHA "no")
  928. endif()
  929. if(("${WOLFSSL_CHACHA}" STREQUAL "noasm") OR NOT WOLFSSL_ASM)
  930. list(APPEND WOLFSSL_DEFINITIONS "-DNO_CHACHA_ASM")
  931. endif()
  932. if(NOT ("${WOLFSSL_CHACHA}" STREQUAL "noasm") AND WOLFSSL_CHACHA)
  933. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CHACHA")
  934. endif()
  935. # TODO: - XCHACHA
  936. # Hash DRBG
  937. add_option("WOLFSSL_HASH_DRBG"
  938. "Enable Hash DRBG support (default: enabled)"
  939. "yes" "yes;no")
  940. if(WOLFSSL_HASH_DRBG)
  941. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_HASHDRBG")
  942. else()
  943. # turn on Hash DRBG if FIPS is on
  944. if(WOLFSSL_FIPS)
  945. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_HASHDRBG")
  946. override_cache(WOLFSSL_HASH_DRBG "yes")
  947. else()
  948. list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_HASHDRBG")
  949. endif()
  950. endif()
  951. # Filesystem
  952. if(WOLFSSL_LINUX_KM)
  953. set(FILESYSTEM_DEFAULT "no")
  954. else()
  955. set(FILESYSTEM_DEFAULT "yes")
  956. endif()
  957. add_option("WOLFSSL_FILESYSTEM"
  958. "Enable Filesystem support (default: enabled)"
  959. ${FILESYSTEM_DEFAULT} "yes;no")
  960. if(NOT WOLFSSL_FILESYSTEM)
  961. list(APPEND WOLFSSL_DEFINITIONS "-DNO_FILESYSTEM")
  962. else()
  963. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  964. list(APPEND WOLFSSL_DEFINITIONS "-DNO_FILESYSTEM")
  965. override_cache(WOLFSSL_FILESYSTEM "no")
  966. endif()
  967. endif()
  968. # Inline function support
  969. add_option("WOLFSSL_INLINE"
  970. "Enable inline functions (default: enabled)"
  971. "yes" "yes;no")
  972. if(NOT WOLFSSL_INLINE)
  973. list(APPEND WOLFSSL_DEFINITIONS "-DNO_INLINE")
  974. endif()
  975. # TODO:
  976. # - CRL monitor
  977. # - User crypto
  978. # - Whitewood netRandom client library
  979. # - SNI
  980. # - Max fragment length
  981. # - ALPN
  982. # - Trusted CA indication
  983. # - Truncated HMAC
  984. # - Renegotiation indication
  985. # - Secure renegotiation
  986. # - Fallback SCSV
  987. add_option(WOLFSSL_OCSP "Enable OCSP (default: disabled)" "no" "yes;no")
  988. add_option(WOLFSSL_OCSPSTAPLING "Enable OCSP Stapling (default: disabled)" "no" "yes;no")
  989. add_option(WOLFSSL_OCSPSTAPLING_V2 "Enable OCSP Stapling v2 (default: disabled)" "no" "yes;no")
  990. add_option(WOLFSSL_CRL
  991. "Enable CRL (Use =io for inline CRL HTTP GET) (default: disabled)"
  992. "no" "yes;no;io")
  993. set(WOLFSSL_SNI_HELP_STRING "Enable SNI (default: disabled)")
  994. add_option(WOLFSSL_SNI ${WOLFSSL_SNI_HELP_STRING} "no" "yes;no")
  995. set(WOLFSSL_TLSX_HELP_STRING "Enable all TLS Extensions (default: disabled)")
  996. add_option(WOLFSSL_TLSX ${WOLFSSL_TLSX_HELP_STRING} "no" "yes;no")
  997. # Supported elliptic curves extensions
  998. add_option("WOLFSSL_SUPPORTED_CURVES"
  999. "Enable Supported Elliptic Curves (default: enabled)"
  1000. "yes" "yes;no")
  1001. if(WOLFSSL_SUPPORTED_CURVES)
  1002. if(NOT WOLFSSL_ECC AND NOT WOLFSSL_CURVE25519 AND NOT WOLFSSL_CURVE448)
  1003. override_cache(WOLFSSL_SUPPORTED_CURVES "no")
  1004. else()
  1005. list(APPEND WOLFSSL_DEFINITIONS
  1006. "-DHAVE_TLS_EXTENSIONS"
  1007. "-DHAVE_SUPPORTED_CURVES")
  1008. endif()
  1009. endif()
  1010. # Diffie-Hellman
  1011. if(WOLFSSL_DH)
  1012. if(WOLFSSL_TLS13 OR WOLFSSL_SUPPORTED_CURVES)
  1013. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_FFDHE_2048")
  1014. endif()
  1015. endif()
  1016. # TODO: - FFDHE params only
  1017. # TLS 1.3 Requires either ECC or (RSA/DH), or CURVE25519/ED25519 or CURVE448/ED448
  1018. if (NOT WOLFSSL_ECC AND
  1019. (NOT WOLFSSL_RSA OR NOT WOLFSSL_DH) AND
  1020. (NOT WOLFSSL_CURVE25519 OR NOT WOLFSSL_ED25519) AND
  1021. (NOT WOLFSSL_CURVE448 AND NOT WOLFSSL_ED448))
  1022. override_cache(WOLFSSL_TLS13 "no")
  1023. endif()
  1024. if (WOLFSSL_TLS13)
  1025. list(APPEND WOLFSSL_DEFINITIONS
  1026. "-DHAVE_SUPPORTED_CURVES"
  1027. "-DWOLFSSL_TLS13"
  1028. "-DHAVE_TLS_EXTENSIONS"
  1029. )
  1030. endif()
  1031. # Session Ticket Extension
  1032. add_option("WOLFSSL_SESSION_TICKET"
  1033. "Enable Session Ticket (default: disabled)"
  1034. "no" "yes;no")
  1035. if(WOLFSSL_NGINX OR WOLFSSL_WPAS OR WOLFSSL_HAPROXY OR WOLFSSL_LIGHTY)
  1036. override_cache(WOLFSSL_SESSION_TICKET "yes")
  1037. endif()
  1038. if(WOLFSSL_SESSION_TICKET)
  1039. list(APPEND WOLFSSL_DEFINITIONS
  1040. "-DHAVE_TLS_EXTENSIONS"
  1041. "-DHAVE_SESSION_TICKET")
  1042. endif()
  1043. # Extended master secret extension
  1044. add_option("WOLFSSL_EXTENDED_MASTER"
  1045. "Enable Extended Master Secret (default: enabled)"
  1046. "yes" "yes;no")
  1047. if(WOLFSSL_EXTENDED_MASTER)
  1048. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_EXTENDED_MASTER")
  1049. endif()
  1050. if(NOT WOLFSSL_ARC4)
  1051. list(APPEND WOLFSSL_DEFINITIONS "-DNO_RC4")
  1052. else()
  1053. # turn off ARC4 if leanpsk or leantls on
  1054. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  1055. list(APPEND WOLFSSL_DEFINITIONS "-DNO_RC4")
  1056. override_cache(WOLFSSL_ARC4 "no")
  1057. endif()
  1058. endif()
  1059. # TODO: - TLS extensions
  1060. # - Early data handshake
  1061. # - wolfSSH options
  1062. # - SCEP
  1063. # - Secure remote password
  1064. # - Indefinite length encoded messages
  1065. # - Small stack cache
  1066. # - Small stack
  1067. # - Valgrind
  1068. # - Test certs
  1069. # - I/O pool example
  1070. # - Certificate service
  1071. # - wolfSSL JNI
  1072. # - lighttpd/lighty
  1073. # - Asio
  1074. # - Apache HTTPD
  1075. set(WOLFSSL_PKCS7_HELP_STRING "Enable PKCS7 (default: disabled)")
  1076. add_option(WOLFSSL_PKCS7 ${WOLFSSL_PKCS7_HELP_STRING} "no" "yes;no")
  1077. set(WOLFSSL_TPM_HELP_STRING "Enable wolfTPM options (default: disabled)")
  1078. add_option(WOLFSSL_TPM ${WOLFSSL_TPM_HELP_STRING} "no" "yes;no")
  1079. set(WOLFSSL_AESKEYWRAP_HELP_STRING "Enable AES key wrap support (default: disabled)")
  1080. add_option(WOLFSSL_AESKEYWRAP ${WOLFSSL_AESKEYWRAP_HELP_STRING} "no" "yes;no")
  1081. set(WOLFSSL_X963KDF_HELP_STRING "Enable X9.63 KDF support (default: disabled)")
  1082. add_option(WOLFSSL_X963KDF ${WOLFSSL_X963KDF_HELP_STRING} "no" "yes;no")
  1083. # Encrypt-then-mac
  1084. add_option("WOLFSSL_ENC_THEN_MAC"
  1085. "Enable Encryptr-Then-Mac extension (default: enabled)"
  1086. "yes" "yes;no")
  1087. if(WOLFSSL_APACHE_HTTPD)
  1088. override_cache(WOLFSSL_ENC_THEN_MAC "no")
  1089. endif()
  1090. if(WOLFSSL_TLSX)
  1091. override_cache(WOLFSSL_ENC_THEN_MAC "yes")
  1092. endif()
  1093. if(WOLFSSL_SNIFFER)
  1094. override_cache(WOLFSSL_ENC_THEN_MAC "no")
  1095. endif()
  1096. # stunnel Support
  1097. # TODO: rest of stunnel support
  1098. add_option("WOLFSSL_STUNNEL"
  1099. "Enable stunnel (default: disabled)"
  1100. "no" "yes;no")
  1101. if(WOLFSSL_ENC_THEN_MAC)
  1102. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ENCRYPT_THEN_MAC")
  1103. endif()
  1104. if(NOT WOLFSSL_PSK AND
  1105. NOT WOLFSSL_LEAN_PSK AND
  1106. NOT WOLFSSL_STUNNEL)
  1107. list(APPEND WOLFSSL_DEFINITIONS "-DNO_PSK")
  1108. endif()
  1109. # MD4
  1110. set(WOLFSSL_MD4_HELP_STRING "Enable MD4 (default: disabled)")
  1111. add_option("WOLFSSL_MD4" ${WOLFSSL_MD4_HELP_STRING} "no" "yes;no")
  1112. if(NOT WOLFSSL_MD4)
  1113. # turn on MD4 if using stunnel
  1114. if(WOLFSSL_STUNNEL OR WOLFSSL_WPAS)
  1115. override_cache(WOLFSSL_MD4 "yes")
  1116. else()
  1117. list(APPEND WOLFSSL_DEFINITIONS "-DNO_MD4")
  1118. endif()
  1119. endif()
  1120. # Encrypted keys
  1121. add_option("WOLFSSL_ENCKEYS"
  1122. "Enable PEM encrypted key support (default: disabled)"
  1123. "no" "yes;no")
  1124. if(NOT WOLFSSL_ENCKEYS)
  1125. if(WOLFSSL_OPENSSLEXTRA OR
  1126. WOLFSSL_WEBSERVER OR
  1127. WOLFSSL_WPAS)
  1128. # opensslextra, webserver, and WPAS needs enckeys
  1129. override_cache(WOLFSSL_ENCKEYS "yes")
  1130. endif()
  1131. endif()
  1132. if(WOLFSSL_ENCKEYS)
  1133. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_ENCRYPTED_KEYS")
  1134. endif()
  1135. # PKCS#12
  1136. set(WOLFSSL_PKCS12_HELP_STRING "Enable pkcs12 (default: enabled)")
  1137. add_option("WOLFSSL_PKCS12" ${WOLFSSL_PKCS12_HELP_STRING} "yes" "yes;no")
  1138. if(NOT WOLFSSL_ASN)
  1139. override_cache(WOLFSSL_PKCS12 "no")
  1140. endif()
  1141. if(NOT WOLFSSL_PKCS12)
  1142. list(APPEND WOLFSSL_DEFINITIONS "-DNO_PKCS12")
  1143. endif()
  1144. # PWDBASED has to come after certservice since we want it on w/o explicit on
  1145. # PWDBASED
  1146. add_option("WOLFSSL_PWDBASED"
  1147. "Enable PWDBASED (default: disabled)"
  1148. "no" "yes;no")
  1149. if(NOT WOLFSSL_PWDBASED)
  1150. if(WOLFSSL_OPENSSLEXTRA OR
  1151. WOLFSSL_OPENSSLALL OR
  1152. WOLFSSL_WEBSERVER OR
  1153. WOLFSSL_ENC_KEYS OR
  1154. WOLFSSL_PKCS12)
  1155. # opensslextra, opensslall, webserver, and enckeys needs pwdbased
  1156. override_cache(WOLFSSL_PWDBASED "yes")
  1157. else()
  1158. list(APPEND WOLFSSL_DEFINITIONS "-DNO_PWDBASED")
  1159. endif()
  1160. endif()
  1161. # TODO: - SCRYPT
  1162. # - wolfCrypt only
  1163. # fastmath
  1164. set(FASTMATH_DEFAULT "no")
  1165. if(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") OR
  1166. ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
  1167. set(FASTMATH_DEFAULT "yes")
  1168. endif()
  1169. if(WOLFSSL_LINUXKM_DEFAULTS)
  1170. set(FASTMATH_DEFAULT "no")
  1171. endif()
  1172. if(WOLFSSL_SP_MATH)
  1173. set(FASTMATH_DEFAULT "no")
  1174. endif()
  1175. add_option("WOLFSSL_FAST_MATH"
  1176. "Enable fast math ops (default: enabled on x86_64/aarch64)"
  1177. ${FASTMATH_DEFAULT} "yes;no")
  1178. if(WOLFSSL_FAST_MATH)
  1179. # turn off fastmath if leanpsk on or asn off (w/o DH and ECC)
  1180. if(WOLFSSL_LEAN_PSK OR NOT WOLFSSL_ASN)
  1181. if(NOT WOLFSSL_DH AND
  1182. NOT WOLFSSL_ECC AND
  1183. NOT WOLFSSL_RSA)
  1184. override_cache(WOLFSSL_FAST_MATH "no")
  1185. else()
  1186. list(APPEND WOLFSSL_DEFINITIONS "-DUSE_FAST_MATH")
  1187. set(WOLFSSL_SLOWMATH "no")
  1188. endif()
  1189. else()
  1190. list(APPEND WOLFSSL_DEFINITIONS "-DUSE_FAST_MATH")
  1191. set(WOLFSSL_SLOWMATH "no")
  1192. endif()
  1193. if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
  1194. # Have settings.h set FP_MAX_BITS higher if user didn't set directly
  1195. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_X86_64_BUILD")
  1196. endif()
  1197. endif()
  1198. # TODO: - Fast huge math
  1199. # Enable examples, used to disable examples
  1200. if(WOLFSSL_LINUX_KM)
  1201. set(EXAMPLES_DEFAULT "no")
  1202. else()
  1203. set(EXAMPLES_DEFAULT "yes")
  1204. endif()
  1205. add_option("WOLFSSL_EXAMPLES"
  1206. "Enable examples (default: enabled)"
  1207. ${EXAMPLES_DEFAULT} "yes;no")
  1208. if(NOT WOLFSSL_FILESYSTEM OR
  1209. NOT WOLFSSL_INLINE OR
  1210. WOLFSSL_CRYPT_ONLY)
  1211. override_cache(WOLFSSL_EXAMPLES "no")
  1212. endif()
  1213. # Enable wolfCrypt test and benchmark
  1214. if(WOLFSSL_LINUX_KM)
  1215. set(CRYPT_TESTS_DEFAULT "no")
  1216. else()
  1217. set(CRYPT_TESTS_DEFAULT "yes")
  1218. endif()
  1219. add_option("WOLFSSL_CRYPT_TESTS"
  1220. "Enable Crypt Bench/Test (default: enabled)"
  1221. ${CRYPT_TESTS_DEFAULT} "yes;no")
  1222. add_option("WOLFSSL_CRYPT_TESTS_LIBS"
  1223. "Build static libraries from the wolfCrypt test and benchmark sources (default: disabled)"
  1224. "no" "yes;no")
  1225. # TODO: - LIBZ
  1226. # - PKCS#11
  1227. # - Cavium
  1228. # - Cavium V
  1229. # - Cavium Octeon
  1230. # - Intel QuickAssist
  1231. # - SP ASM (and other SP logic)
  1232. # - Fast RSA
  1233. # - Static memory use
  1234. # - Microchip API
  1235. # - Asynchronous crypto
  1236. # Asynchronous threading
  1237. add_option("WOLFSSL_ASYNC_THREADS"
  1238. "Enable Asynchronous Threading (default: enabled)"
  1239. "yes" "yes;no")
  1240. if(WOLFSSL_ASYNC_CRYPT AND WOLFSSL_ASYNC_THREADS)
  1241. if(CMAKE_USE_PTHREADS_INIT)
  1242. override_cache(WOLFSSL_ASYNC_THREADS "yes")
  1243. else()
  1244. override_cache(WOLFSSL_ASYNC_THREADS "no")
  1245. endif()
  1246. else()
  1247. override_cache(WOLFSSL_ASYNC_THREADS "no")
  1248. endif()
  1249. if(WOLFSSL_ASYNC_THREADS)
  1250. list(APPEND WOLFSSL_LINK_LIBS Threads::Threads)
  1251. list(APPEND WOLFSSL_DEFINITIONS "-D_GNU_SOURCE")
  1252. else()
  1253. list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_ASYNC_THREADING")
  1254. endif()
  1255. # TODO: - cryptodev
  1256. # - Session export
  1257. add_option("WOLFSSL_CRYPTOCB"
  1258. "Enable crypto callbacks (default: disabled)"
  1259. "no" "yes;no")
  1260. add_option("WOLFSSL_OLD_NAMES"
  1261. "Keep backwards compat with old names (default: enabled)"
  1262. "yes" "yes;no")
  1263. if(NOT WOLFSSL_OLD_NAMES AND NOT WOLFSSL_OPENSSL_COEXIST)
  1264. list(APPEND WOLFSSL_DEFINITIONS
  1265. "-DNO_OLD_RNGNAME"
  1266. "-DNO_OLD_WC_NAMES"
  1267. "-DNO_OLD_SSL_NAMES"
  1268. "-DNO_OLD_SHA_NAMES")
  1269. endif()
  1270. # TODO: - Memory tests
  1271. # - Hash flags
  1272. # Support for enabling setting default DH parameters
  1273. add_option("WOLFSSL_DH_DEFAULT_PARAMS"
  1274. "Enables option for default dh parameters (default: disabled)"
  1275. "no" "yes;no")
  1276. if(WOLFSSL_DH_DEFAULT_PARAMS OR NOT WOLFSSL_QT)
  1277. override_cache(WOLFSSL_DH_DEFAULT_PARAMS "yes")
  1278. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_DH_DEFAULT_PARAMS")
  1279. endif()
  1280. if(NOT WOLFSSL_DES3)
  1281. list(APPEND WOLFSSL_DEFINITIONS "-DNO_DES3")
  1282. else()
  1283. # turn off DES3 if leanpsk or leantls on
  1284. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  1285. list(APPEND WOLFSSL_DEFINITIONS "-DNO_DES3")
  1286. override_cache(WOLFSSL_DES3 "no")
  1287. endif()
  1288. endif()
  1289. add_option("WOLFSSL_USER_SETTINGS"
  1290. "Use your own user_settings.h and do not add Makefile CFLAGS (default: disabled)"
  1291. "no" "yes;no")
  1292. add_option("WOLFSSL_OPTFLAGS"
  1293. "Enable default optimization CFLAGS for the compiler (default: enabled)"
  1294. "yes" "yes;no")
  1295. # FLAGS operations
  1296. if(WOLFSSL_AESCCM)
  1297. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_AESCCM")
  1298. endif()
  1299. if(WOLFSSL_AESOFB)
  1300. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_AES_OFB" "-DWOLFSSL_AES_DIRECT")
  1301. endif()
  1302. if(WOLFSSL_TPM)
  1303. override_cache(WOLFSSL_KEYGEN "yes")
  1304. override_cache(WOLFSSL_CERTGEN "yes")
  1305. override_cache(WOLFSSL_CRYPTOCB "yes")
  1306. override_cache(WOLFSSL_CERTREQ "yes")
  1307. override_cache(WOLFSSL_CERTEXT "yes")
  1308. override_cache(WOLFSSL_PKCS7 "yes")
  1309. override_cache(WOLFSSL_AESCFB "yes")
  1310. endif()
  1311. if(WOLFSSL_AESCFB)
  1312. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_AES_CFB")
  1313. endif()
  1314. if(WOLFSSL_PKCS7)
  1315. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_PKCS7")
  1316. override_cache(WOLFSSL_AESKEYWRAP "yes")
  1317. # Enable prereqs if not already enabled
  1318. if(WOLFSSL_ECC)
  1319. override_cache(WOLFSSL_X963KDF "yes")
  1320. endif()
  1321. endif()
  1322. if(WOLFSSL_X963KDF)
  1323. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_X963_KDF")
  1324. endif()
  1325. if(WOLFSSL_AESKEYWRAP)
  1326. list(APPEND WOLFSSL_DEFINITIONS
  1327. "-DHAVE_AES_KEYWRAP"
  1328. "-DWOLFSSL_AES_DIRECT"
  1329. )
  1330. endif()
  1331. if(WOLFSSL_KEYGEN)
  1332. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_KEY_GEN")
  1333. endif()
  1334. if(WOLFSSL_CERTGEN)
  1335. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_CERT_GEN")
  1336. endif()
  1337. if(WOLFSSL_CERTREQ)
  1338. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_CERT_REQ")
  1339. endif()
  1340. if(WOLFSSL_CERTEXT)
  1341. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_CERT_EXT")
  1342. endif()
  1343. if(WOLFSSL_CERTGENCACHE)
  1344. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_CERT_GEN_CACHE")
  1345. endif()
  1346. if(WOLFSSL_CRYPTOCB)
  1347. list(APPEND WOLFSSL_DEFINITIONS "-DWOLF_CRYPTO_CB")
  1348. endif()
  1349. if(WOLFSSL_OCSPSTAPLING)
  1350. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CERTIFICATE_STATUS_REQUEST" "-DHAVE_TLS_EXTENSIONS")
  1351. override_cache(WOLFSSL_OCSP "yes")
  1352. endif()
  1353. if(WOLFSSL_OCSPSTAPLING_V2)
  1354. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CERTIFICATE_STATUS_REQUEST_V2" "-DHAVE_TLS_EXTENSIONS")
  1355. override_cache(WOLFSSL_OCSP "yes")
  1356. endif()
  1357. # must be below OCSP stapling options to allow override
  1358. if (WOLFSSL_OCSP)
  1359. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_OCSP")
  1360. endif()
  1361. if (WOLFSSL_CRL STREQUAL "yes")
  1362. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CRL")
  1363. elseif(WOLFSSL_CRL STREQUAL "io")
  1364. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CRL" "-DHAVE_CRL_IO")
  1365. endif()
  1366. if (WOLFSSL_SNI)
  1367. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_TLS_EXTENSIONS" "-DHAVE_SNI")
  1368. endif()
  1369. if (WOLFSSL_TLSX)
  1370. list(APPEND WOLFSSL_DEFINITIONS
  1371. "-DHAVE_TLS_EXTENSIONS"
  1372. "-DHAVE_SNI"
  1373. "-DHAVE_MAX_FRAGMENT"
  1374. "-DHAVE_TRUNCATED_HMAC"
  1375. "-DHAVE_ALPN"
  1376. "-DHAVE_TRUSTED_CA")
  1377. if (WOLFSSL_ECC OR WOLFSSL_CURVE25519 OR WOLFSSL_CURVE448 OR WOLFSSL_TLS13)
  1378. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_SUPPORTED_CURVES")
  1379. endif()
  1380. endif()
  1381. # Generates the BUILD_* flags. These control what source files are included in
  1382. # the library. A series of AM_CONDITIONALs handle this in configure.ac.
  1383. generate_build_flags()
  1384. # TODO: - Bit of logic after optimization flags option (above)
  1385. # - Check for build-type conflicts section
  1386. # USER SETTINGS
  1387. if(WOLFSSL_USER_SETTINGS)
  1388. # Replace all options and just use WOLFSSL_USER_SETTINGS
  1389. set(WOLFSSL_DEFINITIONS "-DWOLFSSL_USER_SETTINGS")
  1390. endif()
  1391. # TODO: Applying definitions to everything like this, rather than
  1392. # individual targets, is discouraged in CMake.
  1393. add_definitions(${WOLFSSL_DEFINITIONS})
  1394. add_option("WOLFSSL_CONFIG_H"
  1395. "Enable generation of config.h and define HAVE_CONFIG_H (default: enabled)"
  1396. "yes" "yes;no")
  1397. if(WOLFSSL_CONFIG_H)
  1398. add_definitions("-DHAVE_CONFIG_H")
  1399. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.in"
  1400. "${CMAKE_CURRENT_BINARY_DIR}/config.h" )
  1401. set(abs_top_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
  1402. set(abs_top_builddir ${CMAKE_CURRENT_BINARY_DIR})
  1403. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/wolfcrypt/test/test_paths.h.in"
  1404. "${CMAKE_CURRENT_BINARY_DIR}/wolfcrypt/test/test_paths.h" )
  1405. endif()
  1406. # Suppress some warnings about separate compilation, inlining
  1407. add_definitions("-DWOLFSSL_IGNORE_FILE_WARN")
  1408. # Generate user options header
  1409. message("Generating user options header...")
  1410. if (${CMAKE_DISABLE_SOURCE_CHANGES})
  1411. set(WOLFSSL_BUILD_OUT_OF_TREE_DEFAULT "${CMAKE_DISABLE_SOURCE_CHANGES}")
  1412. else()
  1413. set(WOLFSSL_BUILD_OUT_OF_TREE_DEFAULT "no")
  1414. endif()
  1415. add_option("WOLFSSL_BUILD_OUT_OF_TREE"
  1416. "Don't generate files in the source tree (default: ${WOLFSSL_BUILD_OUT_OF_TREE_DEFAULT})"
  1417. "${WOLFSSL_BUILD_OUT_OF_TREE_DEFAULT}" "yes;no")
  1418. if (${WOLFSSL_BUILD_OUT_OF_TREE})
  1419. set(WOLFSSL_OUTPUT_BASE ${CMAKE_CURRENT_BINARY_DIR})
  1420. else()
  1421. set(WOLFSSL_OUTPUT_BASE ${CMAKE_CURRENT_SOURCE_DIR})
  1422. endif()
  1423. set(OPTION_FILE "${WOLFSSL_OUTPUT_BASE}/wolfssl/options.h")
  1424. set(CYASSL_OPTION_FILE "${WOLFSSL_OUTPUT_BASE}/cyassl/options.h")
  1425. file(REMOVE ${OPTION_FILE})
  1426. file(APPEND ${OPTION_FILE} "/* wolfssl options.h\n")
  1427. file(APPEND ${OPTION_FILE} " * generated from configure options\n")
  1428. file(APPEND ${OPTION_FILE} " *\n")
  1429. file(APPEND ${OPTION_FILE} " * Copyright (C) 2006-2020 wolfSSL Inc.\n")
  1430. file(APPEND ${OPTION_FILE} " *\n")
  1431. file(APPEND ${OPTION_FILE} " * This file is part of wolfSSL. (formerly known as CyaSSL)\n")
  1432. file(APPEND ${OPTION_FILE} " *\n")
  1433. file(APPEND ${OPTION_FILE} " */\n\n")
  1434. file(APPEND ${OPTION_FILE} "#ifndef WOLFSSL_OPTIONS_H\n")
  1435. file(APPEND ${OPTION_FILE} "#define WOLFSSL_OPTIONS_H\n\n\n")
  1436. file(APPEND ${OPTION_FILE} "#ifdef __cplusplus\n")
  1437. file(APPEND ${OPTION_FILE} "extern \"C\" {\n")
  1438. file(APPEND ${OPTION_FILE} "#endif\n\n")
  1439. add_to_options_file("${WOLFSSL_DEFINITIONS}" "${OPTION_FILE}")
  1440. # CMAKE_C_FLAGS is just a string of space-separated flags to pass to the C
  1441. # compiler. We need to replace those spaces with semicolons in order to treat it
  1442. # as a CMake list.
  1443. string(REPLACE " " ";" CMAKE_C_FLAGS_LIST "${CMAKE_C_FLAGS}")
  1444. add_to_options_file("${CMAKE_C_FLAGS_LIST}" "${OPTION_FILE}")
  1445. file(APPEND ${OPTION_FILE} "\n#ifdef __cplusplus\n")
  1446. file(APPEND ${OPTION_FILE} "}\n")
  1447. file(APPEND ${OPTION_FILE} "#endif\n\n\n")
  1448. file(APPEND ${OPTION_FILE} "#endif /* WOLFSSL_OPTIONS_H */\n\n")
  1449. # backwards compatibility for those who have included options or version
  1450. file(REMOVE ${CYASSL_OPTION_FILE})
  1451. file(APPEND ${CYASSL_OPTION_FILE} "/* cyassl options.h\n")
  1452. file(APPEND ${CYASSL_OPTION_FILE} " * generated from wolfssl/options.h\n")
  1453. file(APPEND ${CYASSL_OPTION_FILE} " */\n")
  1454. file(READ ${OPTION_FILE} OPTION_FILE_CONTENTS)
  1455. file(APPEND ${CYASSL_OPTION_FILE} ${OPTION_FILE_CONTENTS})
  1456. ####################################################
  1457. # Library Target
  1458. ####################################################
  1459. # TODO: - Build shared/static libs based on enables. Check CMake
  1460. # global flag BUILD_SHARED_LIBS.
  1461. option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" ON)
  1462. set(LIB_SOURCES "")
  1463. # Generates a list of sources to include in the library.
  1464. # Corresponds to the instances of "src_libwolfssl_la_SOURCES += ..."
  1465. # in the *.am files.
  1466. generate_lib_src_list("${LIB_SOURCES}")
  1467. add_library(wolfssl ${LIB_SOURCES})
  1468. set_target_properties(wolfssl
  1469. PROPERTIES
  1470. SOVERSION ${LIBTOOL_SO_VERSION}
  1471. VERSION ${LIBTOOL_FULL_VERSION}
  1472. )
  1473. target_compile_definitions(wolfssl PRIVATE "BUILDING_WOLFSSL")
  1474. if(${BUILD_SHARED_LIBS})
  1475. target_compile_definitions(wolfssl PUBLIC "WOLFSSL_DLL")
  1476. endif()
  1477. ####################################################
  1478. # Include Directories
  1479. ####################################################
  1480. target_include_directories(wolfssl
  1481. PUBLIC
  1482. $<INSTALL_INTERFACE:include>
  1483. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
  1484. $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
  1485. )
  1486. ####################################################
  1487. # Link Libraries
  1488. ####################################################
  1489. target_link_libraries(wolfssl PUBLIC ${WOLFSSL_LINK_LIBS})
  1490. if(WIN32)
  1491. # For Windows link ws2_32
  1492. target_link_libraries(wolfssl PUBLIC
  1493. $<$<PLATFORM_ID:Windows>:ws2_32>)
  1494. else()
  1495. # DH requires math (m) library
  1496. target_link_libraries(wolfssl
  1497. PUBLIC
  1498. m)
  1499. endif()
  1500. ####################################################
  1501. # Tests and Examples
  1502. ####################################################
  1503. if(WOLFSSL_EXAMPLES)
  1504. # Build wolfSSL client example
  1505. add_executable(client
  1506. ${CMAKE_CURRENT_SOURCE_DIR}/examples/client/client.c)
  1507. target_link_libraries(client wolfssl)
  1508. set_property(TARGET client
  1509. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1510. ${WOLFSSL_OUTPUT_BASE}/examples/client)
  1511. # Build wolfSSL server example
  1512. add_executable(server
  1513. ${CMAKE_CURRENT_SOURCE_DIR}/examples/server/server.c)
  1514. target_link_libraries(server wolfssl)
  1515. set_property(TARGET server
  1516. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1517. ${WOLFSSL_OUTPUT_BASE}/examples/server)
  1518. # Build echo client example
  1519. add_executable(echoclient
  1520. ${CMAKE_CURRENT_SOURCE_DIR}/examples/echoclient/echoclient.c)
  1521. target_include_directories(echoclient PRIVATE
  1522. ${CMAKE_CURRENT_BINARY_DIR})
  1523. target_link_libraries(echoclient wolfssl)
  1524. set_property(TARGET echoclient
  1525. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1526. ${WOLFSSL_OUTPUT_BASE}/examples/echoclient)
  1527. # Build echo server example
  1528. add_executable(echoserver
  1529. ${CMAKE_CURRENT_SOURCE_DIR}/examples/echoserver/echoserver.c)
  1530. target_include_directories(echoserver PRIVATE
  1531. ${CMAKE_CURRENT_BINARY_DIR})
  1532. target_link_libraries(echoserver wolfssl)
  1533. set_property(TARGET echoserver
  1534. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1535. ${WOLFSSL_OUTPUT_BASE}/examples/echoserver)
  1536. if(NOT WIN32)
  1537. # Build TLS benchmark example
  1538. add_executable(tls_bench
  1539. ${CMAKE_CURRENT_SOURCE_DIR}/examples/benchmark/tls_bench.c)
  1540. target_link_libraries(tls_bench wolfssl)
  1541. target_link_libraries(tls_bench Threads::Threads)
  1542. set_property(TARGET tls_bench
  1543. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1544. ${WOLFSSL_OUTPUT_BASE}/examples/benchmark)
  1545. endif()
  1546. # Build unit tests
  1547. add_executable(unit_test
  1548. tests/api.c
  1549. tests/hash.c
  1550. tests/srp.c
  1551. tests/suites.c
  1552. tests/unit.c
  1553. examples/server/server.c
  1554. examples/client/client.c)
  1555. target_include_directories(unit_test PRIVATE
  1556. ${CMAKE_CURRENT_BINARY_DIR})
  1557. target_compile_options(unit_test PUBLIC "-DNO_MAIN_DRIVER")
  1558. target_link_libraries(unit_test wolfssl)
  1559. target_link_libraries(unit_test Threads::Threads)
  1560. set_property(TARGET unit_test
  1561. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1562. ${WOLFSSL_OUTPUT_BASE}/tests/)
  1563. set_property(TARGET unit_test
  1564. PROPERTY RUNTIME_OUTPUT_NAME
  1565. unit.test)
  1566. endif()
  1567. if(WOLFSSL_CRYPT_TESTS)
  1568. if(WOLFSSL_CRYPT_TESTS_LIBS)
  1569. # Build wolfCrypt test as a library. This will compile test.c and make
  1570. # its functions available as a CMake target that other CMake targets can
  1571. # pull in, in addition to producing the library itself. Note that this
  1572. # feature is not enabled by default, and the API of this library and
  1573. # wofcryptbench_lib should NOT be treated as stable.
  1574. add_library(wolfcrypttest_lib
  1575. ${CMAKE_CURRENT_SOURCE_DIR}/wolfcrypt/test/test.c)
  1576. set_target_properties(wolfcrypttest_lib PROPERTIES OUTPUT_NAME "wolfcrypttest")
  1577. target_link_libraries(wolfcrypttest_lib wolfssl)
  1578. target_compile_options(wolfcrypttest_lib PRIVATE "-DNO_MAIN_DRIVER")
  1579. # Make another library for the wolfCrypt benchmark code.
  1580. add_library(wolfcryptbench_lib
  1581. ${CMAKE_CURRENT_SOURCE_DIR}/wolfcrypt/benchmark/benchmark.c)
  1582. set_target_properties(wolfcryptbench_lib PROPERTIES OUTPUT_NAME "wolfcryptbench")
  1583. target_link_libraries(wolfcryptbench_lib wolfssl)
  1584. target_compile_options(wolfcryptbench_lib PRIVATE "-DNO_MAIN_DRIVER")
  1585. endif()
  1586. # Build wolfCrypt test executable.
  1587. add_executable(wolfcrypttest
  1588. ${CMAKE_CURRENT_SOURCE_DIR}/wolfcrypt/test/test.c)
  1589. target_link_libraries(wolfcrypttest wolfssl)
  1590. set_property(TARGET wolfcrypttest
  1591. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1592. ${WOLFSSL_OUTPUT_BASE}/wolfcrypt/test)
  1593. set_property(TARGET wolfcrypttest
  1594. PROPERTY RUNTIME_OUTPUT_NAME
  1595. testwolfcrypt)
  1596. # Build wolfCrypt benchmark executable.
  1597. add_executable(wolfcryptbench
  1598. ${CMAKE_CURRENT_SOURCE_DIR}/wolfcrypt/benchmark/benchmark.c)
  1599. target_include_directories(wolfcryptbench PRIVATE
  1600. ${CMAKE_CURRENT_BINARY_DIR})
  1601. target_link_libraries(wolfcryptbench wolfssl)
  1602. set_property(TARGET wolfcryptbench
  1603. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1604. ${WOLFSSL_OUTPUT_BASE}/wolfcrypt/benchmark)
  1605. set_property(TARGET wolfcryptbench
  1606. PROPERTY RUNTIME_OUTPUT_NAME
  1607. benchmark)
  1608. endif()
  1609. ####################################################
  1610. # Installation
  1611. ####################################################
  1612. include(GNUInstallDirs)
  1613. set(HEADER_EXCLUDE
  1614. "internal.h"
  1615. "cyassl/ctaocrypt/port"
  1616. "wolfssl/wolfcrypt/port/nrf51.h"
  1617. "wolfssl/wolfcrypt/port/arm"
  1618. "wolfssl/wolfcrypt/port/cypress"
  1619. "wolfssl/wolfcrypt/port/Espressif"
  1620. "wolfssl/wolfcrypt/port/iotsafe"
  1621. "wolfssl/wolfcrypt/port/nxp"
  1622. "wolfssl/wolfcrypt/port/pic"
  1623. "wolfssl/wolfcrypt/port/Renesas"
  1624. "wolfssl/wolfcrypt/port/silabs"
  1625. "wolfssl/wolfcrypt/port/st"
  1626. "wolfssl/wolfcrypt/port/ti"
  1627. "wolfssl/wolfcrypt/port/xilinx"
  1628. )
  1629. # TODO: add support for the various ports
  1630. # For distro build don't install options.h.
  1631. # It depends on the architecture and conflicts with Multi-Arch.
  1632. if(BUILD_DISTRO)
  1633. list(APPEND HEADER_EXCLUDE
  1634. "options.h")
  1635. endif()
  1636. if(NOT BUILD_CRYPTOAUTHLIB)
  1637. list(APPEND HEADER_EXCLUDE
  1638. "wolfssl/wolfcrypt/port/atmel")
  1639. endif()
  1640. if(NOT BUILD_AFALG)
  1641. list(APPEND HEADER_EXCLUDE
  1642. "wolfssl/wolfcrypt/port/af_alg")
  1643. endif()
  1644. if(NOT BUILD_KCAPI)
  1645. list(APPEND HEADER_EXCLUDE
  1646. "wolfssl/wolfcrypt/port/kcapi"
  1647. )
  1648. endif()
  1649. if(NOT BUILD_DEVCRYPTO)
  1650. list(APPEND HEADER_EXCLUDE
  1651. "wolfssl/wolfcrypt/port/devcrypto")
  1652. endif()
  1653. if(NOT BUILD_ASYNCCRYPT)
  1654. list(APPEND HEADER_EXCLUDE
  1655. "wolfssl/wolfcrypt/async.h")
  1656. endif()
  1657. if(NOT BUILD_PKCS11)
  1658. list(APPEND HEADER_EXCLUDE
  1659. "wolfssl/wolfcrypt/wc_pkcs11.h"
  1660. "wolfssl/wolfcrypt/pkcs11.h"
  1661. )
  1662. endif()
  1663. if(NOT BUILD_CAVIUM AND NOT BUILD_OCTEON_SYNC)
  1664. list(APPEND HEADER_EXCLUDE
  1665. "wolfssl/wolfcrypt/port/cavium")
  1666. else()
  1667. if(NOT BUILD_CAVIUM)
  1668. list(APPEND HEADER_EXCLUDE
  1669. "wolfssl/wolfcrypt/port/cavium/cavium_nitrox.h")
  1670. endif()
  1671. if(NOT BUILD_OCTEON_SYNC)
  1672. list(APPEND HEADER_EXCLUDE
  1673. "wolfssl/wolfcrypt/port/cavium/cavium_octeon_sync.h"
  1674. )
  1675. endif()
  1676. endif()
  1677. if(NOT BUILD_INTEL_QA AND NOT BUILD_INTEL_QA_SYNC)
  1678. list(APPEND HEADER_EXCLUDE
  1679. "wolfssl/wolfcrypt/port/intel")
  1680. else()
  1681. if(NOT BUILD_INTEL_QA)
  1682. list(APPEND HEADER_EXCLUDE
  1683. "wolfssl/wolfcrypt/port/intel/quickassist.h"
  1684. "wolfssl/wolfcrypt/port/intel/quickassist_mem.h"
  1685. )
  1686. endif()
  1687. if(NOT BUILD_INTEL_QA_SYNC)
  1688. list(APPEND HEADER_EXCLUDE
  1689. "wolfssl/wolfcrypt/port/intel/quickassist_sync.h")
  1690. endif()
  1691. endif()
  1692. if(NOT BUILD_SP)
  1693. list(APPEND HEADER_EXCLUDE
  1694. "wolfssl/wolfcrypt/sp.h"
  1695. "wolfssl/wolfcrypt/sp_int.h")
  1696. endif()
  1697. if(NOT BUILD_SELFTEST)
  1698. list(APPEND HEADER_EXCLUDE
  1699. "wolfssl/wolfcrypt/selftest.h")
  1700. endif()
  1701. if(NOT BUILD_FIPS OR BUILD_FIPS_V1)
  1702. list(APPEND HEADER_EXCLUDE
  1703. "wolfssl/wolfcrypt/fips.h")
  1704. endif()
  1705. if(NOT BUILD_QNXCAAM)
  1706. list(APPEND HEADER_EXCLUDE
  1707. "wolfssl/wolfcrypt/port/caam"
  1708. )
  1709. endif()
  1710. list(JOIN HEADER_EXCLUDE "|" EXCLUDED_HEADERS_REGEX)
  1711. string(PREPEND EXCLUDED_HEADERS_REGEX "(")
  1712. string(APPEND EXCLUDED_HEADERS_REGEX ")")
  1713. set(INSTALLED_EXAMPLES
  1714. ${CMAKE_CURRENT_SOURCE_DIR}/examples/echoserver/echoserver.c
  1715. ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-server.c
  1716. ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-client-dtls.c
  1717. ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-client.c
  1718. ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-server-dtls.c
  1719. ${CMAKE_CURRENT_SOURCE_DIR}/examples/echoclient/echoclient.c
  1720. ${CMAKE_CURRENT_SOURCE_DIR}/examples/server/server.c
  1721. ${CMAKE_CURRENT_SOURCE_DIR}/examples/benchmark/tls_bench.c
  1722. ${CMAKE_CURRENT_SOURCE_DIR}/examples/client/client.c)
  1723. # Install the library
  1724. install(TARGETS wolfssl
  1725. EXPORT wolfssl-targets
  1726. LIBRARY DESTINATION lib
  1727. ARCHIVE DESTINATION lib
  1728. RUNTIME DESTINATION bin
  1729. )
  1730. # Install the headers
  1731. install(DIRECTORY ${WOLFSSL_OUTPUT_BASE}/wolfssl/
  1732. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wolfssl
  1733. FILES_MATCHING PATTERN "*.h"
  1734. REGEX ${EXCLUDED_HEADERS_REGEX} EXCLUDE)
  1735. install(DIRECTORY ${WOLFSSL_OUTPUT_BASE}/cyassl/
  1736. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cyassl
  1737. FILES_MATCHING PATTERN "*.h"
  1738. REGEX ${EXCLUDED_HEADERS_REGEX} EXCLUDE)
  1739. install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/wolfssl/
  1740. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wolfssl
  1741. FILES_MATCHING PATTERN "*.h"
  1742. REGEX ${EXCLUDED_HEADERS_REGEX} EXCLUDE)
  1743. install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cyassl/
  1744. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cyassl
  1745. FILES_MATCHING PATTERN "*.h"
  1746. REGEX ${EXCLUDED_HEADERS_REGEX} EXCLUDE)
  1747. # Install the examples
  1748. install(FILES ${INSTALLED_EXAMPLES}
  1749. DESTINATION ${CMAKE_INSTALL_DOCDIR}/example)
  1750. # Install README.txt and taoCert.txt
  1751. install(FILES
  1752. ${CMAKE_CURRENT_SOURCE_DIR}/doc/README.txt
  1753. ${CMAKE_CURRENT_SOURCE_DIR}/certs/taoCert.txt
  1754. DESTINATION ${CMAKE_INSTALL_DOCDIR})
  1755. # Install the export set
  1756. install(EXPORT wolfssl-targets
  1757. DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/wolfssl
  1758. FILE wolfssl-config.cmake)
  1759. # TODO: Distro build + rules for what to include in the distro.
  1760. # See various include.am files.
  1761. set(prefix ${CMAKE_INSTALL_PREFIX})
  1762. set(exec_prefix "\${prefix}")
  1763. set(libdir "\${exec_prefix}/lib")
  1764. set(includedir "\${prefix}/include")
  1765. set(VERSION ${PROJECT_VERSION})
  1766. configure_file(support/wolfssl.pc.in ${CMAKE_CURRENT_BINARY_DIR}/support/wolfssl.pc @ONLY)
  1767. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/support/wolfssl.pc
  1768. DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)