Robotics StackExchange | Archived questions

How to disable message generation from within the CMakeLists.txt?

According to https://wiki.ros.org/ROS/EnvironmentVariables#ROS_LANG_DISABLE , I can disable genlisp by

export ROS_LANG_DISABLE=genlisp 

within the shell that builds my ROS packages. The caveat is that I need to do this before I issue any catkin and/or ament commands.

Is it possible to disable message generation for a given language within the CMakeLists.txt for the package being built? If so, how?

Asked by rubicks on 2021-01-21 10:33:24 UTC

Comments

Afaik, it only looks at that environment variable. See here.

CMake can set env vars, but only for the current and child processes.

Perhaps setting ROS_LANG_DISABLE like so before the call to find_package(Catkin ..) (I haven't checked the syntax):

set(ENV{ROS_LANG_DISABLE} genlisp)

Note: if you use catkin_make (or anything which coalesces multiple build contexts into a single one) this will -- if it works -- make one package set this value for all others in the active context.

I also have to say I don't find this a very clean approach or a nice thing to do.

And I'm not referring to setting the env var from a build script, but to packages determining for which languages files get generated. That seems like something they should not be doing.

Asked by gvdhoorn on 2021-01-21 11:20:56 UTC

@gvdhoorn what are some examples of ROS-blessed build tools that do not coalesce multiple build contexts into a single one? Could set(ENV{ROS_LANG_DISABLE} genlisp) be made to work with, say, regular catkin and/or colcon?

Asked by rubicks on 2021-01-21 15:51:08 UTC

what are some examples of ROS-blessed build tools that do not coalesce multiple build contexts into a single one?

catkin_tools, catkin_make_isolated and colcon. Although I'd not use the last one for anything but ROS 2 workspaces myself.

And plain CMake itself of course.

Whether it works: I don't know.

What is your rationale for wanting to disable generators from within a package?

Asked by gvdhoorn on 2021-01-22 01:39:09 UTC

Answers