Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 1 | include_directories(../include) |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 2 | |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 3 | if(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) |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 21 | else() |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 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() |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 30 | endif() |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 31 | set(ASM_EXT S) |
| 32 | enable_language(ASM) |
| 33 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack") |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 34 | |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 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() |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 39 | |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 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() |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 61 | endif() |
| 62 | |
| 63 | function(perlasm dest src) |
| 64 | add_custom_command( |
| 65 | OUTPUT ${dest} |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 66 | COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${PERLASM_STYLE} ${PERLASM_FLAGS} ${ARGN} ${dest} |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 67 | DEPENDS |
| 68 | ${src} |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 69 | ${PROJECT_SOURCE_DIR}/crypto/perlasm/arm-xlate.pl |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 70 | ${PROJECT_SOURCE_DIR}/crypto/perlasm/ppc-xlate.pl |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 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 | ) |
| 78 | endfunction() |
| 79 | |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 80 | # Level 0.1 - depends on nothing outside this set. |
| 81 | add_subdirectory(stack) |
| 82 | add_subdirectory(lhash) |
| 83 | add_subdirectory(err) |
| 84 | add_subdirectory(buf) |
| 85 | add_subdirectory(base64) |
| 86 | add_subdirectory(bytestring) |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 87 | add_subdirectory(pool) |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 88 | |
| 89 | # Level 0.2 - depends on nothing but itself |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 90 | add_subdirectory(rc4) |
| 91 | add_subdirectory(conf) |
| 92 | add_subdirectory(chacha) |
| 93 | add_subdirectory(poly1305) |
Adam Langley | 4139edb | 2016-01-13 15:00:54 -0800 | [diff] [blame] | 94 | add_subdirectory(curve25519) |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 95 | |
| 96 | # Level 1, depends only on 0.* |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 97 | add_subdirectory(digest_extra) |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 98 | add_subdirectory(cipher_extra) |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 99 | add_subdirectory(rand_extra) |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 100 | add_subdirectory(bio) |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 101 | add_subdirectory(bn_extra) |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 102 | add_subdirectory(obj) |
| 103 | add_subdirectory(asn1) |
| 104 | |
| 105 | # Level 2 |
| 106 | add_subdirectory(engine) |
| 107 | add_subdirectory(dh) |
| 108 | add_subdirectory(dsa) |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 109 | add_subdirectory(rsa_extra) |
| 110 | add_subdirectory(ec_extra) |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 111 | add_subdirectory(ecdh) |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 112 | add_subdirectory(ecdsa_extra) |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 113 | |
| 114 | # Level 3 |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 115 | add_subdirectory(cmac) |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 116 | add_subdirectory(evp) |
| 117 | add_subdirectory(hkdf) |
| 118 | add_subdirectory(pem) |
| 119 | add_subdirectory(x509) |
| 120 | add_subdirectory(x509v3) |
| 121 | |
| 122 | # Level 4 |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 123 | add_subdirectory(pkcs7) |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 124 | add_subdirectory(pkcs8) |
| 125 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 126 | # Test support code |
| 127 | add_subdirectory(test) |
| 128 | |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 129 | add_subdirectory(fipsmodule) |
| 130 | |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 131 | add_library( |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 132 | crypto_base |
| 133 | |
| 134 | OBJECT |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 135 | |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 136 | cpu-aarch64-linux.c |
| 137 | cpu-arm.c |
| 138 | cpu-arm-linux.c |
| 139 | cpu-intel.c |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 140 | cpu-ppc64le.c |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 141 | crypto.c |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 142 | ex_data.c |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 143 | mem.c |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 144 | refcount_c11.c |
| 145 | refcount_lock.c |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 146 | thread.c |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 147 | thread_none.c |
| 148 | thread_pthread.c |
| 149 | thread_win.c |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 150 | ) |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 151 | |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 152 | if(FIPS_DELOCATE) |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 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 | ) |
| 161 | endif() |
| 162 | |
| 163 | add_library( |
| 164 | crypto |
| 165 | |
| 166 | $<TARGET_OBJECTS:crypto_base> |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 167 | $<TARGET_OBJECTS:stack> |
| 168 | $<TARGET_OBJECTS:lhash> |
| 169 | $<TARGET_OBJECTS:err> |
| 170 | $<TARGET_OBJECTS:base64> |
| 171 | $<TARGET_OBJECTS:bytestring> |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 172 | $<TARGET_OBJECTS:pool> |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 173 | $<TARGET_OBJECTS:fipsmodule> |
| 174 | $<TARGET_OBJECTS:digest_extra> |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 175 | $<TARGET_OBJECTS:cipher_extra> |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 176 | $<TARGET_OBJECTS:rc4> |
| 177 | $<TARGET_OBJECTS:conf> |
| 178 | $<TARGET_OBJECTS:chacha> |
| 179 | $<TARGET_OBJECTS:poly1305> |
Adam Langley | 4139edb | 2016-01-13 15:00:54 -0800 | [diff] [blame] | 180 | $<TARGET_OBJECTS:curve25519> |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 181 | $<TARGET_OBJECTS:buf> |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 182 | $<TARGET_OBJECTS:bn_extra> |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 183 | $<TARGET_OBJECTS:bio> |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 184 | $<TARGET_OBJECTS:rand_extra> |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 185 | $<TARGET_OBJECTS:obj> |
| 186 | $<TARGET_OBJECTS:asn1> |
| 187 | $<TARGET_OBJECTS:engine> |
| 188 | $<TARGET_OBJECTS:dh> |
| 189 | $<TARGET_OBJECTS:dsa> |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 190 | $<TARGET_OBJECTS:rsa_extra> |
| 191 | $<TARGET_OBJECTS:ec_extra> |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 192 | $<TARGET_OBJECTS:ecdh> |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 193 | $<TARGET_OBJECTS:ecdsa_extra> |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 194 | $<TARGET_OBJECTS:cmac> |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 195 | $<TARGET_OBJECTS:evp> |
| 196 | $<TARGET_OBJECTS:hkdf> |
| 197 | $<TARGET_OBJECTS:pem> |
| 198 | $<TARGET_OBJECTS:x509> |
| 199 | $<TARGET_OBJECTS:x509v3> |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 200 | $<TARGET_OBJECTS:pkcs7> |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 201 | $<TARGET_OBJECTS:pkcs8_lib> |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 202 | |
| 203 | ${CRYPTO_FIPS_OBJECTS} |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 204 | ) |
| 205 | |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 206 | if(FIPS_DELOCATE) |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 207 | add_dependencies(crypto bcm_o_target) |
| 208 | endif() |
| 209 | |
| 210 | SET_TARGET_PROPERTIES(crypto PROPERTIES LINKER_LANGUAGE C) |
| 211 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 212 | if(NOT MSVC AND NOT ANDROID) |
| 213 | target_link_libraries(crypto pthread) |
| 214 | endif() |
| 215 | |
David Benjamin | f31229b | 2017-01-25 14:08:15 -0500 | [diff] [blame] | 216 | # TODO(davidben): Convert the remaining tests to GTest. |
| 217 | add_executable( |
| 218 | crypto_test |
| 219 | |
Robert Sloan | 8ecb7cd | 2017-03-21 09:39:01 -0700 | [diff] [blame] | 220 | asn1/asn1_test.cc |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 221 | base64/base64_test.cc |
Robert Sloan | 6d0d00e | 2017-03-27 07:13:07 -0700 | [diff] [blame] | 222 | bio/bio_test.cc |
Robert Sloan | 572a4e2 | 2017-04-17 10:52:19 -0700 | [diff] [blame] | 223 | bytestring/bytestring_test.cc |
Robert Sloan | a94fe05 | 2017-02-21 08:49:28 -0800 | [diff] [blame] | 224 | chacha/chacha_test.cc |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 225 | cipher_extra/aead_test.cc |
| 226 | cipher_extra/cipher_test.cc |
Robert Sloan | 2424d84 | 2017-05-01 07:46:28 -0700 | [diff] [blame] | 227 | cmac/cmac_test.cc |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 228 | compiler_test.cc |
Robert Sloan | 6d0d00e | 2017-03-27 07:13:07 -0700 | [diff] [blame] | 229 | constant_time_test.cc |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 230 | curve25519/ed25519_test.cc |
Robert Sloan | 2424d84 | 2017-05-01 07:46:28 -0700 | [diff] [blame] | 231 | curve25519/spake25519_test.cc |
Robert Sloan | 7d422bc | 2017-03-06 10:04:29 -0800 | [diff] [blame] | 232 | curve25519/x25519_test.cc |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 233 | ecdh/ecdh_test.cc |
David Benjamin | f31229b | 2017-01-25 14:08:15 -0500 | [diff] [blame] | 234 | dh/dh_test.cc |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 235 | digest_extra/digest_test.cc |
David Benjamin | f31229b | 2017-01-25 14:08:15 -0500 | [diff] [blame] | 236 | dsa/dsa_test.cc |
Robert Sloan | 5d62578 | 2017-02-13 09:55:39 -0800 | [diff] [blame] | 237 | err/err_test.cc |
Robert Sloan | 7d422bc | 2017-03-06 10:04:29 -0800 | [diff] [blame] | 238 | evp/evp_extra_test.cc |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 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 |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 248 | fipsmodule/rand/ctrdrbg_test.cc |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 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 |
David Benjamin | f31229b | 2017-01-25 14:08:15 -0500 | [diff] [blame] | 263 | |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 264 | $<TARGET_OBJECTS:crypto_test_data> |
David Benjamin | f31229b | 2017-01-25 14:08:15 -0500 | [diff] [blame] | 265 | $<TARGET_OBJECTS:gtest_main> |
| 266 | $<TARGET_OBJECTS:test_support> |
| 267 | ) |
| 268 | |
| 269 | target_link_libraries(crypto_test crypto gtest) |
Robert Sloan | 6d0d00e | 2017-03-27 07:13:07 -0700 | [diff] [blame] | 270 | if (WIN32) |
| 271 | target_link_libraries(crypto_test ws2_32) |
| 272 | endif() |
David Benjamin | f31229b | 2017-01-25 14:08:15 -0500 | [diff] [blame] | 273 | add_dependencies(all_tests crypto_test) |