Adding custom message to existing package (Humble + Ubuntu22) fails
Hi there, I am trying to integrate an existing functioning package with a custom message(so far it has been divided to two projects).
I am failing when trying to modify the CMakeLists with the following interface:
rosidl_generate_interfaces(${PROJECT_NAME}
${msg_files}
)
I am getting the following error:
CMake Error at /opt/ros/humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:213 (add_custom_target):
add_custom_target cannot create target "myPackage" because another target
with the same name already exists. The existing target is a shared library
created in source directory "/home/user/ros2_ws/src/inuros2". See
documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
CMakeLists.txt:110 (rosidl_generate_interfaces)
My Cmake up to that point is as follows:
cmake_minimum_required(VERSION 3.8)
project(myPackage)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
find_package(ament_cmake REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(rosidl_default_generators REQUIRED)
set (SOURCES
...
)
set (INCLUDES
...
)
add_library(${PROJECT_NAME} SHARED
${INCLUDES}
${SOURCES}
)
set(dependencies
cv_bridge
rclcpp
...
)
ament_target_dependencies(${PROJECT_NAME}
${dependencies}
)
rclcpp_components_register_node(${PROJECT_NAME}
PLUGIN "Class::NodeName"
EXECUTABLE MyPackageExecutable
)
set(msg_files
"msg/Features.msg"
)
rosidl_generate_interfaces(${PROJECT_NAME}
${msg_files}
)
Any help would be great.
Thanks!