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