diff --git a/CMakeLists.txt b/CMakeLists.txt index c6633f070e9..30ea340b59c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,6 +217,13 @@ if(PYTHON_COVERAGE) set(PYTHON_EXECUTABLE coverage run -p) endif() +# external modules (before kconfig, which adds their messages to the Zenoh topic catalog) +set(EXTERNAL_MODULES_LOCATION "" CACHE STRING "External modules source location") + +if(NOT EXTERNAL_MODULES_LOCATION STREQUAL "") + get_filename_component(EXTERNAL_MODULES_LOCATION "${EXTERNAL_MODULES_LOCATION}" ABSOLUTE) +endif() + include(px4_config) include(kconfig) message(STATUS "PX4 config: ${PX4_CONFIG}") @@ -238,13 +245,6 @@ if(${PX4_PLATFORM} STREQUAL "posix") endif() endif() -# external modules -set(EXTERNAL_MODULES_LOCATION "" CACHE STRING "External modules source location") - -if(NOT EXTERNAL_MODULES_LOCATION STREQUAL "") - get_filename_component(EXTERNAL_MODULES_LOCATION "${EXTERNAL_MODULES_LOCATION}" ABSOLUTE) -endif() - set_property(GLOBAL PROPERTY PX4_MODULE_CONFIG_FILES) include(platforms/${PX4_PLATFORM}/cmake/px4_impl_os.cmake) diff --git a/cmake/kconfig.cmake b/cmake/kconfig.cmake index 5f844e956f8..d0394aeac38 100644 --- a/cmake/kconfig.cmake +++ b/cmake/kconfig.cmake @@ -41,6 +41,11 @@ file(GLOB zenoh_catalog_msg_files ${PX4_SOURCE_DIR}/msg/*.msg ${PX4_SOURCE_DIR}/msg/versioned/*.msg ) +# Out-of-tree messages, so that Zenoh can bridge them too +if(EXTERNAL_MODULES_LOCATION) + file(GLOB zenoh_catalog_external_msg_files ${EXTERNAL_MODULES_LOCATION}/msg/*.msg) + list(APPEND zenoh_catalog_msg_files ${zenoh_catalog_external_msg_files}) +endif() execute_process( COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/zenoh/px_generate_zenoh_topic_files.py --zenoh-config diff --git a/src/modules/zenoh/CMakeLists.txt b/src/modules/zenoh/CMakeLists.txt index f927bae2504..08bc895120e 100644 --- a/src/modules/zenoh/CMakeLists.txt +++ b/src/modules/zenoh/CMakeLists.txt @@ -90,14 +90,24 @@ if(CONFIG_ZENOH_SERIAL) target_compile_options(zenohpico_static PRIVATE -DZ_LINK_SERIAL) endif() +# PX4's topics, then those of out-of-tree messages listed in $EXTERNAL_MODULES_LOCATION/msg/dds_topics.yaml +set(dds_topics_files ${CMAKE_CURRENT_SOURCE_DIR}/dds_topics.yaml) +if(EXTERNAL_MODULES_LOCATION AND EXISTS ${EXTERNAL_MODULES_LOCATION}/msg/dds_topics.yaml) + list(APPEND dds_topics_files ${EXTERNAL_MODULES_LOCATION}/msg/dds_topics.yaml) +endif() +set(dds_topics_args) +foreach(dds_topics_file ${dds_topics_files}) + list(APPEND dds_topics_args --dds-topics-file ${dds_topics_file}) +endforeach() + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/default_topics.c COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../uxrce_dds_client/generate_dds_topics.py --client-outdir ${CMAKE_CURRENT_BINARY_DIR} - --dds-topics-file ${CMAKE_CURRENT_SOURCE_DIR}/dds_topics.yaml + ${dds_topics_args} --template_file ${CMAKE_CURRENT_SOURCE_DIR}/default_topics.c.em DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../uxrce_dds_client/generate_dds_topics.py - ${CMAKE_CURRENT_SOURCE_DIR}/dds_topics.yaml + ${dds_topics_files} ${CMAKE_CURRENT_SOURCE_DIR}/default_topics.c.em COMMENT "Generating Default config" )