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

Using colcon, is there a way to skip a "top" CMakeLists.txt and detect packages in sub-folders?

asked 2020-02-25 12:47:37 -0500

anton.deguet gravatar image

I have the following file structure with a mix of legacy code and some ROS packages in a single git repository:

src/top_project/sub_project1/CMakeLists.txt # no ROS
src/top_project/sub_project2/CMakeLists.txt # with ROS

The top_project/CMakeLists.txt is provided for non ROS users and is just a list of add_subdirectory(sub_projectN). I would like colcon to ignore the top_project/CMakeLists.txt and potentially treat each sub_project as a separate package. I tried adding COLCON_IGNORE but this lead to the whole directory and subdirectories being ignored. Is there something like COLCON_IGNORE_CWD to ignore top_project but recursively search the sub folders? To note, I'm trying to port ROS1 libraries build with python catkin build tools which relied on the fact that directories without package.xml where ignored and we had to explicitly provide a package.xml for each actual package.

I'm using ROS 2 Eloquent with:

> cat /etc/lsb-release 

> colcon version-check 
colcon-argcomplete 0.3.3: up-to-date
colcon-bash 0.4.2: up-to-date
colcon-cd 0.1.1: up-to-date
colcon-cmake 0.2.18: up-to-date
colcon-core 0.5.3: up-to-date
colcon-defaults 0.2.3: up-to-date
colcon-devtools 0.2.2: up-to-date
colcon-library-path 0.2.1: up-to-date
colcon-metadata 0.2.3: up-to-date
colcon-notification 0.2.12: up-to-date
colcon-output 0.2.7: up-to-date
colcon-package-information 0.3.1: up-to-date
colcon-package-selection 0.2.5: up-to-date
colcon-parallel-executor 0.2.4: up-to-date
colcon-pkg-config 0.1.0: up-to-date
colcon-powershell 0.3.6: up-to-date
colcon-python-setup-py 0.2.3: up-to-date
colcon-recursive-crawl 0.2.1: up-to-date
colcon-ros 0.3.15: up-to-date
colcon-test-result 0.3.8: up-to-date
colcon-zsh 0.4.0: up-to-date
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-02-25 14:42:44 -0500

Dirk Thomas gravatar image

There is no option to ignore that specific file.

As a workaround - instead of using the default (recursively crawling for packages which stops at that CMake file) - you can choose a different way to discover packages:

  • If all packages are direct subdirectories of src you could call colcon with --paths src/*.
  • If you need crawl recursively under src you can pass --base-paths src/*.

Both options are described when you invoke e.g. colcon build --help.

edit flag offensive delete link more

Question Tools



Asked: 2020-02-25 12:47:37 -0500

Seen: 1,402 times

Last updated: Feb 25 '20