Browse Source

Work on CMake build system - several cleanups

master
Dirk Ziegelmeier 8 years ago
parent
commit
c8b4354440
  1. 39
      ports/CMakeCommon.cmake
  2. 14
      ports/unix/CMakeLists.txt
  3. 10
      ports/unix/unixsim/CMakeLists.txt

39
ports/CMakeCommon.cmake

@ -1,7 +1,31 @@
set(LWIP_GNU_CLANG_COMMON_FLAGS "-Wall -pedantic -Werror -Wparentheses -Wsequence-point -Wswitch-default -Wextra -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wc++-compat -Wwrite-strings -Wold-style-definition -Wcast-align -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Wunreachable-code -Wuninitialized -Wmissing-prototypes -Wredundant-decls -Waggregate-return -Wlogical-not-parentheses")
# ARM mbedtls support https://tls.mbed.org/
# Build mbedtls BEFORE adding our own compile flags -
# mbedtls produces errors with them
set(MBEDTLSDIR ${LWIP_CONTRIB_DIR}/../mbedtls)
if(EXISTS ${MBEDTLSDIR}/include/mbedtls/ssl.h)
set(LWIP_HAVE_MBEDTLS ON BOOL)
# Prevent building MBEDTLS programs and tests
set(ENABLE_PROGRAMS OFF CACHE BOOL "")
set(ENABLE_TESTING OFF CACHE BOOL "")
# mbedtls uses cmake. Sweet!
add_subdirectory(${LWIP_CONTRIB_DIR}/../mbedtls mbedtls)
add_definitions(-DLWIP_HAVE_MBEDTLS=1)
include_directories(${MBEDTLSDIR}/include)
link_libraries(mbedtls mbedcrypto mbedx509)
endif()
set(LWIP_GNU_CLANG_COMMON_FLAGS "-Wall -pedantic -Werror -Wparentheses -Wsequence-point -Wswitch-default -Wextra -Wundef -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)
set(LWIP_GNU_CLANG_COMMON_FLAGS "${LWIP_GNU_CLANG_COMMON_FLAGS} -Wredundant-decls")
endif()
if(CMAKE_C_COMPILER_ID STREQUAL GNU)
set(CMAKE_C_FLAGS "${LWIP_GNU_CLANG_COMMON_FLAGS} -Wlogical-op -Wc90-c99-compat -Wtrampolines")
set(CMAKE_C_FLAGS "${LWIP_GNU_CLANG_COMMON_FLAGS} -Wlogical-op -Wtrampolines")
if (NOT LWIP_HAVE_MBEDTLS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wc90-c99-compat")
endif()
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fstack-protector -fstack-check -fsanitize=undefined -fno-sanitize=alignment")
@ -15,14 +39,3 @@ endif()
if(CMAKE_C_COMPILER_ID STREQUAL MSVC)
# TODO
endif()
# ARM mbedtls support https://tls.mbed.org/
set(MBEDTLSDIR ${LWIP_CONTRIB_DIR}/../mbedtls)
if(EXISTS ${MBEDTLSDIR}/include/mbedtls/ssl.h)
set(ENABLE_PROGRAMS OFF CACHE BOOL "Prevent building MBEDTLS programs")
add_subdirectory(${LWIP_CONTRIB_DIR}/../mbedtls mbedtls)
add_definitions(-DLWIP_HAVE_MBEDTLS=1)
include_directories(${MBEDTLSDIR}/include)
link_libraries(mbedtls mbedcrypto mbedx509)
endif()

14
ports/unix/CMakeLists.txt

@ -12,14 +12,20 @@ set(lwipcontribportunix_SRCS
)
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
link_libraries(util)
link_libraries(pthread)
link_libraries(rt)
find_library(LIBUTIL util)
link_libraries(${LIBUTIL})
find_library(LIBPTHREAD pthread)
link_libraries(${LIBPTHREAD})
find_library(LIBRT rt)
link_libraries(${LIBRT})
endif()
if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
# Darwin doesn't have pthreads or POSIX real-time extensions libs
link_libraries(util)
find_library(LIBUTIL util)
link_libraries(${LIBUTIL})
endif()
add_library(lwipcontribportunix EXCLUDE_FROM_ALL ${lwipcontribportunix_SRCS})

10
ports/unix/unixsim/CMakeLists.txt

@ -10,15 +10,15 @@ include(${LWIP_CONTRIB_DIR}/ports/CMakeCommon.cmake)
add_definitions(-DLWIP_DEBUG)
include_directories(
"${LWIP_CONTRIB_DIR}/../lwip/src/include"
"${LWIP_DIR}/src/include"
"${LWIP_CONTRIB_DIR}/"
"${LWIP_CONTRIB_DIR}/ports/unix/port/include"
"${CMAKE_CURRENT_SOURCE_DIR}/./"
"${CMAKE_CURRENT_SOURCE_DIR}/"
)
add_subdirectory(../../../../lwip/src lwip)
add_subdirectory(../../../ contrib)
add_subdirectory(../ unixport)
add_subdirectory(${LWIP_DIR}/src lwip)
add_subdirectory(${LWIP_CONTRIB_DIR} contrib)
add_subdirectory(${LWIP_CONTRIB_DIR}/ports/unix unixport)
# lwipcontribaddons is specified multiple times in target_link_libraries because of cyclic dependency
# lwipcontribaddons call various functions in lwipcore

Loading…
Cancel
Save