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 |
| 53 | version.c |
| 54 | version_features.c |
| 55 | xtea.c |
| 56 | ) |
| 57 | |
| 58 | set(src_x509 |
| 59 | certs.c |
| 60 | pkcs11.c |
| 61 | x509.c |
| 62 | x509_create.c |
| 63 | x509_crl.c |
| 64 | x509_crt.c |
| 65 | x509_csr.c |
| 66 | x509write_crt.c |
| 67 | x509write_csr.c |
| 68 | ) |
| 69 | |
| 70 | set(src_tls |
| 71 | debug.c |
| 72 | net.c |
| 73 | ssl_cache.c |
| 74 | ssl_ciphersuites.c |
| 75 | ssl_cli.c |
| 76 | ssl_cookie.c |
| 77 | ssl_srv.c |
| 78 | ssl_ticket.c |
| 79 | ssl_tls.c |
| 80 | timing.c |
| 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 | 2a5c7a8 | 2012-05-10 21:54:28 +0000 | [diff] [blame] | 89 | if(WIN32) |
| 90 | set(libs ws2_32) |
| 91 | endif(WIN32) |
| 92 | |
Paul Bakker | 76f0311 | 2013-11-28 17:20:04 +0100 | [diff] [blame] | 93 | if(CMAKE_COMPILER_IS_GNUCC) |
Manuel Pégourié-Gonnard | 98aa191 | 2014-11-14 16:34:36 +0100 | [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 | edb7ed3 | 2015-01-20 16:45:20 +0000 | [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 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 101 | if (NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY) |
| 102 | message(FATAL_ERROR "Need to choose static or shared mbedtls build!") |
| 103 | endif(NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY) |
Paul Bakker | 9d3a7e4 | 2011-01-05 15:24:43 +0000 | [diff] [blame] | 104 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 105 | if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) |
hasufell | 3c6409b | 2014-03-06 15:49:08 +0100 | [diff] [blame] | 106 | # if we build both static an shared, then let |
| 107 | # tests and programs link to the shared lib target |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 108 | set(mbedtls_static_target "mbedtls_static") |
| 109 | elseif(USE_STATIC_MBEDTLS_LIBRARY) |
| 110 | set(mbedtls_static_target "mbedtls") |
hasufell | 3c6409b | 2014-03-06 15:49:08 +0100 | [diff] [blame] | 111 | endif() |
Paul Bakker | 9d3a7e4 | 2011-01-05 15:24:43 +0000 | [diff] [blame] | 112 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 113 | if(USE_STATIC_MBEDTLS_LIBRARY) |
| 114 | add_library(${mbedtls_static_target} STATIC ${src}) |
| 115 | set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) |
| 116 | target_link_libraries(${mbedtls_static_target} ${libs}) |
Paul Bakker | 6c1f69b | 2014-03-17 15:11:13 +0100 | [diff] [blame] | 117 | |
| 118 | if(ZLIB_FOUND) |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 119 | target_link_libraries(${mbedtls_static_target} ${ZLIB_LIBRARIES}) |
Paul Bakker | 6c1f69b | 2014-03-17 15:11:13 +0100 | [diff] [blame] | 120 | endif(ZLIB_FOUND) |
| 121 | |
Paul Bakker | d6917f0 | 2014-06-09 23:46:41 +0200 | [diff] [blame] | 122 | if(LINK_WITH_PTHREAD) |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 123 | target_link_libraries(${mbedtls_static_target} pthread) |
Paul Bakker | d6917f0 | 2014-06-09 23:46:41 +0200 | [diff] [blame] | 124 | endif() |
Paul Bakker | 9d3a7e4 | 2011-01-05 15:24:43 +0000 | [diff] [blame] | 125 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 126 | install(TARGETS ${mbedtls_static_target} |
hasufell | 3c6409b | 2014-03-06 15:49:08 +0100 | [diff] [blame] | 127 | DESTINATION ${LIB_INSTALL_DIR} |
| 128 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
| 129 | endif() |
Paul Bakker | 9d3a7e4 | 2011-01-05 15:24:43 +0000 | [diff] [blame] | 130 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 131 | if(USE_SHARED_MBEDTLS_LIBRARY) |
| 132 | add_library(mbedtls SHARED ${src}) |
Manuel Pégourié-Gonnard | 2a0718d | 2015-01-29 11:29:12 +0000 | [diff] [blame] | 133 | set_target_properties(mbedtls PROPERTIES VERSION 1.4.0 SOVERSION 8) |
Paul Bakker | 9d3a7e4 | 2011-01-05 15:24:43 +0000 | [diff] [blame] | 134 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 135 | target_link_libraries(mbedtls ${libs}) |
Paul Bakker | 2a5c7a8 | 2012-05-10 21:54:28 +0000 | [diff] [blame] | 136 | |
hasufell | 3c6409b | 2014-03-06 15:49:08 +0100 | [diff] [blame] | 137 | if(ZLIB_FOUND) |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 138 | target_link_libraries(mbedtls ${ZLIB_LIBRARIES}) |
hasufell | 3c6409b | 2014-03-06 15:49:08 +0100 | [diff] [blame] | 139 | endif(ZLIB_FOUND) |
Steffan Karger | c245834 | 2013-11-14 10:34:46 +0100 | [diff] [blame] | 140 | |
Paul Bakker | d6917f0 | 2014-06-09 23:46:41 +0200 | [diff] [blame] | 141 | if(LINK_WITH_PTHREAD) |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 142 | target_link_libraries(mbedtls pthread) |
Paul Bakker | d6917f0 | 2014-06-09 23:46:41 +0200 | [diff] [blame] | 143 | endif() |
| 144 | |
Manuel Pégourié-Gonnard | 9014b6f | 2015-01-27 15:44:46 +0000 | [diff] [blame] | 145 | install(TARGETS mbedtls |
hasufell | 3c6409b | 2014-03-06 15:49:08 +0100 | [diff] [blame] | 146 | DESTINATION ${LIB_INSTALL_DIR} |
| 147 | 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] | 148 | endif(USE_SHARED_MBEDTLS_LIBRARY) |