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

You can set the build type in the CMake but it's not recommended to hard code the build type in the CMakeLists.txt but to pass it on the command line when you build. This way if you want to build with debug you just change your invocation instead of having to change the code. This is particularly important if you have a large workspace with lots of packages. If you wanted to change the build type you'd have to modify every package's CMakeLists.txt which is a pain and messy if you have other changes nearby.

cmake -DCMAKE_BUILD_TYPE=Release ..

https://stackoverflow.com/questions/7724569/debug-vs-release-in-cmake

Note that you can pass this to

catkin: -DCMAKE_BUILD_TYPE=Release http://wiki.ros.org/catkin/Tutorials/using_a_workspace

catkin_tools or colcon: --cmake-args -DCMAKE_BUILD_TYPE=Debug https://catkin-tools.readthedocs.io/en/latest/cheat_sheet.html

Note that if you don't set a build type that's not debug or release in CMake https://blog.kitware.com/cmake-and-the-default-build-type/