1# SPDX-License-Identifier: Apache-2.0
2
3cmake_minimum_required(VERSION 3.20.0)
4find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
5project(socket_udp)
6
7function(generate_c_string FILENAME SIZE)
8  set(FILEPATH ${ZEPHYR_BINARY_DIR}/include/generated/${FILENAME})
9
10  add_custom_command(
11    OUTPUT ${FILEPATH}
12    COMMAND
13    ${PYTHON_EXECUTABLE}
14    ${CMAKE_CURRENT_LIST_DIR}/generate-c-string.py
15    --size ${SIZE}
16    ${FILEPATH})
17
18  generate_unique_target_name_from_filename(${FILEPATH} TARGET_NAME)
19  add_custom_target(${TARGET_NAME} DEPENDS
20    ${FILEPATH})
21  add_dependencies(app ${TARGET_NAME})
22endfunction()
23
24math(EXPR
25  ALL_TX_BUFS_SIZE
26  "${CONFIG_NET_BUF_TX_COUNT} * ${CONFIG_NET_BUF_DATA_SIZE}"
27  OUTPUT_FORMAT DECIMAL)
28generate_c_string(string_all_tx_bufs.inc ${ALL_TX_BUFS_SIZE})
29
30target_include_directories(app PRIVATE ${ZEPHYR_BASE}/subsys/net/ip)
31FILE(GLOB app_sources src/*.c)
32target_sources(app PRIVATE ${app_sources})
33