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