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 |
| 9 | asn1parse.c |
| 10 | asn1write.c |
| 11 | base64.c |
| 12 | bignum.c |
| 13 | blowfish.c |
| 14 | camellia.c |
| 15 | ccm.c |
| 16 | cipher.c |
| 17 | cipher_wrap.c |
Robert Cragie | dc5c7b9 | 2015-12-11 15:49:45 +0000 | [diff] [blame] | 18 | cmac.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 19 | ctr_drbg.c |
| 20 | des.c |
| 21 | dhm.c |
| 22 | ecdh.c |
| 23 | ecdsa.c |
Manuel Pégourié-Gonnard | 4d8685b | 2015-08-05 15:44:42 +0200 | [diff] [blame] | 24 | ecjpake.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 25 | ecp.c |
| 26 | ecp_curves.c |
| 27 | entropy.c |
| 28 | entropy_poll.c |
| 29 | error.c |
| 30 | gcm.c |
| 31 | havege.c |
| 32 | hmac_drbg.c |
| 33 | md.c |
| 34 | md2.c |
| 35 | md4.c |
| 36 | md5.c |
| 37 | md_wrap.c |
| 38 | memory_buffer_alloc.c |
| 39 | oid.c |
| 40 | padlock.c |
| 41 | pem.c |
| 42 | pk.c |
| 43 | pk_wrap.c |
| 44 | pkcs12.c |
| 45 | pkcs5.c |
| 46 | pkparse.c |
| 47 | pkwrite.c |
| 48 | platform.c |
| 49 | ripemd160.c |
| 50 | rsa.c |
Hanno Becker | a565f54 | 2017-10-11 11:00:19 +0100 | [diff] [blame] | 51 | rsa_internal.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 52 | sha1.c |
| 53 | sha256.c |
| 54 | sha512.c |
| 55 | threading.c |
Manuel Pégourié-Gonnard | 21dcc1e | 2015-06-25 10:59:15 +0200 | [diff] [blame] | 56 | timing.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 57 | version.c |
| 58 | version_features.c |
| 59 | xtea.c |
| 60 | ) |
| 61 | |
| 62 | set(src_x509 |
| 63 | certs.c |
| 64 | pkcs11.c |
| 65 | x509.c |
| 66 | x509_create.c |
| 67 | x509_crl.c |
| 68 | x509_crt.c |
| 69 | x509_csr.c |
| 70 | x509write_crt.c |
| 71 | x509write_csr.c |
| 72 | ) |
| 73 | |
| 74 | set(src_tls |
| 75 | debug.c |
Andres AG | 788aa4a | 2016-09-14 14:32:09 +0100 | [diff] [blame] | 76 | net_sockets.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 77 | ssl_cache.c |
| 78 | ssl_ciphersuites.c |
| 79 | ssl_cli.c |
| 80 | ssl_cookie.c |
| 81 | ssl_srv.c |
| 82 | ssl_ticket.c |
| 83 | ssl_tls.c |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 84 | ) |
| 85 | |
Paul Bakker | 76f0311 | 2013-11-28 17:20:04 +0100 | [diff] [blame] | 86 | if(CMAKE_COMPILER_IS_GNUCC) |
Manuel Pégourié-Gonnard | 216a183 | 2015-06-25 09:20:03 +0200 | [diff] [blame] | 87 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes") |
Paul Bakker | 76f0311 | 2013-11-28 17:20:04 +0100 | [diff] [blame] | 88 | endif(CMAKE_COMPILER_IS_GNUCC) |
| 89 | |
Manuel Pégourié-Gonnard | 3185545 | 2014-06-25 15:59:50 +0200 | [diff] [blame] | 90 | if(CMAKE_COMPILER_IS_CLANG) |
Manuel Pégourié-Gonnard | 216a183 | 2015-06-25 09:20:03 +0200 | [diff] [blame] | 91 | 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] | 92 | endif(CMAKE_COMPILER_IS_CLANG) |
| 93 | |
Manuel Pégourié-Gonnard | ba2c876 | 2015-06-25 09:35:46 +0200 | [diff] [blame] | 94 | if(WIN32) |
| 95 | set(libs ${libs} ws2_32) |
| 96 | endif(WIN32) |
| 97 | |
| 98 | if(USE_PKCS11_HELPER_LIBRARY) |
| 99 | set(libs ${libs} pkcs11-helper) |
| 100 | endif(USE_PKCS11_HELPER_LIBRARY) |
| 101 | |
| 102 | if(ENABLE_ZLIB_SUPPORT) |
| 103 | set(libs ${libs} ${ZLIB_LIBRARIES}) |
| 104 | endif(ENABLE_ZLIB_SUPPORT) |
| 105 | |
| 106 | if(LINK_WITH_PTHREAD) |
| 107 | set(libs ${libs} pthread) |
| 108 | endif() |
| 109 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 110 | 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] | 111 | 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] | 112 | endif(NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY) |
Paul Bakker | 9d3a7e4 | 2011-01-05 15:24:43 +0000 | [diff] [blame] | 113 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 114 | if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) |
Manuel Pégourié-Gonnard | 216a183 | 2015-06-25 09:20:03 +0200 | [diff] [blame] | 115 | set(mbedtls_static_target "mbedtls_static") |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 116 | set(mbedx509_static_target "mbedx509_static") |
| 117 | set(mbedcrypto_static_target "mbedcrypto_static") |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 118 | elseif(USE_STATIC_MBEDTLS_LIBRARY) |
Manuel Pégourié-Gonnard | 216a183 | 2015-06-25 09:20:03 +0200 | [diff] [blame] | 119 | set(mbedtls_static_target "mbedtls") |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 120 | set(mbedx509_static_target "mbedx509") |
| 121 | set(mbedcrypto_static_target "mbedcrypto") |
hasufell | 3c6409b | 2014-03-06 15:49:08 +0100 | [diff] [blame] | 122 | endif() |
Paul Bakker | 9d3a7e4 | 2011-01-05 15:24:43 +0000 | [diff] [blame] | 123 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 124 | if(USE_STATIC_MBEDTLS_LIBRARY) |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 125 | add_library(${mbedcrypto_static_target} STATIC ${src_crypto}) |
| 126 | set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto) |
| 127 | target_link_libraries(${mbedcrypto_static_target} ${libs}) |
Paul Bakker | 6c1f69b | 2014-03-17 15:11:13 +0100 | [diff] [blame] | 128 | |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 129 | add_library(${mbedx509_static_target} STATIC ${src_x509}) |
| 130 | set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509) |
| 131 | target_link_libraries(${mbedx509_static_target} ${libs} ${mbedcrypto_static_target}) |
| 132 | |
| 133 | add_library(${mbedtls_static_target} STATIC ${src_tls}) |
| 134 | set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) |
| 135 | target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target}) |
| 136 | |
Manuel Pégourié-Gonnard | 6f42417 | 2015-07-24 16:53:46 +0200 | [diff] [blame] | 137 | install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target} |
Manuel Pégourié-Gonnard | ba2c876 | 2015-06-25 09:35:46 +0200 | [diff] [blame] | 138 | DESTINATION ${LIB_INSTALL_DIR} |
| 139 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
Manuel Pégourié-Gonnard | e1d34d1 | 2015-06-25 14:53:13 +0200 | [diff] [blame] | 140 | endif(USE_STATIC_MBEDTLS_LIBRARY) |
Paul Bakker | 9d3a7e4 | 2011-01-05 15:24:43 +0000 | [diff] [blame] | 141 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 142 | if(USE_SHARED_MBEDTLS_LIBRARY) |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 143 | add_library(mbedcrypto SHARED ${src_crypto}) |
Jaeden Amero | 3b438d3 | 2018-02-02 17:52:47 +0000 | [diff] [blame] | 144 | set_target_properties(mbedcrypto PROPERTIES VERSION 2.7.0 SOVERSION 1) |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 145 | target_link_libraries(mbedcrypto ${libs}) |
Paul Bakker | 2a5c7a8 | 2012-05-10 21:54:28 +0000 | [diff] [blame] | 146 | |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 147 | add_library(mbedx509 SHARED ${src_x509}) |
Jaeden Amero | 3b438d3 | 2018-02-02 17:52:47 +0000 | [diff] [blame] | 148 | set_target_properties(mbedx509 PROPERTIES VERSION 2.7.0 SOVERSION 0) |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 149 | target_link_libraries(mbedx509 ${libs} mbedcrypto) |
| 150 | |
| 151 | add_library(mbedtls SHARED ${src_tls}) |
Jaeden Amero | 3b438d3 | 2018-02-02 17:52:47 +0000 | [diff] [blame] | 152 | set_target_properties(mbedtls PROPERTIES VERSION 2.7.0 SOVERSION 10) |
Manuel Pégourié-Gonnard | c7781ad | 2015-06-25 09:49:02 +0200 | [diff] [blame] | 153 | target_link_libraries(mbedtls ${libs} mbedx509) |
| 154 | |
| 155 | install(TARGETS mbedtls mbedx509 mbedcrypto |
Manuel Pégourié-Gonnard | 216a183 | 2015-06-25 09:20:03 +0200 | [diff] [blame] | 156 | DESTINATION ${LIB_INSTALL_DIR} |
| 157 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 158 | endif(USE_SHARED_MBEDTLS_LIBRARY) |
Manuel Pégourié-Gonnard | e1d34d1 | 2015-06-25 14:53:13 +0200 | [diff] [blame] | 159 | |
| 160 | add_custom_target(lib DEPENDS mbedcrypto mbedx509 mbedtls) |
| 161 | if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) |
| 162 | add_dependencies(lib mbedcrypto_static mbedx509_static mbedtls_static) |
| 163 | endif() |