{
cmake_minimum_required(VERSION 3.8)
project(my_value_converter_library)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(std_msgs REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
# let the compiler search for headers in the include folder
include_directories(include)
# define a library target called my_value_converter_library
add_library(my_value_converter_library src/my_value_converter_library.cpp)
# this line to exports the library
ament_export_targets(my_value_converter_library HAS_LIBRARY_TARGET)
# install the include/my_value_converter_library directory to the install/include/my_value_converter_library
install(
DIRECTORY include/my_value_converter_library
DESTINATION include
)
install(
TARGETS my_value_converter_library
EXPORT my_value_converter_library
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
ament_package()
@Dkae
Did you watch that video to the end? Some modifications were made to the CMakeLists.txt later in the video, and I can’t see them in the one you posted here.
Thank you for your response.
Yes I watched the video to the end.
In the video he does 2 things.
He does 1 package “my_value_converter_library” and another package “my_value_converter_node”.
In the first package he creates the library with the header file and in the second package he uses it.
Therefore the modification he does in the end, is just for the “my_value_converter_node” package CMakeList.txt.
But now I am just trying to change the “my_value_converter_library” package with adding a std_msgs/msg/float32 message.
And I am just trying to compile this modified “my_value_converter_library” package.
Therefore I don’t need to make there the changes, which he makes for the node-package.
So I am trying to create a library which has some dependencies, because the same issue I would get if my library for example depends on rclcpp or geometry_msg etc…
Therefore I would like to know, where do I need to add the dependencies in the CMakeList.txt for the library-package.
Also the code I am using, is the code from the open course, I downloaded it from the rosject. The only thing I did was adding the myFunction() with the std_msgs::msg::Float32 message.
Do you have any Idea where the std_msgs dependency needs to be added? I assume it should be possible.
I believe you are missing an ament_target_dependencies or since you are trying to build a library ament_export_depencies( my_value_converter_library std_msgs) in your CMakeLists.txt
Yes, you are right. I jumped to a conclusion too fast, thanks for correcting me.
What you could do to be bullet-proof-sure is to create the library with the needed dependencies from scratch (use could use another name and then compare the CMakeLists.txt and package.xml generated):