Skip to content

Need help to add ament_index_register_resource in px4_msgs CMakeLists.txt #177

@agwegsol

Description

@agwegsol

I am trying to use the latest px4-ros2-interface-lib but is having a problem with the build system.

Note, I am not using colcon, since I compile is a virtual plus cross compile environment. Colcon gets confused since it assumes "stuff" and start using the native objects during compile. This is a no go, so I am using pure CMake.

But I can not build latest px4-ros2-interface-lib do to this line in the CMakefile.txt
ament_index_get_resource(MESSAGE_FILES "rosidl_interfaces" px4_msgs)

From what I can read in the CMakeLists.txt file, the line is used to generate a header file containing all px4_msgs header files. The list is fetched from the px4_msgs CMake cache using ament_index_get_resource. But the resource is not there and thus needs to be added.
If I compile using SHA=396120292cc70014c37646d30fccc2c62a649458, just before the commit adding the header file all compile just fine so my setup is working (sort of)

I am using ros2 kilted in both native in cross compile environment, all in a virtual env.

I compile the px4_msgs using this CMakeLists.txt, from https://github.com/PX4/px4_msgs

cmake_minimum_required(VERSION 3.5)

project(px4_msgs)

list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
	add_compile_options(-Wall -Wextra)
endif()

find_package(ament_cmake REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(rosidl_default_generators REQUIRED)

# ##############################################################################
# Generate ROS messages, ROS2 interfaces and IDL files #
# ##############################################################################

# get all msg files
set(MSGS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/msg")
file(GLOB PX4_MSGS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${MSGS_DIR}/*.msg")

# get all srv files
set(SRVS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/srv")
file(GLOB PX4_SRVS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${SRVS_DIR}/*.srv")

# Generate introspection typesupport for C and C++ and IDL files
rosidl_generate_interfaces(${PROJECT_NAME}
	${PX4_MSGS}
	${PX4_SRVS}
	DEPENDENCIES builtin_interfaces
)

ament_export_dependencies(rosidl_default_runtime)

ament_package()

But there is no ament_index_register_resource and I think this is the problem
I have read the Ament-CMake-Documentation, did some trail and error but did not manage to make it work. So, does someone know how to add the resource?

A hint will be most appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions