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