Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 1 | option(USE_STATIC_MBEDTLS_LIBRARY "Build mbed TLS static library." ON) |
| 2 | option(USE_SHARED_MBEDTLS_LIBRARY "Build mbed TLS shared library." OFF) |
Manuel Pégourié-Gonnard | cfa9a45 | 2015-01-23 13:33:31 +0000 | [diff] [blame] | 3 | option(LINK_WITH_PTHREAD "Explicitly link mbed TLS library to pthread." OFF) |
Paul Bakker | 9d3a7e4 | 2011-01-05 15:24:43 +0000 | [diff] [blame] | 4 | |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 5 | set(src_crypto |
| 6 | aes.c |
| 7 | aesni.c |
| 8 | arc4.c |
Markku-Juhani O. Saarinen | 3c0b53b | 2017-11-30 16:00:34 +0000 | [diff] [blame] | 9 | aria.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 10 | asn1parse.c |
| 11 | asn1write.c |
| 12 | base64.c |
| 13 | bignum.c |
| 14 | blowfish.c |
| 15 | camellia.c |
| 16 | ccm.c |
Daniel King | 34b822c | 2016-05-15 17:28:08 -0300 | [diff] [blame] | 17 | chacha20.c |
Manuel Pégourié-Gonnard | dca3a5d | 2018-05-07 10:43:27 +0200 | [diff] [blame] | 18 | chachapoly.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 19 | cipher.c |
| 20 | cipher_wrap.c |
Robert Cragie | dc5c7b9 | 2015-12-11 15:49:45 +0000 | [diff] [blame] | 21 | cmac.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 22 | ctr_drbg.c |
| 23 | des.c |
| 24 | dhm.c |
| 25 | ecdh.c |
| 26 | ecdsa.c |
Manuel Pégourié-Gonnard | 4d8685b | 2015-08-05 15:44:42 +0200 | [diff] [blame] | 27 | ecjpake.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 28 | ecp.c |
| 29 | ecp_curves.c |
| 30 | entropy.c |
| 31 | entropy_poll.c |
| 32 | error.c |
| 33 | gcm.c |
| 34 | havege.c |
Thomas Fossati | 656864b | 2016-07-17 08:51:22 +0100 | [diff] [blame] | 35 | hkdf.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 36 | hmac_drbg.c |
| 37 | md.c |
| 38 | md2.c |
| 39 | md4.c |
| 40 | md5.c |
| 41 | md_wrap.c |
| 42 | memory_buffer_alloc.c |
Ron Eldor | cb349ac | 2018-07-15 09:29:47 +0300 | [diff] [blame] | 43 | nist_kw.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 44 | oid.c |
| 45 | padlock.c |
| 46 | pem.c |
| 47 | pk.c |
| 48 | pk_wrap.c |
| 49 | pkcs12.c |
| 50 | pkcs5.c |
| 51 | pkparse.c |
| 52 | pkwrite.c |
| 53 | platform.c |
Andres Amaya Garcia | bc7bdbf | 2018-04-24 08:29:20 -0500 | [diff] [blame] | 54 | platform_util.c |
Daniel King | adc32c0 | 2016-05-16 18:25:45 -0300 | [diff] [blame] | 55 | poly1305.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 56 | ripemd160.c |
| 57 | rsa.c |
Hanno Becker | a565f54 | 2017-10-11 11:00:19 +0100 | [diff] [blame] | 58 | rsa_internal.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 59 | sha1.c |
| 60 | sha256.c |
| 61 | sha512.c |
| 62 | threading.c |
Manuel Pégourié-Gonnard | 21dcc1e | 2015-06-25 10:59:15 +0200 | [diff] [blame] | 63 | timing.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 64 | version.c |
| 65 | version_features.c |
| 66 | xtea.c |
| 67 | ) |
| 68 | |
| 69 | set(src_x509 |
| 70 | certs.c |
| 71 | pkcs11.c |
| 72 | x509.c |
| 73 | x509_create.c |
| 74 | x509_crl.c |
| 75 | x509_crt.c |
| 76 | x509_csr.c |
| 77 | x509write_crt.c |
| 78 | x509write_csr.c |
| 79 | ) |
| 80 | |
| 81 | set(src_tls |
| 82 | debug.c |
Andres AG | 788aa4a | 2016-09-14 14:32:09 +0100 | [diff] [blame] | 83 | net_sockets.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 84 | ssl_cache.c |
| 85 | ssl_ciphersuites.c |
| 86 | ssl_cli.c |
| 87 | ssl_cookie.c |
| 88 | ssl_srv.c |
| 89 | ssl_ticket.c |
| 90 | ssl_tls.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 91 | ) |
| 92 | |
Paul Bakker | 76f0311 | 2013-11-28 17:20:04 +0100 | [diff] [blame] | 93 | if(CMAKE_COMPILER_IS_GNUCC) |
Manuel Pégourié-Gonnard | 216a183 | 2015-06-25 09:20:03 +0200 | [diff] [blame] | 94 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes") |
Paul Bakker | 76f0311 | 2013-11-28 17:20:04 +0100 | [diff] [blame] | 95 | endif(CMAKE_COMPILER_IS_GNUCC) |
| 96 | |
Manuel Pégourié-Gonnard | 3185545 | 2014-06-25 15:59:50 +0200 | [diff] [blame] | 97 | if(CMAKE_COMPILER_IS_CLANG) |
Manuel Pégourié-Gonnard | 216a183 | 2015-06-25 09:20:03 +0200 | [diff] [blame] | 98 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes -Wdocumentation -Wno-documentation-deprecated-sync -Wunreachable-code") |
Manuel Pégourié-Gonnard | 3185545 | 2014-06-25 15:59:50 +0200 | [diff] [blame] | 99 | endif(CMAKE_COMPILER_IS_CLANG) |
| 100 | |
Gilles Peskine | 5fa32a7 | 2019-01-06 19:48:30 +0000 | [diff] [blame] | 101 | if(UNSAFE_BUILD) |
| 102 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error") |
| 103 | set(CMAKE_C_FLAGS_ASAN "${CMAKE_C_FLAGS_ASAN} -Wno-error") |
| 104 | set(CMAKE_C_FLAGS_ASANDBG "${CMAKE_C_FLAGS_ASANDBG} -Wno-error") |
| 105 | endif(UNSAFE_BUILD) |
| 106 | |
Manuel Pégourié-Gonnard | ba2c876 | 2015-06-25 09:35:46 +0200 | [diff] [blame] | 107 | if(WIN32) |
| 108 | set(libs ${libs} ws2_32) |
| 109 | endif(WIN32) |
| 110 | |
Andres Amaya Garcia | bf7fe4f | 2018-06-21 20:21:38 +0100 | [diff] [blame] | 111 | if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
TabascoEye | 7f3ef27 | 2018-04-27 13:14:59 +0200 | [diff] [blame] | 112 | SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>") |
| 113 | SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>") |
| 114 | SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>") |
| 115 | SET(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>") |
Andres Amaya Garcia | bf7fe4f | 2018-06-21 20:21:38 +0100 | [diff] [blame] | 116 | endif() |
TabascoEye | 7f3ef27 | 2018-04-27 13:14:59 +0200 | [diff] [blame] | 117 | |
Augustin Cavalier | 60bc47d | 2018-04-11 20:27:32 -0400 | [diff] [blame] | 118 | if(HAIKU) |
Simon Butcher | 6331cb0 | 2018-07-10 11:48:42 +0100 | [diff] [blame] | 119 | set(libs ${libs} network) |
Augustin Cavalier | 60bc47d | 2018-04-11 20:27:32 -0400 | [diff] [blame] | 120 | endif(HAIKU) |
| 121 | |
Manuel Pégourié-Gonnard | ba2c876 | 2015-06-25 09:35:46 +0200 | [diff] [blame] | 122 | if(USE_PKCS11_HELPER_LIBRARY) |
| 123 | set(libs ${libs} pkcs11-helper) |
| 124 | endif(USE_PKCS11_HELPER_LIBRARY) |
| 125 | |
| 126 | if(ENABLE_ZLIB_SUPPORT) |
| 127 | set(libs ${libs} ${ZLIB_LIBRARIES}) |
| 128 | endif(ENABLE_ZLIB_SUPPORT) |
| 129 | |
| 130 | if(LINK_WITH_PTHREAD) |
| 131 | set(libs ${libs} pthread) |
| 132 | endif() |
| 133 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 134 | if (NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY) |
Manuel Pégourié-Gonnard | 216a183 | 2015-06-25 09:20:03 +0200 | [diff] [blame] | 135 | message(FATAL_ERROR "Need to choose static or shared mbedtls build!") |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 136 | endif(NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY) |
Paul Bakker | 9d3a7e4 | 2011-01-05 15:24:43 +0000 | [diff] [blame] | 137 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 138 | if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) |
Manuel Pégourié-Gonnard | 216a183 | 2015-06-25 09:20:03 +0200 | [diff] [blame] | 139 | set(mbedtls_static_target "mbedtls_static") |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 140 | set(mbedx509_static_target "mbedx509_static") |
| 141 | set(mbedcrypto_static_target "mbedcrypto_static") |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 142 | elseif(USE_STATIC_MBEDTLS_LIBRARY) |
Manuel Pégourié-Gonnard | 216a183 | 2015-06-25 09:20:03 +0200 | [diff] [blame] | 143 | set(mbedtls_static_target "mbedtls") |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 144 | set(mbedx509_static_target "mbedx509") |
| 145 | set(mbedcrypto_static_target "mbedcrypto") |
hasufell | 3c6409b | 2014-03-06 15:49:08 +0100 | [diff] [blame] | 146 | endif() |
Paul Bakker | 9d3a7e4 | 2011-01-05 15:24:43 +0000 | [diff] [blame] | 147 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 148 | if(USE_STATIC_MBEDTLS_LIBRARY) |
Jaeden Amero | 30b340a | 2018-10-25 17:37:00 +0100 | [diff] [blame] | 149 | if(NOT USE_CRYPTO_SUBMODULE) |
| 150 | add_library(${mbedcrypto_static_target} STATIC ${src_crypto}) |
| 151 | set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto) |
| 152 | target_link_libraries(${mbedcrypto_static_target} ${libs}) |
| 153 | target_include_directories(${mbedcrypto_static_target} PUBLIC ${CMAKE_SOURCE_DIR}/include/) |
| 154 | endif() |
Paul Bakker | 6c1f69b | 2014-03-17 15:11:13 +0100 | [diff] [blame] | 155 | |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 156 | add_library(${mbedx509_static_target} STATIC ${src_x509}) |
| 157 | set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509) |
| 158 | target_link_libraries(${mbedx509_static_target} ${libs} ${mbedcrypto_static_target}) |
Jaeden Amero | 30b340a | 2018-10-25 17:37:00 +0100 | [diff] [blame] | 159 | target_include_directories(${mbedx509_static_target} |
| 160 | PUBLIC ${CMAKE_SOURCE_DIR}/include/ |
| 161 | PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/) |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 162 | |
| 163 | add_library(${mbedtls_static_target} STATIC ${src_tls}) |
| 164 | set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) |
| 165 | target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target}) |
Jaeden Amero | 30b340a | 2018-10-25 17:37:00 +0100 | [diff] [blame] | 166 | target_include_directories(${mbedtls_static_target} |
| 167 | PUBLIC ${CMAKE_SOURCE_DIR}/include/ |
| 168 | PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/ |
| 169 | ) |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 170 | |
Jaeden Amero | 30b340a | 2018-10-25 17:37:00 +0100 | [diff] [blame] | 171 | if(USE_CRYPTO_SUBMODULE) |
| 172 | install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} |
| 173 | DESTINATION ${LIB_INSTALL_DIR} |
| 174 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
| 175 | else() |
| 176 | install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target} |
| 177 | DESTINATION ${LIB_INSTALL_DIR} |
| 178 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
| 179 | endif() |
Manuel Pégourié-Gonnard | e1d34d1 | 2015-06-25 14:53:13 +0200 | [diff] [blame] | 180 | endif(USE_STATIC_MBEDTLS_LIBRARY) |
Paul Bakker | 9d3a7e4 | 2011-01-05 15:24:43 +0000 | [diff] [blame] | 181 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 182 | if(USE_SHARED_MBEDTLS_LIBRARY) |
Jaeden Amero | 30b340a | 2018-10-25 17:37:00 +0100 | [diff] [blame] | 183 | if(NOT USE_CRYPTO_SUBMODULE) |
| 184 | add_library(mbedcrypto SHARED ${src_crypto}) |
k-stachowiak | 28cb6fb | 2019-02-18 12:01:03 +0100 | [diff] [blame] | 185 | set_target_properties(mbedcrypto PROPERTIES VERSION 0.0.0 SOVERSION 3) |
Jaeden Amero | 30b340a | 2018-10-25 17:37:00 +0100 | [diff] [blame] | 186 | target_link_libraries(mbedcrypto ${libs}) |
| 187 | target_include_directories(mbedcrypto PUBLIC ${CMAKE_SOURCE_DIR}/include/) |
| 188 | endif() |
Paul Bakker | 2a5c7a8 | 2012-05-10 21:54:28 +0000 | [diff] [blame] | 189 | |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 190 | add_library(mbedx509 SHARED ${src_x509}) |
k-stachowiak | 28cb6fb | 2019-02-18 12:01:03 +0100 | [diff] [blame] | 191 | set_target_properties(mbedx509 PROPERTIES VERSION 0.0.0 SOVERSION 0) |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 192 | target_link_libraries(mbedx509 ${libs} mbedcrypto) |
Jaeden Amero | 30b340a | 2018-10-25 17:37:00 +0100 | [diff] [blame] | 193 | target_include_directories(mbedx509 |
| 194 | PUBLIC ${CMAKE_SOURCE_DIR}/include/ |
| 195 | PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/) |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 196 | |
| 197 | add_library(mbedtls SHARED ${src_tls}) |
k-stachowiak | 28cb6fb | 2019-02-18 12:01:03 +0100 | [diff] [blame] | 198 | set_target_properties(mbedtls PROPERTIES VERSION 0.0.0 SOVERSION 12) |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 199 | target_link_libraries(mbedtls ${libs} mbedx509) |
Jaeden Amero | 30b340a | 2018-10-25 17:37:00 +0100 | [diff] [blame] | 200 | target_include_directories(mbedtls |
| 201 | PUBLIC ${CMAKE_SOURCE_DIR}/include/ |
| 202 | PUBLIC ${CMAKE_SOURCE_DIR}/crypto/include/) |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 203 | |
Jaeden Amero | 30b340a | 2018-10-25 17:37:00 +0100 | [diff] [blame] | 204 | if(USE_CRYPTO_SUBMODULE) |
| 205 | install(TARGETS mbedtls mbedx509 |
| 206 | DESTINATION ${LIB_INSTALL_DIR} |
| 207 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
| 208 | else() |
| 209 | install(TARGETS mbedtls mbedx509 mbedcrypto |
| 210 | DESTINATION ${LIB_INSTALL_DIR} |
| 211 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
| 212 | endif() |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 213 | endif(USE_SHARED_MBEDTLS_LIBRARY) |
Manuel Pégourié-Gonnard | e1d34d1 | 2015-06-25 14:53:13 +0200 | [diff] [blame] | 214 | |
Jaeden Amero | 30b340a | 2018-10-25 17:37:00 +0100 | [diff] [blame] | 215 | if(USE_CRYPTO_SUBMODULE) |
| 216 | add_custom_target(lib DEPENDS mbedx509 mbedtls) |
| 217 | if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) |
| 218 | add_dependencies(lib mbedx509_static mbedtls_static) |
| 219 | endif() |
| 220 | else() |
| 221 | add_custom_target(lib DEPENDS mbedcrypto mbedx509 mbedtls) |
| 222 | if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) |
| 223 | add_dependencies(lib mbedcrypto_static mbedx509_static mbedtls_static) |
| 224 | endif() |
Manuel Pégourié-Gonnard | e1d34d1 | 2015-06-25 14:53:13 +0200 | [diff] [blame] | 225 | endif() |