|
1 | 1 | cmake_minimum_required(VERSION 3.17)
|
2 | 2 |
|
3 |
| -set(TOP "../../..") |
4 |
| -get_filename_component(TOP "${TOP}" REALPATH) |
| 3 | +include(${CMAKE_CURRENT_LIST_DIR}/../../../hw/bsp/family_support.cmake) |
5 | 4 |
|
6 |
| -if (EXISTS ${TOP}/lib/lwip/src) |
7 |
| - include(${TOP}/hw/bsp/family_support.cmake) |
| 5 | +set(LWIP ${TOP}/lib/lwip) |
| 6 | +if (NOT EXISTS ${LWIP}/src) |
| 7 | + MESSAGE(WARNING "lib/lwip submodule not found, please run 'python tools/get_deps.py lib/lwip' to fetch it") |
| 8 | + return() |
| 9 | +endif() |
8 | 10 |
|
9 |
| - # gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>) |
10 |
| - family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) |
| 11 | +# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>) |
| 12 | +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) |
11 | 13 |
|
12 |
| - project(${PROJECT} C CXX ASM) |
| 14 | +project(${PROJECT} C CXX ASM) |
13 | 15 |
|
14 |
| - # Checks this example is valid for the family and initializes the project |
15 |
| - family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) |
| 16 | +# Checks this example is valid for the family and initializes the project |
| 17 | +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) |
16 | 18 |
|
17 |
| - add_executable(${PROJECT}) |
| 19 | +add_executable(${PROJECT}) |
18 | 20 |
|
19 |
| - # Example source |
20 |
| - target_sources(${PROJECT} PUBLIC |
21 |
| - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c |
22 |
| - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c |
23 |
| - ) |
| 21 | +# Example source |
| 22 | +target_sources(${PROJECT} PUBLIC |
| 23 | + ${CMAKE_CURRENT_LIST_DIR}/src/main.c |
| 24 | + ${CMAKE_CURRENT_LIST_DIR}/src/usb_descriptors.c |
| 25 | + ) |
24 | 26 |
|
25 |
| - # Example include |
26 |
| - target_include_directories(${PROJECT} PUBLIC |
27 |
| - ${CMAKE_CURRENT_SOURCE_DIR}/src |
28 |
| - ${TOP}/lib/lwip/src/include |
29 |
| - ${TOP}/lib/lwip/src/include/ipv4 |
30 |
| - ${TOP}/lib/lwip/src/include/lwip/apps |
31 |
| - ${TOP}/lib/networking |
32 |
| - ) |
| 27 | +# Example include |
| 28 | +target_include_directories(${PROJECT} PUBLIC |
| 29 | + ${CMAKE_CURRENT_LIST_DIR}/src |
| 30 | + ${LWIP}/src/include |
| 31 | + ${LWIP}/src/include/ipv4 |
| 32 | + ${LWIP}/src/include/lwip/apps |
| 33 | + ${TOP}/lib/networking |
| 34 | + ) |
33 | 35 |
|
34 |
| - target_sources(${PROJECT} PUBLIC |
35 |
| - ${TOP}/lib/lwip/src/core/altcp.c |
36 |
| - ${TOP}/lib/lwip/src/core/altcp_alloc.c |
37 |
| - ${TOP}/lib/lwip/src/core/altcp_tcp.c |
38 |
| - ${TOP}/lib/lwip/src/core/def.c |
39 |
| - ${TOP}/lib/lwip/src/core/dns.c |
40 |
| - ${TOP}/lib/lwip/src/core/inet_chksum.c |
41 |
| - ${TOP}/lib/lwip/src/core/init.c |
42 |
| - ${TOP}/lib/lwip/src/core/ip.c |
43 |
| - ${TOP}/lib/lwip/src/core/mem.c |
44 |
| - ${TOP}/lib/lwip/src/core/memp.c |
45 |
| - ${TOP}/lib/lwip/src/core/netif.c |
46 |
| - ${TOP}/lib/lwip/src/core/pbuf.c |
47 |
| - ${TOP}/lib/lwip/src/core/raw.c |
48 |
| - ${TOP}/lib/lwip/src/core/stats.c |
49 |
| - ${TOP}/lib/lwip/src/core/sys.c |
50 |
| - ${TOP}/lib/lwip/src/core/tcp.c |
51 |
| - ${TOP}/lib/lwip/src/core/tcp_in.c |
52 |
| - ${TOP}/lib/lwip/src/core/tcp_out.c |
53 |
| - ${TOP}/lib/lwip/src/core/timeouts.c |
54 |
| - ${TOP}/lib/lwip/src/core/udp.c |
55 |
| - ${TOP}/lib/lwip/src/core/ipv4/autoip.c |
56 |
| - ${TOP}/lib/lwip/src/core/ipv4/dhcp.c |
57 |
| - ${TOP}/lib/lwip/src/core/ipv4/etharp.c |
58 |
| - ${TOP}/lib/lwip/src/core/ipv4/icmp.c |
59 |
| - ${TOP}/lib/lwip/src/core/ipv4/igmp.c |
60 |
| - ${TOP}/lib/lwip/src/core/ipv4/ip4.c |
61 |
| - ${TOP}/lib/lwip/src/core/ipv4/ip4_addr.c |
62 |
| - ${TOP}/lib/lwip/src/core/ipv4/ip4_frag.c |
63 |
| - ${TOP}/lib/lwip/src/netif/ethernet.c |
64 |
| - ${TOP}/lib/lwip/src/netif/slipif.c |
65 |
| - ${TOP}/lib/lwip/src/apps/http/httpd.c |
66 |
| - ${TOP}/lib/lwip/src/apps/http/fs.c |
67 |
| - ${TOP}/lib/networking/dhserver.c |
68 |
| - ${TOP}/lib/networking/dnserver.c |
69 |
| - ${TOP}/lib/networking/rndis_reports.c |
70 |
| - ) |
| 36 | +# lib/networking sources |
| 37 | +target_sources(${PROJECT} PUBLIC |
| 38 | + ${TOP}/lib/networking/dhserver.c |
| 39 | + ${TOP}/lib/networking/dnserver.c |
| 40 | + ${TOP}/lib/networking/rndis_reports.c |
| 41 | + ) |
71 | 42 |
|
72 |
| - # due to warnings from other net source, we need to prevent error from some of the warnings options |
73 |
| - target_compile_options(${PROJECT} PUBLIC |
74 |
| - -Wno-error=null-dereference |
75 |
| - -Wno-error=conversion |
76 |
| - -Wno-error=sign-conversion |
77 |
| - -Wno-error=sign-compare |
78 |
| - ) |
| 43 | +# lwip sources |
| 44 | +target_sources(${PROJECT} PUBLIC |
| 45 | + ${LWIP}/src/core/altcp.c |
| 46 | + ${LWIP}/src/core/altcp_alloc.c |
| 47 | + ${LWIP}/src/core/altcp_tcp.c |
| 48 | + ${LWIP}/src/core/def.c |
| 49 | + ${LWIP}/src/core/dns.c |
| 50 | + ${LWIP}/src/core/inet_chksum.c |
| 51 | + ${LWIP}/src/core/init.c |
| 52 | + ${LWIP}/src/core/ip.c |
| 53 | + ${LWIP}/src/core/mem.c |
| 54 | + ${LWIP}/src/core/memp.c |
| 55 | + ${LWIP}/src/core/netif.c |
| 56 | + ${LWIP}/src/core/pbuf.c |
| 57 | + ${LWIP}/src/core/raw.c |
| 58 | + ${LWIP}/src/core/stats.c |
| 59 | + ${LWIP}/src/core/sys.c |
| 60 | + ${LWIP}/src/core/tcp.c |
| 61 | + ${LWIP}/src/core/tcp_in.c |
| 62 | + ${LWIP}/src/core/tcp_out.c |
| 63 | + ${LWIP}/src/core/timeouts.c |
| 64 | + ${LWIP}/src/core/udp.c |
| 65 | + ${LWIP}/src/core/ipv4/autoip.c |
| 66 | + ${LWIP}/src/core/ipv4/dhcp.c |
| 67 | + ${LWIP}/src/core/ipv4/etharp.c |
| 68 | + ${LWIP}/src/core/ipv4/icmp.c |
| 69 | + ${LWIP}/src/core/ipv4/igmp.c |
| 70 | + ${LWIP}/src/core/ipv4/ip4.c |
| 71 | + ${LWIP}/src/core/ipv4/ip4_addr.c |
| 72 | + ${LWIP}/src/core/ipv4/ip4_frag.c |
| 73 | + ${LWIP}/src/netif/ethernet.c |
| 74 | + ${LWIP}/src/netif/slipif.c |
| 75 | + ${LWIP}/src/apps/http/httpd.c |
| 76 | + ${LWIP}/src/apps/http/fs.c |
| 77 | + ) |
79 | 78 |
|
80 |
| - # Configure compilation flags and libraries for the example... see the corresponding function |
81 |
| - # in hw/bsp/FAMILY/family.cmake for details. |
82 |
| - family_configure_device_example(${PROJECT}) |
83 |
| -endif() |
| 79 | +# due to warnings from other net source, we need to prevent error from some of the warnings options |
| 80 | +target_compile_options(${PROJECT} PUBLIC |
| 81 | + -Wno-error=null-dereference |
| 82 | + -Wno-error=conversion |
| 83 | + -Wno-error=sign-conversion |
| 84 | + -Wno-error=sign-compare |
| 85 | + ) |
| 86 | + |
| 87 | +# Configure compilation flags and libraries for the example... see the corresponding function |
| 88 | +# in hw/bsp/FAMILY/family.cmake for details. |
| 89 | +family_configure_device_example(${PROJECT}) |
0 commit comments