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

asked 2021-01-21 09:33:24 -0500

rubicks gravatar image

According to https://wiki.ros.org/ROS/EnvironmentV... , 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?

edit retag flag offensive close merge delete

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.

gvdhoorn gravatar image gvdhoorn  ( 2021-01-21 10:20:56 -0500 )edit

@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?

rubicks gravatar image rubicks  ( 2021-01-21 14:51:08 -0500 )edit

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?

gvdhoorn gravatar image gvdhoorn  ( 2021-01-22 00:39:09 -0500 )edit