1# SPDX-License-Identifier: Apache-2.0 2 3cmake_minimum_required(VERSION 3.20.0) 4 5find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 6find_package(Python REQUIRED COMPONENTS Interpreter) 7 8project(prometheus_sample) 9 10if(CONFIG_NET_SOCKETS_SOCKOPT_TLS AND 11 CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED AND 12 (CONFIG_NET_SAMPLE_PSK_HEADER_FILE STREQUAL "dummy_psk.h")) 13 add_custom_target(development_psk 14 COMMAND ${CMAKE_COMMAND} -E echo "----------------------------------------------------------" 15 COMMAND ${CMAKE_COMMAND} -E echo "--- WARNING: Using dummy PSK! Only suitable for ---" 16 COMMAND ${CMAKE_COMMAND} -E echo "--- development. Set NET_SAMPLE_PSK_HEADER_FILE to use ---" 17 COMMAND ${CMAKE_COMMAND} -E echo "--- own pre-shared key. ---" 18 COMMAND ${CMAKE_COMMAND} -E echo "----------------------------------------------------------" 19 ) 20 add_dependencies(app development_psk) 21endif() 22 23 24target_sources(app PRIVATE src/main.c) 25target_sources_ifdef(CONFIG_NET_STATISTICS_VIA_PROMETHEUS app PRIVATE src/stats.c) 26 27set(gen_dir ${ZEPHYR_BINARY_DIR}/include/generated/) 28 29target_link_libraries(app PRIVATE zephyr_interface zephyr) 30 31zephyr_linker_sources(SECTIONS sections-rom.ld) 32zephyr_linker_section_ifdef(CONFIG_NET_SAMPLE_HTTPS_SERVICE NAME 33 http_resource_desc_test_https_service 34 KVMA RAM_REGION GROUP RODATA_REGION 35 SUBALIGN Z_LINK_ITERABLE_SUBALIGN) 36zephyr_linker_section_ifdef(CONFIG_NET_SAMPLE_HTTP_SERVICE NAME 37 http_resource_desc_test_http_service 38 KVMA RAM_REGION GROUP RODATA_REGION 39 SUBALIGN Z_LINK_ITERABLE_SUBALIGN) 40 41foreach(inc_file 42 ca.der 43 server.der 44 server_privkey.der 45 https-server-cert.der 46 https-server-key.der 47 ) 48 generate_inc_file_for_target( 49 app 50 src/${inc_file} 51 ${gen_dir}/${inc_file}.inc 52 ) 53endforeach() 54