From 2124becd04ea5661b0037cf04fdb7042c78aee04 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Mon, 8 Oct 2018 20:57:06 +0200 Subject: [PATCH] Give lwIP a top-level CMakeLists.txt (as it is common in other projects) This breaks iteropts.sh for now --- .vscode/tasks.json | 12 ++++++------ CMakeLists.txt | 13 +++++++++++-- contrib/ports/CMakeCommon.cmake | 4 ++-- contrib/ports/unix/example_app/CMakeLists.txt | 12 +----------- contrib/ports/win32/example_app/CMakeLists.txt | 10 ---------- 5 files changed, 20 insertions(+), 31 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 1d002482..4f589ac8 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -13,10 +13,10 @@ "isDefault": true }, "linux": { - "command": "cd ${workspaceFolder}/contrib/ports/unix/example_app/build && cmake --build ." + "command": "cd ${workspaceFolder}/build && cmake --build ." }, "windows": { - "command": "cd ${workspaceFolder}/contrib/ports/win32/example_app/build; cmake --build ." + "command": "cd ${workspaceFolder}/build; cmake --build ." } }, { @@ -25,10 +25,10 @@ "problemMatcher": "$gcc", "group": "build", "linux": { - "command": "cd ${workspaceFolder}/contrib/ports/unix/example_app && mkdir build && cd build && cmake .." + "command": "cd ${workspaceFolder} && mkdir build && cd build && cmake .." }, "windows": { - "command": "cd ${workspaceFolder}/contrib/ports/win32/example_app; mkdir build; cd build; cmake .." + "command": "cd ${workspaceFolder}; mkdir build; cd build; cmake .." } }, { @@ -37,10 +37,10 @@ "problemMatcher": [], "group": "none", "linux": { - "command": "cd ${workspaceFolder}/contrib/ports/unix/example_app/build && cmake --build . --target lwipdocs" + "command": "cd ${workspaceFolder}/build && cmake --build . --target lwipdocs" }, "windows": { - "command": "cd ${workspaceFolder}/contrib/ports/win32/example_app/build; cmake --build . --target lwipdocs" + "command": "cd ${workspaceFolder}/build; cmake --build . --target lwipdocs" }, } ] diff --git a/CMakeLists.txt b/CMakeLists.txt index f05c0f61..563f583d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,19 @@ cmake_minimum_required(VERSION 3.7) project(lwIP) +# Example lwIP application set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -include(src/Filelists.cmake) +include(${LWIP_DIR}/contrib/ports/CMakeCommon.cmake) -# Package generation +set (LWIP_DEFINITIONS LWIP_DEBUG=1) + +if (${CMAKE_SYSTEM_NAME} STREQUAL Windows) + add_subdirectory(${LWIP_CONTRIB_DIR}/ports/win32/example_app) +else() + add_subdirectory(${LWIP_CONTRIB_DIR}/ports/unix/example_app) +endif() + +# Source package generation set(CPACK_SOURCE_GENERATOR "ZIP") set(CPACK_SOURCE_PACKAGE_DESCRIPTION_SUMMARY "lwIP lightweight IP stack") set(CPACK_PACKAGE_VERSION_MAJOR "${LWIP_VERSION_MAJOR}") diff --git a/contrib/ports/CMakeCommon.cmake b/contrib/ports/CMakeCommon.cmake index 7af829a3..d062b753 100644 --- a/contrib/ports/CMakeCommon.cmake +++ b/contrib/ports/CMakeCommon.cmake @@ -13,12 +13,12 @@ if(EXISTS ${MBEDTLSDIR}/CMakeLists.txt) # Prevent building MBEDTLS programs and tests set(ENABLE_PROGRAMS OFF CACHE BOOL "") set(ENABLE_TESTING OFF CACHE BOOL "") - + # mbedtls uses cmake. Sweet! add_subdirectory(${MBEDTLSDIR} mbedtls) set (LWIP_MBEDTLS_DEFINITIONS - -DLWIP_HAVE_MBEDTLS=1 + LWIP_HAVE_MBEDTLS=1 ) set (LWIP_MBEDTLS_INCLUDE_DIRS ${MBEDTLSDIR}/include diff --git a/contrib/ports/unix/example_app/CMakeLists.txt b/contrib/ports/unix/example_app/CMakeLists.txt index b756fcf2..c77acc34 100644 --- a/contrib/ports/unix/example_app/CMakeLists.txt +++ b/contrib/ports/unix/example_app/CMakeLists.txt @@ -1,13 +1,3 @@ -cmake_minimum_required(VERSION 3.8) - -project(example_app C) - -set (CMAKE_EXPORT_COMPILE_COMMANDS ON) - -set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) -include(${LWIP_DIR}/contrib/ports/CMakeCommon.cmake) - -set (LWIP_DEFINITIONS -DLWIP_DEBUG) set (LWIP_INCLUDE_DIRS "${LWIP_DIR}/src/include" "${LWIP_CONTRIB_DIR}/" @@ -28,4 +18,4 @@ target_link_libraries(example_app ${LWIP_SANITIZER_LIBS} lwipcontribexamples lwi add_executable(makefsdata ${lwipmakefsdata_SRCS}) target_compile_options(makefsdata PRIVATE ${LWIP_COMPILER_FLAGS}) target_include_directories(makefsdata PRIVATE ${LWIP_INCLUDE_DIRS}) -target_link_libraries(makefsdata ${LWIP_SANITIZER_LIBS}) \ No newline at end of file +target_link_libraries(makefsdata ${LWIP_SANITIZER_LIBS}) diff --git a/contrib/ports/win32/example_app/CMakeLists.txt b/contrib/ports/win32/example_app/CMakeLists.txt index 7fe5cba3..b1d7b109 100644 --- a/contrib/ports/win32/example_app/CMakeLists.txt +++ b/contrib/ports/win32/example_app/CMakeLists.txt @@ -1,13 +1,3 @@ -cmake_minimum_required(VERSION 3.8) - -project(example_app C) - -set (CMAKE_EXPORT_COMPILE_COMMANDS ON) - -set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) -include(${LWIP_DIR}/contrib/ports/CMakeCommon.cmake) - -set (LWIP_DEFINITIONS -DLWIP_DEBUG) set (LWIP_INCLUDE_DIRS "${LWIP_DIR}/src/include" "${LWIP_CONTRIB_DIR}/"