CMakeLists.txt 71 KB

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