ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Though it may be obvious from William's response, using the first method is more convenient and actually recommended. the consequence of using the latter is that all of the CMake functions/macros that utilize environment variables generated by find_package() have to have the corresponding variable listed as an argument. For C++ code, this particularly effects include_directories() and target_link_libraries(). Example:

Instead of :

include_directories(${catkin_INCLUDE_DIRS})

add_executable(foo ...)

target_link_libraries(foo ${catkin_LIBRARIES})

You would have:

include_directories(${catkin_INCLUDE_DIRS} ${roscpp_INCLUDE_DIRS} ${std_msgs_INCLUDE_DIRS})

add_executable(foo ...)

target_link_libraries(foo ${catkin_LIBRARIES} ${roscpp_LIBRARIES} ${std_msgs_LIBRARIES})

So save yourself effort and always find catkin packages as components of catkin!

Though it may be obvious from William's response, using the first method is more convenient and actually recommended. the consequence of using the latter is that all of the CMake functions/macros that utilize environment variables generated by find_package() have to have the corresponding variable listed as an argument. For C++ code, this particularly effects include_directories() and target_link_libraries(). Example:

Instead of :

include_directories(${catkin_INCLUDE_DIRS})include_directories(${catkin_INCLUDE_DIRS})
add_executable(foo ...)
target_link_libraries(foo ${catkin_LIBRARIES})

add_executable(foo ...)

target_link_libraries(foo ${catkin_LIBRARIES})

You would have:

include_directories(${catkin_INCLUDE_DIRS} ${roscpp_INCLUDE_DIRS} ${std_msgs_INCLUDE_DIRS})

${std_msgs_INCLUDE_DIRS}) add_executable(foo ...)

...) target_link_libraries(foo ${catkin_LIBRARIES} ${roscpp_LIBRARIES} ${std_msgs_LIBRARIES})${std_msgs_LIBRARIES})

So save yourself effort and always find catkin packages as components of catkin!