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