blob: 585e75ee07dc279e244432fc072f7a1b91ca2b98 [file] [log] [blame]
Manuel Pégourié-Gonnard9014b6f2015-01-27 15:44:46 +00001option(USE_STATIC_MBEDTLS_LIBRARY "Build mbed TLS static library." ON)
2option(USE_SHARED_MBEDTLS_LIBRARY "Build mbed TLS shared library." OFF)
Manuel Pégourié-Gonnardcfa9a452015-01-23 13:33:31 +00003option(LINK_WITH_PTHREAD "Explicitly link mbed TLS library to pthread." OFF)
Paul Bakker9d3a7e42011-01-05 15:24:43 +00004
Manuel Pégourié-Gonnard463e09d2015-06-24 11:54:19 +02005set(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é-Gonnard21dcc1e2015-06-25 10:59:15 +020053 timing.c
Manuel Pégourié-Gonnard463e09d2015-06-24 11:54:19 +020054 version.c
55 version_features.c
56 xtea.c
57)
58
59set(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
71set(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é-Gonnard463e09d2015-06-24 11:54:19 +020081)
82
Paul Bakker9d3a7e42011-01-05 15:24:43 +000083set(src
Manuel Pégourié-Gonnard463e09d2015-06-24 11:54:19 +020084 ${src_crypto}
85 ${src_x509}
86 ${src_tls}
Paul Bakker367dae42009-06-28 21:50:27 +000087)
Paul Bakker547f73d2011-01-05 15:07:54 +000088
Paul Bakker2a5c7a82012-05-10 21:54:28 +000089if(WIN32)
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +020090 set(libs ws2_32)
Paul Bakker2a5c7a82012-05-10 21:54:28 +000091endif(WIN32)
92
Paul Bakker76f03112013-11-28 17:20:04 +010093if(CMAKE_COMPILER_IS_GNUCC)
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +020094 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes")
Paul Bakker76f03112013-11-28 17:20:04 +010095endif(CMAKE_COMPILER_IS_GNUCC)
96
Manuel Pégourié-Gonnard31855452014-06-25 15:59:50 +020097if(CMAKE_COMPILER_IS_CLANG)
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +020098 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes -Wdocumentation -Wno-documentation-deprecated-sync -Wunreachable-code")
Manuel Pégourié-Gonnard31855452014-06-25 15:59:50 +020099endif(CMAKE_COMPILER_IS_CLANG)
100
Manuel Pégourié-Gonnard9014b6f2015-01-27 15:44:46 +0000101if (NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200102 message(FATAL_ERROR "Need to choose static or shared mbedtls build!")
Manuel Pégourié-Gonnard9014b6f2015-01-27 15:44:46 +0000103endif(NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
Paul Bakker9d3a7e42011-01-05 15:24:43 +0000104
Manuel Pégourié-Gonnard9014b6f2015-01-27 15:44:46 +0000105if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200106 # if we build both static an shared, then let
107 # tests and programs link to the shared lib target
108 set(mbedtls_static_target "mbedtls_static")
Manuel Pégourié-Gonnard9014b6f2015-01-27 15:44:46 +0000109elseif(USE_STATIC_MBEDTLS_LIBRARY)
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200110 set(mbedtls_static_target "mbedtls")
hasufell3c6409b2014-03-06 15:49:08 +0100111endif()
Paul Bakker9d3a7e42011-01-05 15:24:43 +0000112
Manuel Pégourié-Gonnard9014b6f2015-01-27 15:44:46 +0000113if(USE_STATIC_MBEDTLS_LIBRARY)
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200114 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 Bakker6c1f69b2014-03-17 15:11:13 +0100117
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200118 if(ZLIB_FOUND)
119 target_link_libraries(${mbedtls_static_target} ${ZLIB_LIBRARIES})
120 endif(ZLIB_FOUND)
Paul Bakker6c1f69b2014-03-17 15:11:13 +0100121
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200122 if(LINK_WITH_PTHREAD)
Manuel Pégourié-Gonnard9014b6f2015-01-27 15:44:46 +0000123 target_link_libraries(${mbedtls_static_target} pthread)
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200124 endif()
Paul Bakker9d3a7e42011-01-05 15:24:43 +0000125
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200126 install(TARGETS ${mbedtls_static_target}
127 DESTINATION ${LIB_INSTALL_DIR}
128 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
hasufell3c6409b2014-03-06 15:49:08 +0100129endif()
Paul Bakker9d3a7e42011-01-05 15:24:43 +0000130
Manuel Pégourié-Gonnard9014b6f2015-01-27 15:44:46 +0000131if(USE_SHARED_MBEDTLS_LIBRARY)
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200132 add_library(mbedtls SHARED ${src})
133 set_target_properties(mbedtls PROPERTIES VERSION 1.4.0 SOVERSION 8)
Paul Bakker9d3a7e42011-01-05 15:24:43 +0000134
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200135 target_link_libraries(mbedtls ${libs})
Paul Bakker2a5c7a82012-05-10 21:54:28 +0000136
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200137 if(ZLIB_FOUND)
138 target_link_libraries(mbedtls ${ZLIB_LIBRARIES})
139 endif(ZLIB_FOUND)
Steffan Kargerc2458342013-11-14 10:34:46 +0100140
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200141 if(LINK_WITH_PTHREAD)
Manuel Pégourié-Gonnard9014b6f2015-01-27 15:44:46 +0000142 target_link_libraries(mbedtls pthread)
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200143 endif()
Paul Bakkerd6917f02014-06-09 23:46:41 +0200144
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +0200145 install(TARGETS mbedtls
146 DESTINATION ${LIB_INSTALL_DIR}
147 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
Manuel Pégourié-Gonnard9014b6f2015-01-27 15:44:46 +0000148endif(USE_SHARED_MBEDTLS_LIBRARY)