ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
![]() | 1 | initial version |
@duck-development's solution will most probably work.
However, it is recommended to not tinker around with CMAKE_C_FLAGS
and CMAKE_CXX_FLAGS
.
Another way to achieve this is (directly taken from the rosbuild to catkin migration guide:
# let cmake find OpenMP and set some variables
find_package(OpenMP REQUIRED)
if(OPENMP_FOUND)
message(STATUS "OPENMP FOUND")
set(OpenMP_FLAGS ${OpenMP_CXX_FLAGS}) # or if you use C: ${OpenMP_C_FLAGS}
set(OpenMP_LIBS gomp)
endif()
...
# the entry in catkin_package could be optional (I am not fully sure about this)
catkin_package(
DEPENDS
OpenMP
)
...
# exemplary executable foo using OpenMP
add_executable(foo
ros/src/foo_node.cpp
)
target_compile_options(foo PRIVATE ${OpenMP_FLAGS})
add_dependencies(foo ${catkin_EXPORTED_TARGETS})
target_link_libraries(foo
${catkin_LIBRARIES}
${OpenMP_LIBS}
)