functions.cmake 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. function(override_cache VAR VAL)
  2. get_property(VAR_STRINGS CACHE ${VAR} PROPERTY STRINGS)
  3. LIST(FIND VAR_STRINGS ${VAL} CK)
  4. if(-1 EQUAL ${CK} AND DEFINED VAR_STRINGS)
  5. message(SEND_ERROR
  6. "\"${VAL}\" is not valid override value for \"${VAR}\"."
  7. " Please select value from \"${VAR_STRINGS}\"\n")
  8. endif()
  9. set_property(CACHE ${VAR} PROPERTY VALUE ${VAL})
  10. endfunction()
  11. function(add_option NAME HELP_STRING DEFAULT VALUES)
  12. if(VALUES STREQUAL "yes;no")
  13. # Set the default value for the option.
  14. set(${NAME} ${DEFAULT} CACHE BOOL ${HELP_STRING})
  15. else()
  16. # Set the default value for the option.
  17. set(${NAME} ${DEFAULT} CACHE STRING ${HELP_STRING})
  18. # Set the list of allowed values for the option.
  19. set_property(CACHE ${NAME} PROPERTY STRINGS ${VALUES})
  20. endif()
  21. if(DEFINED ${NAME})
  22. list(FIND VALUES ${${NAME}} IDX)
  23. #
  24. # If the given value isn't in the list of allowed values for the option,
  25. # reduce it to yes/no according to CMake's "if" logic:
  26. # https://cmake.org/cmake/help/latest/command/if.html#basic-expressions
  27. #
  28. # This has no functional impact; it just makes the settings in
  29. # CMakeCache.txt and cmake-gui easier to read.
  30. #
  31. if (${IDX} EQUAL -1)
  32. if(${${NAME}})
  33. override_cache(${NAME} "yes")
  34. else()
  35. override_cache(${NAME} "no")
  36. endif()
  37. endif()
  38. endif()
  39. endfunction()
  40. function(generate_build_flags)
  41. set(BUILD_DISTRO ${WOLFSSL_DISTRO} PARENT_SCOPE)
  42. set(BUILD_ALL ${WOLFSSL_ALL} PARENT_SCOPE)
  43. if(WOLFSSL_TLS13 OR WOLFSSL_USER_SETTINGS)
  44. set(BUILD_TLS13 "yes" PARENT_SCOPE)
  45. endif()
  46. if(WOLFSSL_DTLS13 OR WOLFSSL_USER_SETTINGS)
  47. set(BUILD_DTLS13 "yes" PARENT_SCOPE)
  48. endif()
  49. if(WOLFSSL_QUIC)
  50. set(BUILD_QUIC "yes" PARENT_SCOPE)
  51. endif()
  52. if(WOLFSSL_RNG OR WOLFSSL_USER_SETTINGS)
  53. set(BUILD_RNG "yes" PARENT_SCOPE)
  54. endif()
  55. if(WOLFSSL_SCTP OR WOLFSSL_USER_SETTINGS)
  56. set(BUILD_SCTP "yes" PARENT_SCOPE)
  57. endif()
  58. if(WOLFSSL_DTLS_CID OR WOLFSSL_USER_SETTINGS OR WOLFSSL_DTLS)
  59. set(BUILD_DTLS_COMMON "yes" PARENT_SCOPE)
  60. endif()
  61. set(BUILD_MCAST ${WOLFSSL_MCAST} PARENT_SCOPE)
  62. set(BUILD_IPV6 ${WOLFSSL_IPV6} PARENT_SCOPE)
  63. set(BUILD_LEAN_PSK ${WOLFSSL_LEAN_PSK} PARENT_SCOPE)
  64. set(BUILD_LEAN_TLS ${WOLFSSL_LEAN_TLS} PARENT_SCOPE)
  65. set(BUILD_LOWMEM ${WOLFSSL_LOWRESOURCE} PARENT_SCOPE)
  66. set(BUILD_PKCALLBACKS ${WOLFSSL_PKCALLBACKS} PARENT_SCOPE)
  67. set(BUILD_CRYPTOAUTHLIB ${WOLFSSL_CRYPTOAUTHLIB} PARENT_SCOPE)
  68. if(WOLFSSL_SNIFFER OR WOLFSSL_USER_SETTINGS)
  69. set(BUILD_SNIFFER "yes" PARENT_SCOPE)
  70. endif()
  71. set(BUILD_SNIFFTEST ${WOLFSSL_SNIFFTEST} PARENT_SCOPE)
  72. if(WOLFSSL_AESGCM OR WOLFSSL_USER_SETTINGS)
  73. set(BUILD_AESGCM "yes" PARENT_SCOPE)
  74. endif()
  75. if(WOLFSSL_AESCCM OR WOLFSSL_USER_SETTINGS)
  76. set(BUILD_AESCCM "yes" PARENT_SCOPE)
  77. endif()
  78. set(BUILD_ARMASM ${WOLFSSL_ARM_ASM} PARENT_SCOPE)
  79. set(BUILD_XILINX ${WOLFSSL_XILINX} PARENT_SCOPE)
  80. set(BUILD_AESNI ${WOLFSSL_AESNI} PARENT_SCOPE)
  81. set(BUILD_INTELASM ${WOLFSSL_INTEL_ASM} PARENT_SCOPE)
  82. set(BUILD_AFALG ${WOLFSSL_AFALG} PARENT_SCOPE)
  83. set(BUILD_DEVCRYPTO ${WOLFSSL_DEVCRYPTO} PARENT_SCOPE)
  84. if(WOLFSSL_CAMELLIA OR WOLFSSL_USER_SETTINGS)
  85. set(BUILD_CAMELLIA "yes" PARENT_SCOPE)
  86. endif()
  87. if(WOLFSSL_MD2 OR WOLFSSL_USER_SETTINGS)
  88. set(BUILD_MD2 "yes" PARENT_SCOPE)
  89. endif()
  90. if(WOLFSSL_RIPEMD OR WOLFSSL_USER_SETTINGS)
  91. set(BUILD_RIPEMD "yes" PARENT_SCOPE)
  92. endif()
  93. if(WOLFSSL_BLAKE2 OR WOLFSSL_USER_SETTINGS)
  94. set(BUILD_BLAKE2 "yes" PARENT_SCOPE)
  95. endif()
  96. if(WOLFSSL_BLAKE2S OR WOLFSSL_USER_SETTINGS)
  97. set(BUILD_BLAKE2S "yes" PARENT_SCOPE)
  98. endif()
  99. if(WOLFSSL_SHA512 OR WOLFSSL_SHA384 OR WOLFSSL_USER_SETTINGS)
  100. set(BUILD_SHA512 "yes" PARENT_SCOPE)
  101. endif()
  102. if(WOLFSSL_DSA OR WOLFSSL_USER_SETTINGS)
  103. set(BUILD_DSA "yes" PARENT_SCOPE)
  104. endif()
  105. if(WOLFSSL_ECC OR WOLFSSL_USER_SETTINGS)
  106. set(BUILD_ECC "yes" PARENT_SCOPE)
  107. endif()
  108. if(WOLFSSL_ED25519 OR WOLFSSL_USER_SETTINGS)
  109. set(BUILD_ED25519 "yes" PARENT_SCOPE)
  110. endif()
  111. set(BUILD_ED25519_SMALL ${WOLFSSL_ED25519_SMALL} PARENT_SCOPE)
  112. if(WOLFSSL_FEMATH OR WOLFSSL_USER_SETTINGS)
  113. set(BUILD_FEMATH "yes" PARENT_SCOPE)
  114. endif()
  115. if(WOLFSSL_GEMATH OR WOLFSSL_USER_SETTINGS)
  116. set(BUILD_GEMATH "yes" PARENT_SCOPE)
  117. endif()
  118. if(WOLFSSL_CURVE25519 OR WOLFSSL_USER_SETTINGS)
  119. set(BUILD_CURVE25519 "yes" PARENT_SCOPE)
  120. endif()
  121. set(BUILD_CURVE25519_SMALL ${WOLFSSL_CURVE25519_SMALL} PARENT_SCOPE)
  122. if(WOLFSSL_ED448 OR WOLFSSL_USER_SETTINGS)
  123. set(BUILD_ED448 "yes" PARENT_SCOPE)
  124. endif()
  125. set(BUILD_ED448_SMALL ${WOLFSSL_ED448_SMALL} PARENT_SCOPE)
  126. if(WOLFSSL_FE448 OR WOLFSSL_USER_SETTINGS)
  127. set(BUILD_FE448 "yes" PARENT_SCOPE)
  128. endif()
  129. if(WOLFSSL_GE448 OR WOLFSSL_USER_SETTINGS)
  130. set(BUILD_GE448 "yes" PARENT_SCOPE)
  131. endif()
  132. if(WOLFSSL_CURVE448 OR WOLFSSL_USER_SETTINGS)
  133. set(BUILD_CURVE448 "yes" PARENT_SCOPE)
  134. endif()
  135. if(WOLFSSL_CURVE448_SMALL OR WOLFSSL_USER_SETTINGS)
  136. set(BUILD_CURVE448_SMALL "yes" PARENT_SCOPE)
  137. endif()
  138. if(WOLFSSL_MEMORY OR WOLFSSL_USER_SETTINGS)
  139. set(BUILD_MEMORY "yes" PARENT_SCOPE)
  140. endif()
  141. if(WOLFSSL_RSA OR WOLFSSL_USER_SETTINGS)
  142. set(BUILD_RSA "yes" PARENT_SCOPE)
  143. endif()
  144. if(WOLFSSL_DH OR WOLFSSL_USER_SETTINGS)
  145. set(BUILD_DH "yes" PARENT_SCOPE)
  146. endif()
  147. if(WOLFSSL_ASN OR WOLFSSL_USER_SETTINGS)
  148. set(BUILD_ASN "yes" PARENT_SCOPE)
  149. endif()
  150. if(WOLFSSL_AES OR WOLFSSL_USER_SETTINGS)
  151. set(BUILD_AES "yes" PARENT_SCOPE)
  152. endif()
  153. if(WOLFSSL_CODING OR WOLFSSL_USER_SETTINGS)
  154. set(BUILD_CODING "yes" PARENT_SCOPE)
  155. endif()
  156. if(WOLFSSL_ARC4 OR WOLFSSL_USER_SETTINGS)
  157. set(BUILD_RC4 "yes" PARENT_SCOPE)
  158. endif()
  159. if(WOLFSSL_MD5 OR WOLFSSL_USER_SETTINGS)
  160. set(BUILD_MD5 "yes" PARENT_SCOPE)
  161. endif()
  162. if(WOLFSSL_SHA OR WOLFSSL_USER_SETTINGS)
  163. set(BUILD_SHA "yes" PARENT_SCOPE)
  164. endif()
  165. set(BUILD_FIPS ${WOLFSSL_FIPS} PARENT_SCOPE)
  166. if("${FIPS_VERSION}" STREQUAL "v1")
  167. set(BUILD_FIPS_V1 "yes" PARENT_SCOPE)
  168. endif()
  169. if("${FIPS_VERSION}" STREQUAL "v2")
  170. set(BUILD_FIPS_V2 "yes" PARENT_SCOPE)
  171. endif()
  172. if("${FIPS_VERSION}" STREQUAL "rand")
  173. set(BUILD_FIPS_RAND "yes" PARENT_SCOPE)
  174. endif()
  175. if("${FIPS_VERSION}" STREQUAL "v5")
  176. set(BUILD_FIPS_V5 "yes" PARENT_SCOPE)
  177. endif()
  178. set(BUILD_FIPS_READY ${FIPS_READY} PARENT_SCOPE)
  179. if(WOLFSSL_CMAC OR WOLFSSL_USER_SETTINGS)
  180. set(BUILD_CMAC "yes" PARENT_SCOPE)
  181. endif()
  182. set(BUILD_SELFTEST ${WOLFSSL_SELFTEST} PARENT_SCOPE)
  183. if(WOLFSSL_SHA224 OR WOLFSSL_USER_SETTINGS)
  184. set(BUILD_SHA224 "yes" PARENT_SCOPE)
  185. endif()
  186. if(WOLFSSL_SHA3 OR WOLFSSL_USER_SETTINGS)
  187. set(BUILD_SHA3 "yes" PARENT_SCOPE)
  188. endif()
  189. if(WOLFSSL_POLY1305 OR WOLFSSL_USER_SETTINGS)
  190. set(BUILD_POLY1305 "yes" PARENT_SCOPE)
  191. endif()
  192. if(WOLFSSL_CHACHA OR WOLFSSL_USER_SETTINGS)
  193. set(BUILD_CHACHA "yes" PARENT_SCOPE)
  194. endif()
  195. if(WOLFSSL_XCHACHA OR WOLFSSL_USER_SETTINGS)
  196. set(BUILD_XCHACHA "yes" PARENT_SCOPE)
  197. endif()
  198. if(WOLFSSL_KYBER OR WOLFSSL_USER_SETTINGS)
  199. set(BUILD_WC_KYBER "yes" PARENT_SCOPE)
  200. endif()
  201. if(WOLFSSL_OQS OR WOLFSSL_USER_SETTINGS)
  202. set(BUILD_FALCON "yes" PARENT_SCOPE)
  203. set(BUILD_SPHINCS "yes" PARENT_SCOPE)
  204. set(BUILD_DILITHIUM "yes" PARENT_SCOPE)
  205. set(BUILD_EXT_KYBER "yes" PARENT_SCOPE)
  206. set(BUILD_OQS_HELPER "yes" PARENT_SCOPE)
  207. endif()
  208. if(WOLFSSL_ARIA OR WOLFSSL_USER_SETTINGS)
  209. message(STATUS "ARIA functions.cmake found WOLFSSL_ARIA")
  210. # we cannot actually build, as we only have pre-compiled bin
  211. set(BUILD_ARIA "yes" PARENT_SCOPE)
  212. endif()
  213. set(BUILD_INLINE ${WOLFSSL_INLINE} PARENT_SCOPE)
  214. if(WOLFSSL_OCSP OR WOLFSSL_USER_SETTINGS)
  215. set(BUILD_OCSP "yes" PARENT_SCOPE)
  216. endif()
  217. set(BUILD_OCSP_STAPLING ${WOLFSSL_OCSPSTAPLING} PARENT_SCOPE)
  218. set(BUILD_OCSP_STAPLING_V2 ${WOLFSSL_OCSPSTAPLING_V2} PARENT_SCOPE)
  219. if(WOLFSSL_CRL OR WOLFSSL_USER_SETTINGS)
  220. set(BUILD_CRL "yes" PARENT_SCOPE)
  221. endif()
  222. if(WOLFSSL_CRL_MONITOR)
  223. set(BUILD_CRL_MONITOR "yes" PARENT_SCOPE)
  224. endif()
  225. set(BUILD_QUIC ${WOLFSSL_QUIC} PARENT_SCOPE)
  226. set(BUILD_WNR ${WOLFSSL_WNR} PARENT_SCOPE)
  227. if(WOLFSSL_SRP OR WOLFSSL_USER_SETTINGS)
  228. set(BUILD_SRP "yes" PARENT_SCOPE)
  229. endif()
  230. set(USE_VALGRIND ${WOLFSSL_VALGRIND})
  231. if(WOLFSSL_MD4 OR WOLFSSL_USER_SETTINGS)
  232. set(BUILD_MD4 "yes" PARENT_SCOPE)
  233. endif()
  234. if(WOLFSSL_PWDBASED OR WOLFSSL_USER_SETTINGS)
  235. set(BUILD_PWDBASED "yes" PARENT_SCOPE)
  236. endif()
  237. if(WOLFSSL_SCRYPT OR WOLFSSL_USER_SETTINGS)
  238. set(BUILD_SCRYPT "yes" PARENT_SCOPE)
  239. endif()
  240. if(WOLFSSL_CRYPT_ONLY AND NOT WOLFSSL_OPENSSL_EXTRA)
  241. set(BUILD_CRYPTONLY "yes" PARENT_SCOPE)
  242. endif()
  243. if(WOLFSSL_FAST_MATH OR WOLFSSL_USER_SETTINGS)
  244. set(BUILD_FAST_MATH "yes" PARENT_SCOPE)
  245. endif()
  246. if(WOLFSSL_SLOW_MATH OR WOLFSSL_USER_SETTINGS)
  247. set(BUILD_SLOW_MATH "yes" PARENT_SCOPE)
  248. endif()
  249. if(WOLFSSL_EXAMPLES AND NOT WOLFSSL_LEAN_TLS)
  250. set(BUILD_EXAMPLE_SERVERS "yes" PARENT_SCOPE)
  251. endif()
  252. set(BUILD_EXAMPLE_CLIENTS ${WOLFSSL_EXAMPLES} PARENT_SCOPE)
  253. set(BUILD_TESTS ${WOLFSSL_EXAMPLES} PARENT_SCOPE)
  254. if(NOT WOLFSSL_SINGLE_THREADED AND WOLFSSL_EXAMPLES AND NOT WOLFSSL_LEAN_TLS)
  255. set(BUILD_THREADED_EXAMPLES "yes" PARENT_SCOPE)
  256. endif()
  257. set(BUILD_WOLFCRYPT_TESTS ${WOLFSSL_CRYPT_TESTS} PARENT_SCOPE)
  258. set(BUILD_LIBZ ${WOLFSSL_LIBZ} PARENT_SCOPE)
  259. if(WOLFSSL_PKCS11 OR WOLFSSL_USER_SETTINGS)
  260. set(BUILD_PKCS11 "yes" PARENT_SCOPE)
  261. endif()
  262. if(WOLFSSL_PKCS12 OR WOLFSSL_USER_SETTINGS)
  263. set(BUILD_PKCS12 "yes" PARENT_SCOPE)
  264. endif()
  265. set(BUILD_CAVIUM ${WOLFSSL_CAVIUM} PARENT_SCOPE)
  266. set(BUILD_CAVIUM_V ${WOLFSSL_CAVIUM_V} PARENT_SCOPE)
  267. set(BUILD_OCTEON_SYNC ${WOLFSSL_OCTEON_SYNC} PARENT_SCOPE)
  268. set(BUILD_INTEL_QA ${WOLFSSL_INTEL_QA} PARENT_SCOPE)
  269. set(BUILD_INTEL_QA_SYNC ${WOLFSSL_INTEL_QA_SYNC} PARENT_SCOPE)
  270. if(WOLFSSL_SP OR WOLFSSL_USER_SETTINGS)
  271. set(BUILD_SP "yes" PARENT_SCOPE)
  272. endif()
  273. if((WOLFSSL_SP AND NOT WOLFSSL_SP_ASM) OR WOLFSSL_USER_SETTINGS)
  274. set(BUILD_SP_C "yes" PARENT_SCOPE)
  275. endif()
  276. if(WOLFSSL_SP_ARM64_ASM OR WOLFSSL_USER_SETTINGS)
  277. set(BUILD_SP_ARM64 "yes" PARENT_SCOPE)
  278. endif()
  279. if(WOLFSSL_SP_ARM32_ASM OR WOLFSSL_USER_SETTINGS)
  280. set(BUILD_SP_ARM32 "yes" PARENT_SCOPE)
  281. endif()
  282. if(WOLFSSL_SP_ARM_THUMB_ASM OR WOLFSSL_USER_SETTINGS)
  283. set(BUILD_SP_ARM_THUMB "yes" PARENT_SCOPE)
  284. endif()
  285. if(WOLFSSL_SP_ARM_CORTEX_ASM OR WOLFSSL_USER_SETTINGS)
  286. set(BUILD_SP_ARM_CORTEX "yes" PARENT_SCOPE)
  287. endif()
  288. if(WOLFSSL_X86_64_BUILD AND (WOLFSSL_SP_X86_64_ASM OR WOLFSSL_USER_SETTINGS))
  289. set(BUILD_SP_X86_64 "yes" PARENT_SCOPE)
  290. endif()
  291. if(WOLFSSL_SP_MATH OR WOLFSSL_SP_MATH_ALL OR WOLFSSL_USER_SETTINGS)
  292. set(BUILD_SP_INT "yes" PARENT_SCOPE)
  293. endif()
  294. set(BUILD_MCAPI ${WOLFSSL_MCAPI} PARENT_SCOPE)
  295. set(BUILD_ASYNCCRYPT ${WOLFSSL_ASYNCCRYPT} PARENT_SCOPE)
  296. set(BUILD_WOLFEVENT ${WOLFSSL_ASYNCCRYPT} PARENT_SCOPE)
  297. if(WOLFSSL_CRYPTOCB OR WOLFSSL_USER_SETTINGS)
  298. set(BUILD_CRYPTOCB "yes" PARENT_SCOPE)
  299. endif()
  300. set(BUILD_PSK ${WOLFSSL_PSK} PARENT_SCOPE)
  301. set(BUILD_TRUST_PEER_CERT ${WOLFSSL_TRUSTED_PEER_CERT} PARENT_SCOPE)
  302. set(BUILD_PKI ${WOLFSSL_PKI} PARENT_SCOPE)
  303. if(WOLFSSL_DES3 OR WOLFSSL_USER_SETTINGS)
  304. set(BUILD_DES3 "yes" PARENT_SCOPE)
  305. endif()
  306. if(WOLFSSL_PKCS7 OR WOLFSSL_USER_SETTINGS)
  307. set(BUILD_PKCS7 "yes" PARENT_SCOPE)
  308. endif()
  309. set(BUILD_HASHFLAGS ${WOLFSSL_HASHFLAGS} PARENT_SCOPE)
  310. set(BUILD_LINUX_KM ${WOLFSSL_LINUX_KM} PARENT_SCOPE)
  311. set(BUILD_NO_LIBRARY ${WOLFSSL_NO_LIBRARY} PARENT_SCOPE)
  312. if(WOLFSSL_DEBUG OR WOLFSSL_STACK_SIZE)
  313. set(BUILD_DEBUG "yes" PARENT_SCOPE)
  314. endif()
  315. set(BUILD_RC2 ${WOLFSSL_RC2} PARENT_SCOPE)
  316. if(WOLFSSL_CAAM)
  317. set(BUILD_CAAM "yes" PARENT_SCOPE)
  318. endif()
  319. if(WOLFSSL_HPKE OR WOLFSSL_USER_SETTINGS)
  320. set(BUILD_HPKE "yes" PARENT_SCOPE)
  321. endif()
  322. set(BUILD_FLAGS_GENERATED "yes" PARENT_SCOPE)
  323. endfunction()
  324. function(generate_lib_src_list LIB_SOURCES)
  325. if(NOT BUILD_FLAGS_GENERATED)
  326. message(FATAL_ERROR "Cannot call generate_lib_src_list without calling generate_build_flags first.")
  327. endif()
  328. # Corresponds to src/include.am
  329. if(BUILD_FIPS)
  330. if(BUILD_FIPS_V2)
  331. # FIPSv2 first file
  332. list(APPEND LIB_SOURCES wolfcrypt/src/wolfcrypt_first.c)
  333. list(APPEND LIB_SOURCES
  334. wolfcrypt/src/hmac.c
  335. wolfcrypt/src/random.c
  336. wolfcrypt/src/sha256.c)
  337. if(BUILD_RSA)
  338. list(APPEND LIB_SOURCES wolfcrypt/src/rsa.c)
  339. endif()
  340. if(BUILD_ECC)
  341. list(APPEND LIB_SOURCES wolfcrypt/src/ecc.c)
  342. endif()
  343. if(BUILD_AES)
  344. list(APPEND LIB_SOURCES wolfcrypt/src/aes.c)
  345. if(BUILD_ARMASM AND BUILD_FIPS_READY)
  346. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-aes.c)
  347. endif()
  348. endif()
  349. if(BUILD_AESNI)
  350. list(APPEND LIB_SOURCES wolfcrypt/src/aes_asm.S)
  351. if(BUILD_INTELASM)
  352. list(APPEND LIB_SOURCES wolfcrypt/src/aes_gcm_asm.S)
  353. endif()
  354. endif()
  355. if(BUILD_DES3)
  356. list(APPEND LIB_SOURCES wolfcrypt/src/des3.c)
  357. endif()
  358. if(BUILD_SHA)
  359. list(APPEND LIB_SOURCES wolfcrypt/src/sha.c)
  360. endif()
  361. if(BUILD_ARMASM AND BUILD_FIPS_READY)
  362. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-sha256.c)
  363. endif()
  364. if(BUILD_INTELASM)
  365. list(APPEND LIB_SOURCES wolfcrypt/src/sha256_asm.S)
  366. endif()
  367. if(BUILD_SHA512)
  368. list(APPEND LIB_SOURCES wolfcrypt/src/sha512.c)
  369. if(BUILD_ARMASM AND BUILD_FIPS_READY)
  370. list(APPEND LIB_SOURCES
  371. wolfcrypt/src/port/arm/armv8-sha512.c
  372. wolfcrypt/src/port/arm/armv8-sha512-asm.S
  373. wolfcrypt/src/port/arm/armv8-32-sha512-asm.S)
  374. endif()
  375. if(BUILD_INTELASM)
  376. list(APPEND LIB_SOURCES wolfcrypt/src/sha512_asm.S)
  377. endif()
  378. endif()
  379. if(BUILD_SHA3)
  380. list(APPEND LIB_SOURCES wolfcrypt/src/sha3.c)
  381. endif()
  382. if(BUILD_DH)
  383. list(APPEND LIB_SOURCES wolfcrypt/src/dh.c)
  384. endif()
  385. if(BUILD_CMAC)
  386. list(APPEND LIB_SOURCES wolfcrypt/src/cmac.c)
  387. endif()
  388. list(APPEND LIB_SOURCES
  389. wolfcrypt/src/fips.c
  390. wolfcrypt/src/fips_test.c)
  391. # fips last file
  392. list(APPEND LIB_SOURCES wolfcrypt/src/wolfcrypt_last.c)
  393. endif()
  394. if(BUILD_FIPS_V5)
  395. list(APPEND LIB_SOURCES wolfcrypt/src/wolfcrypt_first.c)
  396. list(APPEND LIB_SOURCES
  397. wolfcrypt/src/hmac.c
  398. wolfcrypt/src/random.c
  399. wolfcrypt/src/sha256.c)
  400. list(APPEND LIB_SOURCES
  401. wolfcrypt/src/kdf.c)
  402. if(BUILD_RSA)
  403. list(APPEND LIB_SOURCES wolfcrypt/src/rsa.c)
  404. endif()
  405. endif()
  406. if(BUILD_FIPS_RAND)
  407. list(APPEND LIB_SOURCES
  408. wolfcrypt/src/wolfcrypt_first.c
  409. wolfcrypt/src/hmac.c
  410. wolfcrypt/src/random.c
  411. wolfcrypt/src/sha256.c
  412. wolfcrypt/src/sha256_asm.S
  413. wolfcrypt/src/fips.c
  414. wolfcrypt/src/fips_test.c
  415. wolfcrypt/src/wolfcrypt_last.c)
  416. endif()
  417. endif()
  418. # For wolfRand, exclude everything else.
  419. if(NOT BUILD_FIPS_RAND)
  420. # For FIPSV2, exclude the wolfCrypt files included above.
  421. # For wolfRand, exclude just a couple files.
  422. # For old FIPS, keep the wolfCrypt versions of the
  423. # CtaoCrypt files included above.
  424. if(NOT BUILD_FIPS_V2)
  425. list(APPEND LIB_SOURCES wolfcrypt/src/hmac.c)
  426. endif()
  427. # CAVP self test
  428. if(BUILD_SELFTEST)
  429. list(APPEND LIB_SOURCES wolfcrypt/src/selftest.c)
  430. endif()
  431. endif()
  432. list(APPEND LIB_SOURCES
  433. wolfcrypt/src/hash.c
  434. wolfcrypt/src/cpuid.c)
  435. if(NOT BUILD_FIPS_RAND)
  436. if(NOT BUILD_FIPS_V5)
  437. list(APPEND LIB_SOURCES wolfcrypt/src/kdf.c)
  438. endif()
  439. if(NOT BUILD_FIPS_V2 AND BUILD_RNG)
  440. list(APPEND LIB_SOURCES wolfcrypt/src/random.c)
  441. endif()
  442. if(NOT BUILD_FIPS_V2)
  443. if(BUILD_ARMASM)
  444. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-sha256.c)
  445. else()
  446. list(APPEND LIB_SOURCES wolfcrypt/src/sha256.c)
  447. if(BUILD_INTELASM)
  448. list(APPEND LIB_SOURCES wolfcrypt/src/sha256_asm.S)
  449. endif()
  450. endif()
  451. endif()
  452. if(BUILD_AFALG)
  453. list(APPEND LIB_SOURCES wolfcrypt/src/port/af_alg/afalg_hash.c)
  454. endif()
  455. if(BUILD_WOLFEVENT)
  456. list(APPEND LIB_SOURCES wolfcrypt/src/wolfevent.c)
  457. endif()
  458. if(BUILD_ASYNCCRYPT)
  459. list(APPEND LIB_SOURCES wolfcrypt/src/async.c)
  460. endif()
  461. if(BUILD_RSA)
  462. if(NOT BUILD_FIPS_V2)
  463. list(APPEND LIB_SOURCES wolfcrypt/src/rsa.c)
  464. endif()
  465. endif()
  466. if(BUILD_SP)
  467. if(BUILD_SP_C)
  468. list(APPEND LIB_SOURCES
  469. wolfcrypt/src/sp_c32.c
  470. wolfcrypt/src/sp_c64.c)
  471. endif()
  472. if(BUILD_SP_X86_64)
  473. list(APPEND LIB_SOURCES wolfcrypt/src/sp_x86_64.c)
  474. if(WOLFSSL_X86_64_BUILD_ASM)
  475. list(APPEND LIB_SOURCES wolfcrypt/src/sp_x86_64_asm.S)
  476. endif()
  477. endif()
  478. if(NOT BUILD_FIPS_V2 AND BUILD_SP_ARM32)
  479. list(APPEND LIB_SOURCES wolfcrypt/src/sp_arm32.c)
  480. endif()
  481. if(BUILD_SP_ARM_THUMB)
  482. list(APPEND LIB_SOURCES wolfcrypt/src/sp_armthumb.c)
  483. endif()
  484. if(BUILD_SP_ARM64)
  485. list(APPEND LIB_SOURCES wolfcrypt/src/sp_arm64.c)
  486. endif()
  487. if(BUILD_SP_ARM_CORTEX)
  488. list(APPEND LIB_SOURCES wolfcrypt/src/sp_cortexm.c)
  489. endif()
  490. endif()
  491. if(BUILD_SP_INT)
  492. list(APPEND LIB_SOURCES wolfcrypt/src/sp_int.c)
  493. endif()
  494. if(NOT BUILD_FIPS_V2)
  495. if(BUILD_AES)
  496. list(APPEND LIB_SOURCES wolfcrypt/src/aes.c)
  497. if(BUILD_ARMASM)
  498. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-aes.c)
  499. endif()
  500. if(BUILD_AFALG)
  501. list(APPEND LIB_SOURCES wolfcrypt/src/port/af_alg/afalg_aes.c)
  502. endif()
  503. endif()
  504. endif()
  505. if(NOT BUILD_FIPS_V2 AND BUILD_CMAC)
  506. list(APPEND LIB_SOURCES wolfcrypt/src/cmac.c)
  507. endif()
  508. if(NOT BUILD_FIPS_V2 AND BUILD_DES3)
  509. list(APPEND LIB_SOURCES wolfcrypt/src/des3.c)
  510. endif()
  511. if(NOT BUILD_FIPS_V2 AND BUILD_SHA)
  512. list(APPEND LIB_SOURCES wolfcrypt/src/sha.c)
  513. endif()
  514. if(NOT BUILD_FIPS_V2 AND BUILD_SHA512)
  515. if(BUILD_ARMASM)
  516. list(APPEND LIB_SOURCES
  517. wolfcrypt/src/port/arm/armv8-sha512.c
  518. wolfcrypt/src/port/arm/armv8-sha512-asm.S
  519. wolfcrypt/src/port/arm/armv8-32-sha512-asm.S)
  520. else()
  521. list(APPEND LIB_SOURCES wolfcrypt/src/sha512.c)
  522. if(BUILD_INTELASM)
  523. list(APPEND LIB_SOURCES wolfcrypt/src/sha512_asm.S)
  524. endif()
  525. endif()
  526. endif()
  527. if(NOT BUILD_FIPS_V2 AND BUILD_SHA3)
  528. list(APPEND LIB_SOURCES wolfcrypt/src/sha3.c)
  529. endif()
  530. endif()
  531. list(APPEND LIB_SOURCES
  532. wolfcrypt/src/logging.c
  533. wolfcrypt/src/wc_port.c
  534. wolfcrypt/src/error.c)
  535. if(BUILD_OQS_HELPER)
  536. list(APPEND LIB_SOURCES
  537. wolfcrypt/src/port/liboqs/liboqs.c)
  538. endif()
  539. if(BUILD_ARIA)
  540. list(APPEND LIB_SOURCES
  541. wolfcrypt/src/port/aria/aria-crypt.c
  542. wolfcrypt/src/port/aria/aria-cryptocb.c)
  543. endif()
  544. if(NOT BUILD_FIPS_RAND)
  545. list(APPEND LIB_SOURCES
  546. wolfcrypt/src/wc_encrypt.c
  547. wolfcrypt/src/signature.c
  548. wolfcrypt/src/wolfmath.c)
  549. endif()
  550. if(BUILD_MEMORY)
  551. list(APPEND LIB_SOURCES wolfcrypt/src/memory.c)
  552. endif()
  553. if(NOT BUILD_FIPS_RAND)
  554. if(NOT BUILD_FIPS_V2 AND BUILD_DH)
  555. list(APPEND LIB_SOURCES wolfcrypt/src/dh.c)
  556. endif()
  557. if(BUILD_ASN)
  558. list(APPEND LIB_SOURCES wolfcrypt/src/asn.c)
  559. endif()
  560. endif()
  561. if(BUILD_CODING)
  562. list(APPEND LIB_SOURCES wolfcrypt/src/coding.c)
  563. endif()
  564. if(NOT BUILD_FIPS_RAND)
  565. if(BUILD_POLY1305)
  566. if(BUILD_ARMASM)
  567. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-poly1305.c)
  568. endif()
  569. list(APPEND LIB_SOURCES wolfcrypt/src/poly1305.c)
  570. if(BUILD_INTELASM)
  571. list(APPEND LIB_SOURCES wolfcrypt/src/poly1305_asm.S)
  572. endif()
  573. endif()
  574. if(BUILD_RC4)
  575. list(APPEND LIB_SOURCES wolfcrypt/src/arc4.c)
  576. endif()
  577. if(BUILD_MD4)
  578. list(APPEND LIB_SOURCES wolfcrypt/src/md4.c)
  579. endif()
  580. if(BUILD_MD5)
  581. list(APPEND LIB_SOURCES wolfcrypt/src/md5.c)
  582. endif()
  583. if(BUILD_PWDBASED)
  584. list(APPEND LIB_SOURCES
  585. wolfcrypt/src/pwdbased.c
  586. wolfcrypt/src/pkcs12.c)
  587. endif()
  588. if(BUILD_DSA)
  589. list(APPEND LIB_SOURCES wolfcrypt/src/dsa.c)
  590. endif()
  591. if(NOT BUILD_FIPS_V2 AND BUILD_AESNI)
  592. list(APPEND LIB_SOURCES
  593. wolfcrypt/src/aes_asm.S
  594. wolfcrypt/src/aes_gcm_asm.S)
  595. endif()
  596. if(BUILD_CAMELLIA)
  597. list(APPEND LIB_SOURCES wolfcrypt/src/camellia.c)
  598. endif()
  599. if(BUILD_MD2)
  600. list(APPEND LIB_SOURCES wolfcrypt/src/md2.c)
  601. endif()
  602. if(BUILD_RIPEMD)
  603. list(APPEND LIB_SOURCES wolfcrypt/src/ripemd.c)
  604. endif()
  605. if(BUILD_BLAKE2)
  606. list(APPEND LIB_SOURCES wolfcrypt/src/blake2b.c)
  607. endif()
  608. if(BUILD_BLAKE2S)
  609. list(APPEND LIB_SOURCES wolfcrypt/src/blake2s.c)
  610. endif()
  611. if(BUILD_CHACHA)
  612. if(BUILD_ARMASM)
  613. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-chacha.c)
  614. else()
  615. list(APPEND LIB_SOURCES wolfcrypt/src/chacha.c)
  616. if(BUILD_INTELASM)
  617. list(APPEND LIB_SOURCES wolfcrypt/src/chacha_asm.S)
  618. endif()
  619. endif()
  620. if(BUILD_POLY1305)
  621. list(APPEND LIB_SOURCES wolfcrypt/src/chacha20_poly1305.c)
  622. endif()
  623. endif()
  624. if(NOT BUILD_INLINE)
  625. list(APPEND LIB_SOURCES wolfcrypt/src/misc.c)
  626. endif()
  627. if(BUILD_FAST_MATH)
  628. list(APPEND LIB_SOURCES wolfcrypt/src/tfm.c)
  629. endif()
  630. if(BUILD_SLOW_MATH)
  631. list(APPEND LIB_SOURCES wolfcrypt/src/integer.c)
  632. endif()
  633. if(NOT BUILD_FIPS_V2 AND BUILD_ECC)
  634. list(APPEND LIB_SOURCES wolfcrypt/src/ecc.c)
  635. endif()
  636. if(BUILD_CURVE25519)
  637. list(APPEND LIB_SOURCES wolfcrypt/src/curve25519.c)
  638. endif()
  639. if(BUILD_ED25519)
  640. list(APPEND LIB_SOURCES wolfcrypt/src/ed25519.c)
  641. endif()
  642. if(BUILD_FEMATH)
  643. if(BUILD_CURVE25519_SMALL)
  644. list(APPEND LIB_SOURCES wolfcrypt/src/fe_low_mem.c)
  645. else()
  646. if(BUILD_INTELASM)
  647. list(APPEND LIB_SOURCES wolfcrypt/src/fe_x25519_asm.S)
  648. else()
  649. if(BUILD_ARMASM)
  650. list(APPEND LIB_SOURCES
  651. wolfcrypt/src/port/arm/armv8-32-curve25519.S
  652. wolfcrypt/src/port/arm/armv8-curve25519.S)
  653. else()
  654. list(APPEND LIB_SOURCES wolfcrypt/src/fe_operations.c)
  655. endif()
  656. endif()
  657. endif()
  658. endif()
  659. if(BUILD_GEMATH)
  660. if(BUILD_ED25519_SMALL)
  661. list(APPEND LIB_SOURCES wolfcrypt/src/ge_low_mem.c)
  662. else()
  663. list(APPEND LIB_SOURCES wolfcrypt/src/ge_operations.c)
  664. if(NOT BUILD_FEMATH)
  665. if(BUILD_INTELASM)
  666. list(APPEND LIB_SOURCES wolfcrypt/src/fe_x25519_asm.S)
  667. else()
  668. if(BUILD_ARMASM)
  669. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-curve25519.S)
  670. else()
  671. list(APPEND LIB_SOURCES wolfcrypt/src/fe_operations.c)
  672. endif()
  673. endif()
  674. endif()
  675. endif()
  676. endif()
  677. if(BUILD_CURVE448)
  678. list(APPEND LIB_SOURCES wolfcrypt/src/curve448.c)
  679. endif()
  680. if(BUILD_ED448)
  681. list(APPEND LIB_SOURCES wolfcrypt/src/ed448.c)
  682. endif()
  683. if(BUILD_FE448)
  684. list(APPEND LIB_SOURCES wolfcrypt/src/fe_448.c)
  685. endif()
  686. if(BUILD_GE448)
  687. list(APPEND LIB_SOURCES wolfcrypt/src/ge_448.c)
  688. if(NOT BUILD_FE448)
  689. list(APPEND LIB_SOURCES wolfcrypt/src/fe_448.c)
  690. endif()
  691. endif()
  692. if(BUILD_FALCON)
  693. list(APPEND LIB_SOURCES wolfcrypt/src/falcon.c)
  694. endif()
  695. if(BUILD_SPHINCS)
  696. list(APPEND LIB_SOURCES wolfcrypt/src/sphincs.c)
  697. endif()
  698. if(BUILD_DILITHIUM)
  699. list(APPEND LIB_SOURCES wolfcrypt/src/dilithium.c)
  700. endif()
  701. if(BUILD_WC_KYBER)
  702. list(APPEND LIB_SOURCES wolfcrypt/src/wc_kyber.c)
  703. list(APPEND LIB_SOURCES wolfcrypt/src/wc_kyber_poly.c)
  704. if(BUILD_INTELASM)
  705. list(APPEND LIB_SOURCES wolfcrypt/src/wc_kyber_asm.S)
  706. endif()
  707. endif()
  708. if(BUILD_EXT_KYBER)
  709. list(APPEND LIB_SOURCES wolfcrypt/src/ext_kyber.c)
  710. endif()
  711. if(BUILD_LIBZ)
  712. list(APPEND LIB_SOURCES wolfcrypt/src/compress.c)
  713. endif()
  714. if(BUILD_PKCS7)
  715. list(APPEND LIB_SOURCES wolfcrypt/src/pkcs7.c)
  716. endif()
  717. if(BUILD_SRP)
  718. list(APPEND LIB_SOURCES wolfcrypt/src/srp.c)
  719. endif()
  720. if(BUILD_AFALG)
  721. list(APPEND LIB_SOURCES wolfcrypt/src/port/af_alg/wc_afalg.c)
  722. endif()
  723. if(NOT BUILD_CRYPTONLY)
  724. # ssl files
  725. list(APPEND LIB_SOURCES
  726. src/internal.c
  727. src/wolfio.c
  728. src/keys.c
  729. src/ssl.c
  730. src/ocsp.c
  731. src/tls.c)
  732. if(BUILD_TLS13)
  733. list(APPEND LIB_SOURCES src/tls13.c)
  734. endif()
  735. if(BUILD_DTLS13)
  736. list(APPEND LIB_SOURCES src/dtls13.c)
  737. endif()
  738. if(BUILD_QUIC)
  739. list(APPEND LIB_SOURCES src/quic.c)
  740. endif()
  741. if(BUILD_OCSP)
  742. list(APPEND LIB_SOURCES src/ocsp.c)
  743. endif()
  744. if(BUILD_CRL)
  745. list(APPEND LIB_SOURCES src/crl.c)
  746. endif()
  747. if(BUILD_SNIFFER)
  748. list(APPEND LIB_SOURCES src/sniffer.c)
  749. endif()
  750. if(BUILD_DTLS_COMMON)
  751. list(APPEND LIB_SOURCES src/dtls.c)
  752. endif()
  753. if(BUILD_QUIC)
  754. list(APPEND LIB_SOURCES src/quic.c)
  755. endif()
  756. endif()
  757. endif()
  758. # Corresponds to wolfcrypt/src/include.am
  759. if(BUILD_CRYPTOCB)
  760. list(APPEND LIB_SOURCES wolfcrypt/src/cryptocb.c)
  761. endif()
  762. if(BUILD_PKCS11)
  763. list(APPEND LIB_SOURCES wolfcrypt/src/wc_pkcs11.c)
  764. endif()
  765. if(BUILD_DEVCRYPTO)
  766. list(APPEND LIB_SOURCES
  767. wolfcrypt/src/port/devcrypto/devcrypto_hash.c
  768. wolfcrypt/src/port/devcrypto/devcrypto_aes.c
  769. wolfcrypt/src/port/devcrypto/wc_devcrypto.c)
  770. endif()
  771. if(BUILD_CAVIUM)
  772. list(APPEND LIB_SOURCES wolfcrypt/src/port/cavium/cavium_nitrox.c)
  773. endif()
  774. if(BUILD_OCTEON_SYNC)
  775. list(APPEND LIB_SOURCES wolfcrypt/src/port/cavium/cavium_octeon_sync.c)
  776. endif()
  777. if(BUILD_INTEL_QA)
  778. list(APPEND LIB_SOURCES
  779. wolfcrypt/src/port/intel/quickassist.c
  780. wolfcrypt/src/port/intel/quickassist_mem.c)
  781. endif()
  782. if(BUILD_INTEL_QA_SYNC)
  783. list(APPEND LIB_SOURCES wolfcrypt/src/port/intel/quickassist_sync.c)
  784. endif()
  785. if(BUILD_CRYPTOAUTHLIB)
  786. list(APPEND LIB_SOURCES wolfcrypt/src/port/atmel/atmel.c)
  787. endif()
  788. if(BUILD_CAAM)
  789. list(APPEND LIB_SOURCES
  790. wolfcrypt/src/port/caam/wolfcaam_init.c
  791. wolfcrypt/src/port/caam/wolfcaam_qnx.c
  792. wolfcrypt/src/port/caam/wolfcaam_seco.c
  793. wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c
  794. wolfcrypt/src/port/caam/wolfcaam_x25519.c
  795. wolfcrypt/src/port/caam/wolfcaam_ecdsa.c
  796. wolfcrypt/src/port/caam/wolfcaam_cmac.c
  797. wolfcrypt/src/port/caam/wolfcaam_aes.c
  798. wolfcrypt/src/port/caam/wolfcaam_hash.c
  799. wolfcrypt/src/port/caam/wolfcaam_rsa.c
  800. wolfcrypt/src/port/caam/wolfcaam_hmac.c)
  801. endif()
  802. if(BUILD_HPKE)
  803. list(APPEND LIB_SOURCES wolfcrypt/src/hpke.c)
  804. endif()
  805. set(LIB_SOURCES ${LIB_SOURCES} PARENT_SCOPE)
  806. endfunction()
  807. # Function: set_wolfssl_definitions
  808. # Parameter: SEARCH_VALUE The string to search for. (e.g. "WOLFSSL_SHA3")
  809. # Returns: RESULT
  810. #
  811. # Searches WOLFSSL_DEFINITIONS for SEARCH_VALUE
  812. # Returns RESULT = 1 (true) if the search value is found
  813. #
  814. # Ensures setting is only added once and prints status messages.
  815. #
  816. # Also sets a parent (global in cmake file) variable by the same name to 1.
  817. #
  818. # See also get_wolfssl_definitions() for query-only.
  819. #
  820. function(set_wolfssl_definitions SEARCH_VALUE RESULT)
  821. if (${SEARCH_VALUE} STREQUAL "")
  822. message(FATAL_ERROR "Function set_wolfssl_definitions cannot have blank SEARCH_VALUE")
  823. endif()
  824. list(FIND WOLFSSL_DEFINITIONS "${SEARCH_VALUE}" pos)
  825. string(SUBSTRING "${SEARCH_VALUE}" 0 2 PREFIX_VALUE)
  826. if ("${PREFIX_VALUE}" STREQUAL "-D")
  827. message(FATAL_ERROR "Do not specify the -D prefix in set_wolfssl_definitions")
  828. endif()
  829. if(${pos} EQUAL -1)
  830. message(STATUS "${SEARCH_VALUE} not found in WOLFSSL_DEFINITIONS.")
  831. message(STATUS "Enabling ${SEARCH_VALUE}")
  832. list(APPEND WOLFSSL_DEFINITIONS "-D${SEARCH_VALUE}")
  833. set(${SEARCH_VALUE} 1 PARENT_SCOPE)
  834. # override_cache("${SEARCH_VALUE}" "yes") # Need to check that value is settable
  835. set(${RESULT} 1 PARENT_SCOPE)
  836. message(STATUS "Enabling ${SEARCH_VALUE} - success")
  837. else()
  838. message(STATUS "${SEARCH_VALUE} found in WOLFSSL_DEFINITIONS.")
  839. set(${RESULT} 0 PARENT_SCOPE)
  840. endif()
  841. endfunction()
  842. # Function: get_wolfssl_definitions
  843. # Parameter: SEARCH_VALUE The string to search for. (e.g. "WOLFSSL_SHA3")
  844. # Returns: RESULT
  845. #
  846. # Searches WOLFSSL_DEFINITIONS for SEARCH_VALUE
  847. # Returns RESULT = 1 (true) if the search value is found
  848. #
  849. # Unlike set_wolfssl_definitions(), this function only queries the WOLFSSL_DEFINITIONS.
  850. #
  851. function(get_wolfssl_definitions SEARCH_VALUE RESULT)
  852. if (${SEARCH_VALUE} STREQUAL "")
  853. message(FATAL_ERROR "Function get_wolfssl_definitions cannot have blank SEARCH_VALUE")
  854. endif()
  855. list(FIND WOLFSSL_DEFINITIONS "${SEARCH_VALUE}" pos)
  856. string(SUBSTRING "${SEARCH_VALUE}" 0 2 PREFIX_VALUE)
  857. if ("${PREFIX_VALUE}" STREQUAL "-D")
  858. message(FATAL_ERROR "Do not specify the -D prefix in get_wolfssl_definitions")
  859. endif()
  860. if(${pos} EQUAL -1)
  861. message(STATUS "${SEARCH_VALUE} not found in WOLFSSL_DEFINITIONS.")
  862. else()
  863. message(STATUS "${SEARCH_VALUE} found in WOLFSSL_DEFINITIONS.")
  864. endif()
  865. endfunction()