Ask Your Question
0

How to build release version of ROS node

asked 2018-12-25 14:34:04 -0500

AutoCar gravatar image

I have written my own ROS node, it works well. But I am not sure if the exe is debug version or release version? How can I find out? What changes I need to make to CMakefile.txt to build release version ROS node?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2019-01-04 13:43:43 -0500

tfoote gravatar image

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/7...

Note that you can pass this to

catkin: -DCMAKE_BUILD_TYPE=Releasehttp://wiki.ros.org/catkin/Tutorials/...

catkin_tools or colcon: --cmake-args -DCMAKE_BUILD_TYPE=Debughttps://catkin-tools.readthedocs.io/e...

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

edit flag offensive delete link more
0

answered 2019-01-04 04:29:36 -0500

juanlu gravatar image

updated 2019-01-04 07:16:27 -0500

To compile your code in release you have to add this flag to the CMakeLists, taken from here:

if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release)
endif()

Finding out if the compiled files are in debug or release is a bit tricky, take a look at this question for starters.

edit flag offensive delete link more

Comments

1

Wouldn't set(CMAKE_BUILD_TYPE Release) (or RelWithDebInfo) be more portable and correct (but be careful with just setting it)? Without the CMAKE_BUILD_TYPE being set, CMAKE_CXX_FLAGS_RELEASE will not be used.

gvdhoorn gravatar imagegvdhoorn ( 2019-01-04 04:34:29 -0500 )edit

You are right! Ill edit my answer

juanlu gravatar imagejuanlu ( 2019-01-04 05:30:09 -0500 )edit
2

Perhaps something like this would be better, as an unconditional set(..) will make it impossible to configure the build type from the command line.

gvdhoorn gravatar imagegvdhoorn ( 2019-01-04 06:51:08 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-12-25 14:34:04 -0500

Seen: 273 times

Last updated: Jan 04