Compare commits

...

2 Commits

Author SHA1 Message Date
Matthias Grob baace65379 mavlink: with cmake policy CMP0118 verion 3.20 we can depend on the mavlink_c library instead of including its content in multiple places
This works because the policy now allows to have the generated property available in other places than the library directory itself. Are we ready for cmake 3.20? Then we should increase the minimum version instead of just enabling the policy in a few files.
2024-06-21 15:37:07 +02:00
Matthias Grob 6e27db9490 mavlink: report generator error
Without this flag the command silently succeeds even though the logs contains
an error. It's much more developer friendly to fail early in case of an error.
The log path is then also shown in the console output.
2024-06-21 15:13:23 +02:00
4 changed files with 10 additions and 20 deletions
+5 -6
View File
@@ -31,6 +31,9 @@
#
############################################################################
# Make GENERATED property available outside of this directory e.g. for simulator_mavlink and mavlink_tests which depend on mavlink_c
cmake_policy(SET CMP0118 NEW)
set(MAVLINK_GIT_DIR "${CMAKE_CURRENT_LIST_DIR}/mavlink")
set(MAVLINK_LIBRARY_DIR "${CMAKE_BINARY_DIR}/mavlink")
file(RELATIVE_PATH MAVLINK_GIT_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${MAVLINK_GIT_DIR})
@@ -44,8 +47,7 @@ add_custom_command(
COMMAND
${PYTHON_EXECUTABLE} ${MAVLINK_GIT_DIR}/pymavlink/tools/mavgen.py
--lang C --wire-protocol 2.0
#--no-validate
#--strict-units
--exit-code
--output ${MAVLINK_LIBRARY_DIR}
${MAVLINK_GIT_DIR}/message_definitions/v1.0/${MAVLINK_DIALECT_UAVIONIX}.xml > ${CMAKE_CURRENT_BINARY_DIR}/mavgen_${MAVLINK_DIALECT_UAVIONIX}.log
DEPENDS
@@ -64,8 +66,7 @@ add_custom_command(
COMMAND
${PYTHON_EXECUTABLE} ${MAVLINK_GIT_DIR}/pymavlink/tools/mavgen.py
--lang C --wire-protocol 2.0
#--no-validate
#--strict-units
--exit-code
--output ${MAVLINK_LIBRARY_DIR}
${MAVLINK_GIT_DIR}/message_definitions/v1.0/${CONFIG_MAVLINK_DIALECT}.xml > ${CMAKE_CURRENT_BINARY_DIR}/mavgen_${CONFIG_MAVLINK_DIALECT}.log
DEPENDS
@@ -80,11 +81,9 @@ add_custom_command(
COMMENT "Generating Mavlink ${CONFIG_MAVLINK_DIALECT}: ${MAVLINK_GIT_DIR_RELATIVE}/message_definitions/v1.0/${CONFIG_MAVLINK_DIALECT}.xml"
)
add_custom_target(mavlink_c_generate DEPENDS ${MAVLINK_LIBRARY_DIR}/${CONFIG_MAVLINK_DIALECT}/${CONFIG_MAVLINK_DIALECT}.h)
set_source_files_properties(${MAVLINK_LIBRARY_DIR}/${CONFIG_MAVLINK_DIALECT}/${CONFIG_MAVLINK_DIALECT}.h PROPERTIES GENERATED true)
# mavlink header only library
add_library(mavlink_c INTERFACE)
target_compile_options(mavlink_c INTERFACE -Wno-address-of-packed-member -Wno-cast-align)
@@ -93,9 +93,7 @@ extern mavlink_status_t *mavlink_get_channel_status(uint8_t chan);
extern mavlink_message_t *mavlink_get_channel_buffer(uint8_t chan);
#include <mavlink.h>
#if !MAVLINK_FTP_UNIT_TEST
#include <uAvionix.h>
#endif
__END_DECLS
@@ -35,16 +35,12 @@ px4_add_module(
MODULE modules__mavlink__mavlink_tests
MAIN mavlink_tests
STACK_MAIN 8192
INCLUDES
${MAVLINK_LIBRARY_DIR}
${MAVLINK_LIBRARY_DIR}/${CONFIG_MAVLINK_DIALECT}
COMPILE_FLAGS
-DMAVLINK_FTP_UNIT_TEST
#-DMAVLINK_FTP_DEBUG
-DMavlinkStream=MavlinkStreamTest
-DMavlinkFTP=MavlinkFTPTest
-Wno-cast-align # TODO: fix and enable
-Wno-address-of-packed-member # TODO: fix in c_library_v2
-Wno-double-promotion # The fix has been proposed as PR upstream (2020-03-08)
SRCS
mavlink_tests.cpp
@@ -52,5 +48,5 @@ px4_add_module(
../mavlink_stream.cpp
../mavlink_ftp.cpp
DEPENDS
mavlink_c_generate
mavlink_c
)
@@ -31,23 +31,20 @@
#
############################################################################
# Make GENERATED property from mavlink_c available
cmake_policy(SET CMP0118 NEW)
px4_add_module(
MODULE modules__simulation__simulator_mavlink
MAIN simulator_mavlink
COMPILE_FLAGS
-Wno-double-promotion
-Wno-cast-align
-Wno-address-of-packed-member # TODO: fix in c_library_v2
INCLUDES
${CMAKE_BINARY_DIR}/mavlink
${CMAKE_BINARY_DIR}/mavlink/development
${CMAKE_BINARY_DIR}/mavlink/common
${CMAKE_BINARY_DIR}/mavlink/standard
SRCS
SimulatorMavlink.cpp
SimulatorMavlink.hpp
DEPENDS
mavlink_c_generate
mavlink_c
conversion
geo
drivers_accelerometer