2018-10-12 20:01:25 +00:00
|
|
|
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0")
|
|
|
|
include_guard(GLOBAL)
|
|
|
|
endif()
|
2018-10-05 06:02:34 +00:00
|
|
|
|
2018-11-25 13:25:23 +00:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
message(STATUS "CMAKE_BUILD_TYPE not set - defaulting to Debug build.")
|
|
|
|
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}." FORCE)
|
|
|
|
endif()
|
|
|
|
message (STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
2018-10-02 10:54:56 +00:00
|
|
|
set(LWIP_CONTRIB_DIR ${LWIP_DIR}/contrib)
|
|
|
|
|
2018-10-02 10:17:31 +00:00
|
|
|
# ARM mbedtls support https://tls.mbed.org/
|
2018-10-08 19:17:32 +00:00
|
|
|
if(NOT DEFINED LWIP_MBEDTLSDIR)
|
|
|
|
set(LWIP_MBEDTLSDIR ${LWIP_DIR}/../mbedtls)
|
|
|
|
message(STATUS "LWIP_MBEDTLSDIR not set - using default location ${LWIP_MBEDTLSDIR}")
|
2018-10-02 11:06:01 +00:00
|
|
|
endif()
|
2018-10-08 19:17:32 +00:00
|
|
|
if(EXISTS ${LWIP_MBEDTLSDIR}/CMakeLists.txt)
|
2018-10-02 10:17:31 +00:00
|
|
|
set(LWIP_HAVE_MBEDTLS ON BOOL)
|
|
|
|
|
|
|
|
# Prevent building MBEDTLS programs and tests
|
|
|
|
set(ENABLE_PROGRAMS OFF CACHE BOOL "")
|
|
|
|
set(ENABLE_TESTING OFF CACHE BOOL "")
|
2018-10-08 18:57:06 +00:00
|
|
|
|
2018-10-02 10:17:31 +00:00
|
|
|
# mbedtls uses cmake. Sweet!
|
2018-10-08 19:17:32 +00:00
|
|
|
add_subdirectory(${LWIP_MBEDTLSDIR} mbedtls)
|
2018-10-02 10:17:31 +00:00
|
|
|
|
|
|
|
set (LWIP_MBEDTLS_DEFINITIONS
|
2018-10-08 18:57:06 +00:00
|
|
|
LWIP_HAVE_MBEDTLS=1
|
2018-10-02 10:17:31 +00:00
|
|
|
)
|
|
|
|
set (LWIP_MBEDTLS_INCLUDE_DIRS
|
2018-10-08 19:17:32 +00:00
|
|
|
${LWIP_MBEDTLSDIR}/include
|
2018-10-02 10:17:31 +00:00
|
|
|
)
|
|
|
|
set (LWIP_MBEDTLS_LINK_LIBRARIES
|
|
|
|
mbedtls
|
|
|
|
mbedcrypto
|
|
|
|
mbedx509
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(LWIP_COMPILER_FLAGS_GNU_CLANG
|
2018-11-25 13:25:23 +00:00
|
|
|
$<$<CONFIG:Debug>:-Og>
|
2018-11-28 21:43:21 +00:00
|
|
|
$<$<CONFIG:Debug>:-g>
|
2018-11-25 13:25:23 +00:00
|
|
|
$<$<CONFIG:Release>:-O3>
|
2018-10-02 10:17:31 +00:00
|
|
|
-Wall
|
|
|
|
-pedantic
|
|
|
|
-Werror
|
|
|
|
-Wparentheses
|
|
|
|
-Wsequence-point
|
|
|
|
-Wswitch-default
|
2018-10-24 13:08:02 +00:00
|
|
|
-Wextra
|
|
|
|
-Wundef
|
2018-10-02 10:17:31 +00:00
|
|
|
-Wshadow
|
|
|
|
-Wpointer-arith
|
|
|
|
-Wcast-qual
|
|
|
|
-Wc++-compat
|
|
|
|
-Wwrite-strings
|
|
|
|
-Wold-style-definition
|
|
|
|
-Wcast-align
|
|
|
|
-Wmissing-prototypes
|
|
|
|
-Wnested-externs
|
|
|
|
-Wunreachable-code
|
|
|
|
-Wuninitialized
|
|
|
|
-Wmissing-prototypes
|
|
|
|
-Waggregate-return
|
|
|
|
-Wlogical-not-parentheses
|
|
|
|
)
|
|
|
|
|
|
|
|
if (NOT LWIP_HAVE_MBEDTLS)
|
|
|
|
list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG
|
|
|
|
-Wredundant-decls
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2018-11-22 12:14:14 +00:00
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
2018-10-02 10:17:31 +00:00
|
|
|
list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG
|
|
|
|
-Wlogical-op
|
|
|
|
-Wtrampolines
|
|
|
|
)
|
|
|
|
|
|
|
|
if (NOT LWIP_HAVE_MBEDTLS)
|
|
|
|
list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG
|
|
|
|
-Wc90-c99-compat
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
|
|
|
|
if(LWIP_USE_SANITIZERS)
|
|
|
|
list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG
|
|
|
|
-fsanitize=address
|
|
|
|
-fsanitize=undefined
|
|
|
|
-fno-sanitize=alignment
|
|
|
|
-fstack-protector
|
|
|
|
-fstack-check
|
|
|
|
)
|
|
|
|
set(LWIP_SANITIZER_LIBS asan ubsan)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(LWIP_COMPILER_FLAGS ${LWIP_COMPILER_FLAGS_GNU_CLANG})
|
|
|
|
endif()
|
|
|
|
|
2018-11-22 12:14:14 +00:00
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
2018-10-02 10:17:31 +00:00
|
|
|
list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG
|
|
|
|
-Wdocumentation
|
|
|
|
-Wno-documentation-deprecated-sync
|
|
|
|
)
|
|
|
|
|
|
|
|
if(LWIP_USE_SANITIZERS)
|
|
|
|
list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG
|
|
|
|
-fsanitize=address
|
|
|
|
-fsanitize=undefined
|
|
|
|
-fno-sanitize=alignment
|
|
|
|
)
|
|
|
|
set(LWIP_SANITIZER_LIBS asan ubsan)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(LWIP_COMPILER_FLAGS ${LWIP_COMPILER_FLAGS_GNU_CLANG})
|
|
|
|
endif()
|
|
|
|
|
2018-11-22 12:14:14 +00:00
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
2018-11-25 13:25:23 +00:00
|
|
|
set(LWIP_COMPILER_FLAGS
|
2018-11-26 07:11:39 +00:00
|
|
|
$<$<CONFIG:Debug>:/Od>
|
|
|
|
$<$<CONFIG:Release>:/Ox>
|
2018-11-25 13:25:23 +00:00
|
|
|
/Wall
|
|
|
|
/WX
|
|
|
|
)
|
2018-10-02 10:17:31 +00:00
|
|
|
endif()
|