How to properly build include a small library/namespace in a ROS-Project
I have a ROS project consisting of several nodes each of which is built from the CMakeLists like this:
add_executable(node1 src/node1.cpp src/node1callback.cpp)
target_link_libraries(node1 ${catkin_LIBRARIES})
add_dependencies(node 1 my_ros_project_generate_messages_cpp)
Now I would like to write a small library (not sure if this is the right word) consisting of a .h and a .cpp file defining a namespace with a couple of functions that I use in multiple nodes.
Now my question is: How do I add this library to the CMakeLists? Do I add it in the same way even though it's not a node?
An observation: please realise this is not ROS-specific, but a general CMake workflow question.
add_library(..)
as suggested by @Sebastian Kasperski is a regular CMake function, and the rest of the additions/changes to yourCMakeLists.txt
would be as well.@gvdhoorn You are right, sorry. I'll consider other forums the next time.
@max11gen: I did not make my comment to tell you to go to other fora. I merely wanted to make sure you did not assume this was something ROS-specific.
Many times I've had to explain that Catkin is essentially "some" convenience macros for CMake. Just wanted to make sure you understood that.