-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
56 lines (47 loc) · 1.9 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
cmake_minimum_required(VERSION 3.22.1)
# Uncomment for (gdbserver) debugging
if(BOARD MATCHES "qemu_.*")
list(APPEND QEMU_EXTRA_FLAGS -serial tcp:127.0.0.1:5678,server)
endif()
if(BOARD MATCHES "rpi_pico")
set(ZENOHPICO_CFLAGS "-DZENOH_NO_STDATOMIC")
endif()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(zenoh_hello_world)
include(ExternalProject)
include(CMakePrintHelpers)
zephyr_get_system_include_directories_for_lang_as_string(C ext_system_includes)
zephyr_get_include_directories_for_lang_as_string(C ext_includes)
zephyr_get_compile_definitions_for_lang_as_string(C ext_defs)
zephyr_get_compile_options_for_lang_as_String(C ext_opts)
set(ZENOHPICO_CFLAGS
"${ZENOHPICO_CFLAGS} ${ext_defs} ${ext_system_includes} ${ext_includes} ${ext_opts}"
)
set(ZENOHPICO_LIB_DIR ${CMAKE_SOURCE_DIR}/build/zenoh-pico-prefix/lib)
set(ZENOHPICO_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/build/zenoh-pico-prefix/include)
ExternalProject_Add(zenoh-pico
GIT_REPOSITORY https://github.com/cguimaraes/zenoh-pico.git
GIT_TAG zephyr-module
BUILD_COMMAND ${CMAKE_COMMAND} --build .
CMAKE_ARGS
-DWITH_ZEPHYR=1 -DBUILD_INTEGRATION=OFF -DBUILD_TOOLS=OFF -DBUILD_TESTING=OFF -DBUILD_MULTICAST=OFF
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_VERBOSE_MAKEFILE=1
-DCMAKE_C_FLAGS=${ZENOHPICO_CFLAGS}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_SYSTEM_NAME=Generic
-DCMAKE_BUILD_TYPE=Debug
DEPENDS zephyr_interface
BUILD_BYPRODUCTS ${ZENOHPICO_LIB_DIR}/libzenohpico.a
)
add_library(zenohpico_lib STATIC IMPORTED GLOBAL)
add_dependencies(zenohpico_lib zenoh-pico)
set_target_properties(zenohpico_lib PROPERTIES IMPORTED_LOCATION ${ZENOHPICO_LIB_DIR}/libzenohpico.a)
add_definitions(-DZENOH_ZEPHYR)
target_include_directories(app PUBLIC ${ZENOHPICO_INCLUDE_DIR})
target_link_libraries(app PUBLIC zenohpico_lib)
target_sources(app
PRIVATE
src/main.c
)