Browse Source

Work on CMake build system - Add CMake project for unit tests

master
Dirk Ziegelmeier 8 years ago
parent
commit
64da512d90
  1. 1
      .gitignore
  2. 45
      ports/unix/check/CMakeLists.txt

1
.gitignore vendored

@ -10,6 +10,7 @@
/ports/unix/unixsim/simnode
/ports/unix/unixsim/makefsdata
/ports/unix/minimal/echop
/ports/unix/check/build
/ports/win32/WindowsCMake/build
/ports/win32/msvc/Debug
/ports/win32/lwipcfg_msvc.h

45
ports/unix/check/CMakeLists.txt

@ -0,0 +1,45 @@
cmake_minimum_required(VERSION 3.8)
project(lwipunittests C)
if (NOT CMAKE_SYSTEM_NAME STREQUAL Linux AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
message(FATAL_ERROR "Unit test are currently only working on Linux or Darwin")
endif()
set(LWIP_CONTRIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../lwip)
include(${LWIP_CONTRIB_DIR}/ports/CMakeCommon.cmake)
if(CMAKE_C_COMPILER_ID STREQUAL Clang)
# check.h causes 'error: token pasting of ',' and __VA_ARGS__ is a GNU extension' with clang 9.0.0
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-gnu-zero-variadic-macro-arguments")
endif()
add_definitions(-DLWIP_DEBUG -DLWIP_NOASSERT_ON_ERROR)
include_directories(
"${LWIP_DIR}/test/unit"
"${LWIP_DIR}/src/include"
"${LWIP_CONTRIB_DIR}/"
"${LWIP_CONTRIB_DIR}/ports/unix/port/include"
"${CMAKE_CURRENT_SOURCE_DIR}/"
)
add_subdirectory(${LWIP_DIR}/src lwip)
include(${LWIP_DIR}/test/unit/Filelists.cmake)
add_executable(lwip_unittests ${LWIP_TESTFILES})
find_library(LIBCHECK check)
find_library(LIBM m)
find_library(LIBUTIL util)
find_library(LIBPTHREAD pthread)
find_library(LIBRT rt)
target_link_libraries(lwip_unittests lwipapps lwipcore ${LIBCHECK} ${LIBM} ${LIBUTIL} ${LIBPTHREAD} ${LIBRT})
if (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
# check installed via brew on Darwin doesn't have a separate subunit library (must be statically linked)
find_library(LIBSUBUNIT subunit)
target_link_libraries(lwip_unittests ${LIBSUBUNIT})
endif()
Loading…
Cancel
Save