CMakeLists.txt 3.23 KB
Newer Older
1 2
option(USE_STATIC_MBEDTLS_LIBRARY "Build mbed TLS static library." ON)
option(USE_SHARED_MBEDTLS_LIBRARY "Build mbed TLS shared library." OFF)
3
option(LINK_WITH_PTHREAD "Explicitly link mbed TLS library to pthread." OFF)
4 5

set(src
6
     aes.c
7
     aesni.c
8
     arc4.c
9
     asn1parse.c
10
     asn1write.c
11 12
     base64.c
     bignum.c
13
     blowfish.c
14
     camellia.c
15
     ccm.c
16
     certs.c
17 18
     cipher.c
     cipher_wrap.c
19
     ctr_drbg.c
20 21
     debug.c
     des.c
22
     dhm.c
23
     ecp.c
Manuel Pégourié-Gonnard's avatar
Manuel Pégourié-Gonnard committed
24
     ecp_curves.c
25
     ecdh.c
26
     ecdsa.c
27 28
     entropy.c
     entropy_poll.c
29
     error.c
30
     gcm.c
31
     havege.c
32
     hmac_drbg.c
33 34
     md.c
     md_wrap.c
35
     md2.c
36
     md4.c
37
     md5.c
38
     memory_buffer_alloc.c
39
     net.c
40
     oid.c
41
     padlock.c
Paul Bakker's avatar
Paul Bakker committed
42
     pem.c
43
     pkcs5.c
44
     pkcs11.c
45
     pkcs12.c
46
     pk.c
47
     pk_wrap.c
48
     pkparse.c
49
     pkwrite.c
50
     platform.c
51
     ripemd160.c
52 53
     rsa.c
     sha1.c
54 55
     sha256.c
     sha512.c
56
     ssl_cache.c
57
     ssl_cookie.c
58
     ssl_ticket.c
59
     ssl_ciphersuites.c
60 61
     ssl_cli.c
     ssl_srv.c
62
     ssl_tls.c
63
     threading.c
64
     timing.c
65
     version.c
66
     version_features.c
67 68 69 70 71
     x509.c
     x509_crt.c
     x509_crl.c
     x509_csr.c
     x509_create.c
72 73
     x509write_crt.c
     x509write_csr.c
74
     xtea.c
75
)
76

77 78 79 80
if(WIN32)
set(libs ws2_32)
endif(WIN32)

81
if(CMAKE_COMPILER_IS_GNUCC)
82
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes")
83 84
endif(CMAKE_COMPILER_IS_GNUCC)

85
if(CMAKE_COMPILER_IS_CLANG)
86
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes -Wdocumentation -Wno-documentation-deprecated-sync -Wunreachable-code")
87 88
endif(CMAKE_COMPILER_IS_CLANG)

89 90 91
if (NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
	message(FATAL_ERROR "Need to choose static or shared mbedtls build!")
endif(NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
92

93
if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
94 95
	# if we build both static an shared, then let
	# tests and programs link to the shared lib target
96 97 98
	set(mbedtls_static_target "mbedtls_static")
elseif(USE_STATIC_MBEDTLS_LIBRARY)
	set(mbedtls_static_target "mbedtls")
99
endif()
100

101 102 103 104
if(USE_STATIC_MBEDTLS_LIBRARY)
	add_library(${mbedtls_static_target} STATIC ${src})
	set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls)
	target_link_libraries(${mbedtls_static_target} ${libs})
105 106

	if(ZLIB_FOUND)
107
		target_link_libraries(${mbedtls_static_target} ${ZLIB_LIBRARIES})
108 109
	endif(ZLIB_FOUND)

110
	if(LINK_WITH_PTHREAD)
111
        target_link_libraries(${mbedtls_static_target} pthread)
112
	endif()
113

114
	install(TARGETS ${mbedtls_static_target}
115 116 117
			DESTINATION ${LIB_INSTALL_DIR}
			PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endif()
118

119 120
if(USE_SHARED_MBEDTLS_LIBRARY)
	add_library(mbedtls SHARED ${src})
121
	set_target_properties(mbedtls PROPERTIES VERSION 1.4.0 SOVERSION 8)
122

123
	target_link_libraries(mbedtls ${libs})
124

125
	if(ZLIB_FOUND)
126
		target_link_libraries(mbedtls ${ZLIB_LIBRARIES})
127
	endif(ZLIB_FOUND)
128

129
	if(LINK_WITH_PTHREAD)
130
        target_link_libraries(mbedtls pthread)
131 132
	endif()

133
	install(TARGETS mbedtls
134 135
			DESTINATION ${LIB_INSTALL_DIR}
			PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
136
endif(USE_SHARED_MBEDTLS_LIBRARY)