1 | # ARM mbedtls support https://tls.mbed.org/
|
---|
2 | set(MBEDTLSDIR ${LWIP_CONTRIB_DIR}/../mbedtls)
|
---|
3 | if(EXISTS ${MBEDTLSDIR}/CMakeLists.txt)
|
---|
4 | set(LWIP_HAVE_MBEDTLS ON BOOL)
|
---|
5 |
|
---|
6 | # Prevent building MBEDTLS programs and tests
|
---|
7 | set(ENABLE_PROGRAMS OFF CACHE BOOL "")
|
---|
8 | set(ENABLE_TESTING OFF CACHE BOOL "")
|
---|
9 |
|
---|
10 | # mbedtls uses cmake. Sweet!
|
---|
11 | add_subdirectory(${MBEDTLSDIR} mbedtls)
|
---|
12 |
|
---|
13 | set (LWIP_MBEDTLS_DEFINITIONS
|
---|
14 | -DLWIP_HAVE_MBEDTLS=1
|
---|
15 | )
|
---|
16 | set (LWIP_MBEDTLS_INCLUDE_DIRS
|
---|
17 | ${MBEDTLSDIR}/include
|
---|
18 | )
|
---|
19 | set (LWIP_MBEDTLS_LINK_LIBRARIES
|
---|
20 | mbedtls
|
---|
21 | mbedcrypto
|
---|
22 | mbedx509
|
---|
23 | )
|
---|
24 | endif()
|
---|
25 |
|
---|
26 | set(LWIP_COMPILER_FLAGS_GNU_CLANG
|
---|
27 | -g
|
---|
28 | -Wall
|
---|
29 | -pedantic
|
---|
30 | -Werror
|
---|
31 | -Wparentheses
|
---|
32 | -Wsequence-point
|
---|
33 | -Wswitch-default
|
---|
34 | -Wextra -Wundef
|
---|
35 | -Wshadow
|
---|
36 | -Wpointer-arith
|
---|
37 | -Wcast-qual
|
---|
38 | -Wc++-compat
|
---|
39 | -Wwrite-strings
|
---|
40 | -Wold-style-definition
|
---|
41 | -Wcast-align
|
---|
42 | -Wmissing-prototypes
|
---|
43 | -Wnested-externs
|
---|
44 | -Wunreachable-code
|
---|
45 | -Wuninitialized
|
---|
46 | -Wmissing-prototypes
|
---|
47 | -Waggregate-return
|
---|
48 | -Wlogical-not-parentheses
|
---|
49 | )
|
---|
50 |
|
---|
51 | if (NOT LWIP_HAVE_MBEDTLS)
|
---|
52 | list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG
|
---|
53 | -Wredundant-decls
|
---|
54 | )
|
---|
55 | endif()
|
---|
56 |
|
---|
57 | if(CMAKE_C_COMPILER_ID STREQUAL GNU)
|
---|
58 | list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG
|
---|
59 | -Wlogical-op
|
---|
60 | -Wtrampolines
|
---|
61 | )
|
---|
62 |
|
---|
63 | if (NOT LWIP_HAVE_MBEDTLS)
|
---|
64 | list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG
|
---|
65 | -Wc90-c99-compat
|
---|
66 | )
|
---|
67 | endif()
|
---|
68 |
|
---|
69 | if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
|
---|
70 | if(LWIP_USE_SANITIZERS)
|
---|
71 | list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG
|
---|
72 | -fsanitize=address
|
---|
73 | -fsanitize=undefined
|
---|
74 | -fno-sanitize=alignment
|
---|
75 | -fstack-protector
|
---|
76 | -fstack-check
|
---|
77 | )
|
---|
78 | set(LWIP_SANITIZER_LIBS asan ubsan)
|
---|
79 | endif()
|
---|
80 | endif()
|
---|
81 |
|
---|
82 | set(LWIP_COMPILER_FLAGS ${LWIP_COMPILER_FLAGS_GNU_CLANG})
|
---|
83 | endif()
|
---|
84 |
|
---|
85 | if(CMAKE_C_COMPILER_ID STREQUAL Clang)
|
---|
86 | list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG
|
---|
87 | -Wdocumentation
|
---|
88 | -Wno-documentation-deprecated-sync
|
---|
89 | )
|
---|
90 |
|
---|
91 | if(LWIP_USE_SANITIZERS)
|
---|
92 | list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG
|
---|
93 | -fsanitize=address
|
---|
94 | -fsanitize=undefined
|
---|
95 | -fno-sanitize=alignment
|
---|
96 | )
|
---|
97 | set(LWIP_SANITIZER_LIBS asan ubsan)
|
---|
98 | endif()
|
---|
99 |
|
---|
100 | set(LWIP_COMPILER_FLAGS ${LWIP_COMPILER_FLAGS_GNU_CLANG})
|
---|
101 | endif()
|
---|
102 |
|
---|
103 | if(CMAKE_C_COMPILER_ID STREQUAL MSVC)
|
---|
104 | # TODO
|
---|
105 | endif()
|
---|