Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

262 righe
5.7 KiB

  1. include_directories(../include)
  2. if(UNIX)
  3. if (${ARCH} STREQUAL "aarch64")
  4. # The "armx" Perl scripts look for "64" in the style argument
  5. # in order to decide whether to generate 32- or 64-bit asm.
  6. if (APPLE)
  7. set(PERLASM_STYLE ios64)
  8. else()
  9. set(PERLASM_STYLE linux64)
  10. endif()
  11. elseif (${ARCH} STREQUAL "arm")
  12. if (APPLE)
  13. set(PERLASM_STYLE ios32)
  14. else()
  15. set(PERLASM_STYLE linux32)
  16. endif()
  17. elseif (${ARCH} STREQUAL "ppc64le")
  18. set(PERLASM_STYLE ppc64le)
  19. else()
  20. if (${ARCH} STREQUAL "x86")
  21. set(PERLASM_FLAGS "-fPIC -DOPENSSL_IA32_SSE2")
  22. endif()
  23. if (APPLE)
  24. set(PERLASM_STYLE macosx)
  25. else()
  26. set(PERLASM_STYLE elf)
  27. endif()
  28. endif()
  29. set(ASM_EXT S)
  30. enable_language(ASM)
  31. set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
  32. # CMake does not add -isysroot and -arch flags to assembly.
  33. if (APPLE)
  34. set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -isysroot ${CMAKE_OSX_SYSROOT}")
  35. foreach(arch ${CMAKE_OSX_ARCHITECTURES})
  36. set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -arch ${arch}")
  37. endforeach()
  38. endif()
  39. else()
  40. if (CMAKE_CL_64)
  41. message("Using nasm")
  42. set(PERLASM_STYLE nasm)
  43. else()
  44. message("Using win32n")
  45. set(PERLASM_STYLE win32n)
  46. set(PERLASM_FLAGS "-DOPENSSL_IA32_SSE2")
  47. endif()
  48. # On Windows, we use the NASM output, specifically built with Yasm.
  49. set(ASM_EXT asm)
  50. enable_language(ASM_NASM)
  51. endif()
  52. function(perlasm dest src)
  53. add_custom_command(
  54. OUTPUT ${dest}
  55. COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${PERLASM_STYLE} ${PERLASM_FLAGS} ${ARGN} ${dest}
  56. DEPENDS
  57. ${src}
  58. ${PROJECT_SOURCE_DIR}/crypto/perlasm/arm-xlate.pl
  59. ${PROJECT_SOURCE_DIR}/crypto/perlasm/ppc-xlate.pl
  60. ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86_64-xlate.pl
  61. ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86asm.pl
  62. ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86gas.pl
  63. ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86masm.pl
  64. ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86nasm.pl
  65. WORKING_DIRECTORY .
  66. )
  67. endfunction()
  68. # Level 0.1 - depends on nothing outside this set.
  69. add_subdirectory(stack)
  70. add_subdirectory(lhash)
  71. add_subdirectory(err)
  72. add_subdirectory(buf)
  73. add_subdirectory(base64)
  74. add_subdirectory(bytestring)
  75. add_subdirectory(pool)
  76. # Level 0.2 - depends on nothing but itself
  77. add_subdirectory(modes)
  78. add_subdirectory(des)
  79. add_subdirectory(rc4)
  80. add_subdirectory(conf)
  81. add_subdirectory(chacha)
  82. add_subdirectory(poly1305)
  83. add_subdirectory(curve25519)
  84. # Level 1, depends only on 0.*
  85. add_subdirectory(digest_extra)
  86. add_subdirectory(cipher)
  87. add_subdirectory(rand)
  88. add_subdirectory(bio)
  89. add_subdirectory(bn)
  90. add_subdirectory(obj)
  91. add_subdirectory(asn1)
  92. # Level 2
  93. add_subdirectory(engine)
  94. add_subdirectory(dh)
  95. add_subdirectory(dsa)
  96. add_subdirectory(rsa)
  97. add_subdirectory(ec)
  98. add_subdirectory(ecdh)
  99. add_subdirectory(ecdsa)
  100. add_subdirectory(hmac_extra)
  101. # Level 3
  102. add_subdirectory(cmac)
  103. add_subdirectory(evp)
  104. add_subdirectory(hkdf)
  105. add_subdirectory(pem)
  106. add_subdirectory(x509)
  107. add_subdirectory(x509v3)
  108. # Level 4
  109. add_subdirectory(pkcs7)
  110. add_subdirectory(pkcs8)
  111. # Test support code
  112. add_subdirectory(test)
  113. add_subdirectory(fipsmodule)
  114. add_library(
  115. crypto_base
  116. OBJECT
  117. cpu-aarch64-linux.c
  118. cpu-arm.c
  119. cpu-arm-linux.c
  120. cpu-intel.c
  121. cpu-ppc64le.c
  122. crypto.c
  123. ex_data.c
  124. mem.c
  125. refcount_c11.c
  126. refcount_lock.c
  127. thread.c
  128. thread_none.c
  129. thread_pthread.c
  130. thread_win.c
  131. )
  132. if(FIPS)
  133. SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES EXTERNAL_OBJECT true)
  134. SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES GENERATED true)
  135. set(
  136. CRYPTO_FIPS_OBJECTS
  137. fipsmodule/bcm.o
  138. )
  139. endif()
  140. add_library(
  141. crypto
  142. $<TARGET_OBJECTS:crypto_base>
  143. $<TARGET_OBJECTS:stack>
  144. $<TARGET_OBJECTS:lhash>
  145. $<TARGET_OBJECTS:err>
  146. $<TARGET_OBJECTS:base64>
  147. $<TARGET_OBJECTS:bytestring>
  148. $<TARGET_OBJECTS:pool>
  149. $<TARGET_OBJECTS:fipsmodule>
  150. $<TARGET_OBJECTS:digest_extra>
  151. $<TARGET_OBJECTS:cipher>
  152. $<TARGET_OBJECTS:modes>
  153. $<TARGET_OBJECTS:des>
  154. $<TARGET_OBJECTS:rc4>
  155. $<TARGET_OBJECTS:conf>
  156. $<TARGET_OBJECTS:chacha>
  157. $<TARGET_OBJECTS:poly1305>
  158. $<TARGET_OBJECTS:curve25519>
  159. $<TARGET_OBJECTS:buf>
  160. $<TARGET_OBJECTS:bn>
  161. $<TARGET_OBJECTS:bio>
  162. $<TARGET_OBJECTS:rand>
  163. $<TARGET_OBJECTS:obj>
  164. $<TARGET_OBJECTS:asn1>
  165. $<TARGET_OBJECTS:engine>
  166. $<TARGET_OBJECTS:dh>
  167. $<TARGET_OBJECTS:dsa>
  168. $<TARGET_OBJECTS:rsa>
  169. $<TARGET_OBJECTS:ec>
  170. $<TARGET_OBJECTS:ecdh>
  171. $<TARGET_OBJECTS:ecdsa>
  172. $<TARGET_OBJECTS:cmac>
  173. $<TARGET_OBJECTS:evp>
  174. $<TARGET_OBJECTS:hkdf>
  175. $<TARGET_OBJECTS:pem>
  176. $<TARGET_OBJECTS:x509>
  177. $<TARGET_OBJECTS:x509v3>
  178. $<TARGET_OBJECTS:pkcs7>
  179. $<TARGET_OBJECTS:pkcs8_lib>
  180. ${CRYPTO_FIPS_OBJECTS}
  181. )
  182. if(FIPS)
  183. add_dependencies(crypto bcm_o_target)
  184. endif()
  185. SET_TARGET_PROPERTIES(crypto PROPERTIES LINKER_LANGUAGE C)
  186. if(NOT MSVC AND NOT ANDROID)
  187. target_link_libraries(crypto pthread)
  188. endif()
  189. add_executable(
  190. thread_test
  191. thread_test.c
  192. $<TARGET_OBJECTS:test_support>
  193. )
  194. target_link_libraries(thread_test crypto)
  195. add_dependencies(all_tests thread_test)
  196. add_executable(
  197. refcount_test
  198. refcount_test.cc
  199. )
  200. target_link_libraries(refcount_test crypto)
  201. add_dependencies(all_tests refcount_test)
  202. # TODO(davidben): Convert the remaining tests to GTest.
  203. add_executable(
  204. crypto_test
  205. asn1/asn1_test.cc
  206. base64/base64_test.cc
  207. bio/bio_test.cc
  208. bytestring/bytestring_test.cc
  209. chacha/chacha_test.cc
  210. constant_time_test.cc
  211. curve25519/x25519_test.cc
  212. dh/dh_test.cc
  213. dsa/dsa_test.cc
  214. ec/ec_test.cc
  215. err/err_test.cc
  216. evp/evp_extra_test.cc
  217. rand/ctrdrbg_test.cc
  218. rsa/rsa_test.cc
  219. $<TARGET_OBJECTS:gtest_main>
  220. $<TARGET_OBJECTS:test_support>
  221. )
  222. target_link_libraries(crypto_test crypto gtest)
  223. if (WIN32)
  224. target_link_libraries(crypto_test ws2_32)
  225. endif()
  226. add_dependencies(all_tests crypto_test)