2025-01-03 15:09:13 +07:00
|
|
|
cmake_minimum_required(VERSION 3.20)
|
2021-01-25 13:28:23 +07:00
|
|
|
|
2023-05-26 15:16:18 +07:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/../../../hw/bsp/family_support.cmake)
|
2021-01-25 13:28:23 +07:00
|
|
|
|
2023-07-18 09:02:59 -05:00
|
|
|
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
|
|
|
|
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
|
|
|
|
|
2024-07-18 11:08:23 +01:00
|
|
|
# Prefer the tinyusb lwip
|
2023-05-26 15:16:18 +07:00
|
|
|
set(LWIP ${TOP}/lib/lwip)
|
2024-07-18 11:08:23 +01:00
|
|
|
|
|
|
|
# If we can't find one from tinyusb then check cmake var before giving up
|
|
|
|
if (NOT EXISTS ${LWIP}/src)
|
|
|
|
set(LWIP ${TINYUSB_LWIP_PATH})
|
|
|
|
endif()
|
|
|
|
|
2023-05-26 15:16:18 +07:00
|
|
|
if (NOT EXISTS ${LWIP}/src)
|
2023-07-18 09:02:59 -05:00
|
|
|
family_example_missing_dependency(${PROJECT} "lib/lwip")
|
2023-05-26 15:16:18 +07:00
|
|
|
return()
|
|
|
|
endif()
|
2021-01-25 13:28:23 +07:00
|
|
|
|
2023-05-26 15:16:18 +07:00
|
|
|
project(${PROJECT} C CXX ASM)
|
2021-01-25 13:28:23 +07:00
|
|
|
|
2023-05-26 15:16:18 +07:00
|
|
|
# Checks this example is valid for the family and initializes the project
|
|
|
|
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
|
2021-05-30 18:41:07 -05:00
|
|
|
|
2023-05-26 15:16:18 +07:00
|
|
|
add_executable(${PROJECT})
|
2021-05-30 18:41:07 -05:00
|
|
|
|
2023-05-26 15:16:18 +07:00
|
|
|
# Example source
|
|
|
|
target_sources(${PROJECT} PUBLIC
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/main.c
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/usb_descriptors.c
|
|
|
|
)
|
2021-05-30 18:41:07 -05:00
|
|
|
|
2023-05-26 15:16:18 +07:00
|
|
|
# Example include
|
|
|
|
target_include_directories(${PROJECT} PUBLIC
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src
|
|
|
|
${LWIP}/src/include
|
|
|
|
${LWIP}/src/include/ipv4
|
|
|
|
${LWIP}/src/include/lwip/apps
|
|
|
|
${TOP}/lib/networking
|
|
|
|
)
|
2021-05-30 18:41:07 -05:00
|
|
|
|
2023-05-26 15:16:18 +07:00
|
|
|
# lib/networking sources
|
|
|
|
target_sources(${PROJECT} PUBLIC
|
|
|
|
${TOP}/lib/networking/dhserver.c
|
|
|
|
${TOP}/lib/networking/dnserver.c
|
|
|
|
${TOP}/lib/networking/rndis_reports.c
|
|
|
|
)
|
2021-05-30 18:41:07 -05:00
|
|
|
|
2023-05-26 15:16:18 +07:00
|
|
|
# lwip sources
|
|
|
|
target_sources(${PROJECT} PUBLIC
|
|
|
|
${LWIP}/src/core/altcp.c
|
|
|
|
${LWIP}/src/core/altcp_alloc.c
|
|
|
|
${LWIP}/src/core/altcp_tcp.c
|
|
|
|
${LWIP}/src/core/def.c
|
|
|
|
${LWIP}/src/core/dns.c
|
|
|
|
${LWIP}/src/core/inet_chksum.c
|
|
|
|
${LWIP}/src/core/init.c
|
|
|
|
${LWIP}/src/core/ip.c
|
|
|
|
${LWIP}/src/core/mem.c
|
|
|
|
${LWIP}/src/core/memp.c
|
|
|
|
${LWIP}/src/core/netif.c
|
|
|
|
${LWIP}/src/core/pbuf.c
|
|
|
|
${LWIP}/src/core/raw.c
|
|
|
|
${LWIP}/src/core/stats.c
|
|
|
|
${LWIP}/src/core/sys.c
|
|
|
|
${LWIP}/src/core/tcp.c
|
|
|
|
${LWIP}/src/core/tcp_in.c
|
|
|
|
${LWIP}/src/core/tcp_out.c
|
|
|
|
${LWIP}/src/core/timeouts.c
|
|
|
|
${LWIP}/src/core/udp.c
|
|
|
|
${LWIP}/src/core/ipv4/autoip.c
|
|
|
|
${LWIP}/src/core/ipv4/dhcp.c
|
|
|
|
${LWIP}/src/core/ipv4/etharp.c
|
|
|
|
${LWIP}/src/core/ipv4/icmp.c
|
|
|
|
${LWIP}/src/core/ipv4/igmp.c
|
|
|
|
${LWIP}/src/core/ipv4/ip4.c
|
|
|
|
${LWIP}/src/core/ipv4/ip4_addr.c
|
|
|
|
${LWIP}/src/core/ipv4/ip4_frag.c
|
|
|
|
${LWIP}/src/netif/ethernet.c
|
|
|
|
${LWIP}/src/netif/slipif.c
|
|
|
|
${LWIP}/src/apps/http/httpd.c
|
|
|
|
${LWIP}/src/apps/http/fs.c
|
2024-05-07 00:23:50 +02:00
|
|
|
${LWIP}/src/apps/lwiperf/lwiperf.c
|
2023-05-26 15:16:18 +07:00
|
|
|
)
|
2022-06-27 17:53:42 +07:00
|
|
|
|
2023-05-26 15:16:18 +07:00
|
|
|
# due to warnings from other net source, we need to prevent error from some of the warnings options
|
2023-06-02 13:27:18 +07:00
|
|
|
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|
|
|
target_compile_options(${PROJECT} PUBLIC
|
|
|
|
-Wno-error=null-dereference
|
|
|
|
-Wno-error=conversion
|
|
|
|
-Wno-error=sign-conversion
|
|
|
|
-Wno-error=sign-compare
|
|
|
|
)
|
|
|
|
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
|
|
|
|
|
|
|
endif ()
|
2023-05-26 15:16:18 +07:00
|
|
|
|
2023-06-27 15:45:38 +07:00
|
|
|
# Configure compilation flags and libraries for the example without RTOS.
|
|
|
|
# See the corresponding function in hw/bsp/FAMILY/family.cmake for details.
|
|
|
|
family_configure_device_example(${PROJECT} noos)
|