Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building the whole repo as a single CMake project #27

Merged
merged 3 commits into from
Nov 27, 2024

Conversation

traversaro
Copy link
Member

For integration with CMake-based workflows like the one based on FetchContent or ExternalProject (like the robotology-superbuild) cmake modules, it is convenient to be able to build the repository as a single CMake project.

The most naive way of supporting this would be to just add a CMakeLists.txt to the root folder of the repo, but that would problematic as it would influence also the workflow of building the repo via colcon, as it would force the serial configuration, build and install of each subproject of the repo, as oppose to the parallel configuration, build and install of each subproject permitted by colcon. For this reason, I used another strategy: I created a new folder xcub_moveit2_all_packages that contains the following minimal content required to build the repo as a single CMake project:

cmake_minimum_required(VERSION 3.22)
project(xcub-moveit2)

# This file is used to easily build the whole xcub-moveit2 repo
# as a single CMake project. To avoid interfering with the existing
# colcon workflows, this CMakeLists.txt is contained in a subfolder
# of the repo called all_packages, that contains a COLCON_IGNORE
# so that it will be excluded automatically by the colcon build command

# The order of inclusion was taken from colcon graph output
add_subdirectory(../ergocub_moveit_config ${CMAKE_CURRENT_BINARY_DIR}/ergocub_moveit_config)
add_subdirectory(../grasp_moveit ${CMAKE_CURRENT_BINARY_DIR}/grasp_moveit)
add_subdirectory(../icub_moveit_config ${CMAKE_CURRENT_BINARY_DIR}/icub_moveit_config)
add_subdirectory(../robot_controller ${CMAKE_CURRENT_BINARY_DIR}/robot_controller)
add_subdirectory(../robot_moveit ${CMAKE_CURRENT_BINARY_DIR}/robot_moveit)
add_subdirectory(../test_controller ${CMAKE_CURRENT_BINARY_DIR}/test_controller)

However, in this folder I also added a COLCON_IGNORE file, to ensure that the directory is ignored by colcon builds.

In this way, users that want to install the repo as a single cmake project can by doing:

git clone https://github.com/icub-tech-iit/xcub-moveit2/
cd xcub-moveit2/xcub_moveit2_all_packages
cmake -Bbuild -S.
cmake --build build
cmake --install build

without interfering with the usual colcon workflow:

mkdir -p xcub_moveit_ws/src
cd xcub_moveit_ws/src
git clone https://github.com/icub-tech-iit/xcub-moveit2/
cd ../..
colcon build

Copy link
Member

@martinaxgloria martinaxgloria left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

@martinaxgloria martinaxgloria merged commit 2989415 into icub-tech-iit:master Nov 27, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants