From a928f30e2fdcda85aa1651ec26383d63d243abed Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Mon, 2 Dec 2024 17:06:27 +0100 Subject: [PATCH] Reorganize CMakeLists --- CMakeLists.txt | 13 ++++++++----- examples/rpi_pico_w/CMakeLists.txt | 24 +++++++++++++++++------- src/system/rpi_pico_w/network.c | 1 + 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91b9ed774..146b9f182 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,8 +91,10 @@ if(CMAKE_BUILD_TYPE MATCHES "RELEASE" OR "Release") add_compile_options(-pipe -O3) endif() else() - if(UNIX) - add_compile_options(-c -Wall -Wextra -Werror -Wshadow -Wunused -Wstrict-prototypes -pipe -g -O0) + if(CMAKE_SYSTEM_NAME MATCHES "PICO") + add_compile_options(-c -Wall -Wextra -Wno-unused -Wno-strict-prototypes -pipe -g -O0) + elseif(UNIX) + add_compile_options(-c -Wall -Wextra -Werror -Wshadow -Wunused -Wstrict-prototypes -pipe -g -O0) # C99 pedantic doesn't like struct anonymous in unix header if (NOT CMAKE_C_STANDARD STREQUAL "99") add_compile_options(-Wpedantic) @@ -159,7 +161,7 @@ if (NOT CMAKE_BUILD_TYPE MATCHES "RELEASE" OR "Release") set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") endif() -#set(CHECK_THREADS "ON") +set(CHECK_THREADS "ON") # System definition if(CMAKE_SYSTEM_NAME MATCHES "Linux") @@ -182,9 +184,10 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Generic") pico_add_compile_definition(ZENOH_ZEPHYR) elseif(WITH_FREERTOS_PLUS_TCP) pico_add_compile_definition(ZENOH_FREERTOS_PLUS_TCP) -elseif(WITH_RPI_PICO_W) - pico_add_compile_definition(ZENOH_RPI_PICO_W) endif() +elseif(CMAKE_SYSTEM_NAME MATCHES "PICO") # Raspberry Pico + pico_add_compile_definition(ZENOH_RPI_PICO_W) + set(CHECK_THREADS "OFF") else() message(FATAL_ERROR "zenoh-pico is not yet available on ${CMAKE_SYSTEM_NAME} platform") return() diff --git a/examples/rpi_pico_w/CMakeLists.txt b/examples/rpi_pico_w/CMakeLists.txt index b39470c7a..5c5517825 100644 --- a/examples/rpi_pico_w/CMakeLists.txt +++ b/examples/rpi_pico_w/CMakeLists.txt @@ -1,21 +1,27 @@ cmake_minimum_required(VERSION 3.13) +set(CMAKE_C_STANDARD 11) + +# Include Raspberry Pico SDK set(PICO_BOARD "pico_w") if(NOT DEFINED ENV{PICO_SDK_PATH}) message(FATAL_ERROR "PICO_SDK_PATH environment variable is not set. Please set it to the location of the Pico SDK.") endif() include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) +# Include FreeRTOS SDK include(FreeRTOS_Kernel_import.cmake) -include(../../cmake/helpers.cmake) -set_default_build_type(Release) +# Ignore warnings from FreeRTOS code +set_source_files_properties( + ${FREERTOS_KERNEL_PATH}/portable/ThirdParty/GCC/RP2040/include/portmacro.h + PROPERTIES + COMPILE_OPTIONS "-Wno-strict-prototypes" +) +# Configure project project(zenohpico_rpi_pico_w_examples C CXX ASM) -set(CMAKE_SYSTEM_NAME "Generic") -set(CMAKE_C_STANDARD 11) - add_compile_definitions(LWIP_TIMEVAL_PRIVATE=0) pico_sdk_init() @@ -25,11 +31,13 @@ add_executable(zenohpico_rpi_pico_w_examples main.c app_main.c) pico_enable_stdio_usb(zenohpico_rpi_pico_w_examples 1) pico_enable_stdio_uart(zenohpico_rpi_pico_w_examples 1) +# Include Zenoh Pico library +include(../../cmake/helpers.cmake) +set_default_build_type(Release) + set(BUILD_SHARED_LIBS OFF) set(WITH_RPI_PICO_W ON) set(ZENOH_DEBUG 5) -#add_compile_options(-Wno-strict-prototypes) -#add_compile_options(-Wno-pragmas) configure_include_project(ZENOHPICO zenohpico zenohpico::lib "../.." zenohpico "https://github.com/eclipse-zenoh/zenoh-pico" "") target_link_libraries(zenohpico_static @@ -38,6 +46,7 @@ target_link_libraries(zenohpico_static FreeRTOS-Kernel-Heap4 ) +# Configure build target_include_directories(zenohpico_static PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/.. @@ -60,3 +69,4 @@ target_link_libraries(zenohpico_rpi_pico_w_examples ) pico_add_extra_outputs(zenohpico_rpi_pico_w_examples) + diff --git a/src/system/rpi_pico_w/network.c b/src/system/rpi_pico_w/network.c index aaf5fc29f..2eccea503 100644 --- a/src/system/rpi_pico_w/network.c +++ b/src/system/rpi_pico_w/network.c @@ -203,6 +203,7 @@ z_result_t _z_listen_udp_unicast(_z_sys_net_socket_t *sock, const _z_sys_net_end (void)sock; (void)lep; (void)tout; + z_result_t ret = _Z_RES_OK; // @TODO: To be implemented ret = _Z_ERR_GENERIC;