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

How do I set global cmake flags catkin

asked 2015-01-25 01:16:20 -0500

aswin gravatar image

Hi all, So far I have only used catkin to do a normal build using catkin_make and a release build using catkin_make -DCMAKE_BUILD_TYPE=Release.

However, I would like to set more CMAKE_CXX_FLAGS and various other options globally for multiple packages in my workspace. How do I do this?

Do I modify the top level cmake? Are there any examples for the same?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-01-25 01:36:34 -0500

Dirk Thomas gravatar image

catkin_make --help will show that it accepts any CMake arguments with -Dname=value.

edit flag offensive delete link more


Thank you Dirk. Would it be possible to set these flags in /opt/ros/indigo/share/catkin/cmake/toplevel.cmake? Or override the CMakeLists.txt in your workspace?

aswin gravatar image aswin  ( 2015-01-25 01:58:53 -0500 )edit

Technically yes, you can replace the symlink of the CMake file in the root of your workspace with a modified version. Or even change the system wide file. But I would recommend passing the parameter once - it is persistent and you don't have to pass it again.

Dirk Thomas gravatar image Dirk Thomas  ( 2015-01-25 02:42:16 -0500 )edit

I would recommend a CMake toolchain file for this. It will allow you to set settings for all packages.

William gravatar image William  ( 2015-01-25 02:47:45 -0500 )edit

Great answers. Dirk, its good to know I only have to do this once.

William, so I do catkin_make -DCMAKE_TOOLCHAIN_FILE=~/myToolChain.cmake. In this file I can enter lines like: set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}). Is this correct?

aswin gravatar image aswin  ( 2015-01-25 05:06:30 -0500 )edit

Something like that, the toolchain file is mostly for cross-compiling, but you could use it for this. I'd suggesting looking at:

William gravatar image William  ( 2015-01-25 20:21:23 -0500 )edit

Thank you guys. Will add a note somewhere in the wiki when I get it running

aswin gravatar image aswin  ( 2015-01-25 21:34:46 -0500 )edit

Question Tools

1 follower


Asked: 2015-01-25 01:16:20 -0500

Seen: 5,721 times

Last updated: Jan 25 '15