colcon-cmake

0.2.29 · active · verified Fri Apr 17

colcon-cmake is an extension for the colcon build tool, providing robust support for building, testing, and installing packages that utilize CMake as their build system. It seamlessly integrates CMake projects into the colcon workspace management workflow, enabling consistent project orchestration across various build types. The current version is 0.2.29, with releases generally aligned with colcon's development or as required for improvements and bug fixes.

Common errors

Warnings

Install

Quickstart

This quickstart demonstrates how to set up a simple CMake package and build it using colcon, leveraging the colcon-cmake extension. Ensure `colcon-cmake` is installed before running `colcon build`.

mkdir -p my_colcon_workspace/src/my_cmake_pkg
cd my_colcon_workspace/src/my_cmake_pkg

# Create a minimal CMakeLists.txt
echo 'cmake_minimum_required(VERSION 3.1)' > CMakeLists.txt
echo 'project(my_cmake_pkg CXX)' >> CMakeLists.txt
echo 'add_executable(my_node src/main.cpp)' >> CMakeLists.txt
echo 'install(TARGETS my_node DESTINATION bin)' >> CMakeLists.txt

# Create a simple C++ source file
mkdir src
echo '#include <iostream>\nint main() { std::cout << "Hello from colcon-cmake!" << std::endl; return 0; }' > src/main.cpp

# Go back to the workspace root and build
cd ../..
colcon build

# To run the built executable
./install/my_cmake_pkg/bin/my_node

view raw JSON →