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

How can I set common cmake flags for all my packages?

asked 2015-11-06 05:11:36 -0600

msporyshev gravatar image

updated 2022-01-22 16:16:31 -0600

Evgeny gravatar image

I want to setup cxx compiler flags common for all my packages, but I can't edit CMakeLists.txt in my catkin workspace folder. I can edit only separate catkin packages CMakeLists.txt. What should I do?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-11-06 06:58:02 -0600

dornhege gravatar image

You can pass cmake options to catkin_make, e.g., catkin_make -DCMAKE_BUILD_TYPE=Debug.

edit flag offensive delete link more

answered 2015-11-06 09:10:20 -0600

gvdhoorn gravatar image

updated 2015-11-06 09:11:31 -0600

Two other 'alternatives':

  1. make use of catkin_tools' profiles to store CMake and / or make flags (this basically adds some convenience to @dornhege's suggestion)
  2. create a catkin package that exports your shared build flags in a CFG_EXTRAS file (see catkin - Developers Guide - Extracted CMake API reference - catkin_package() and this answer for some more information). This approach would require all of your other packages that need to use those flags to build_depend on your 'shared-flags' package and add them to their CMAKE_CXX_FLAGS variable though (but most of that can be automated).
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-11-06 05:10:42 -0600

Seen: 783 times

Last updated: Nov 06 '15