How to fix ROS2 error: catkinConfig.cmake

Problem

When trying to build some ROS package using colcon build, you see an error message such as

CMake Error at CMakeLists.txt:6 (find_package):
  By not providing "Findcatkin.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "catkin", but
  CMake did not find one.

  Could not find a package configuration file provided by "catkin" with any
  of the following names:

    catkinConfig.cmake
    catkin-config.cmake

  Add the installation prefix of "catkin" to CMAKE_PREFIX_PATH or set
  "catkin_DIR" to a directory containing one of the above files.  If "catkin"
  provides a separate development package or SDK, be sure it has been
  installed.

Solution

Catkin is currently not available in a form suitable for installing it from the official ROS2 sources.

Therefore, clone the repo, build it using colcon and then source install/setup.bash before building your package.

git clone https://github.com/ros/catkin.git
cd catkin
colcon build
source install/setup.bash

After that (in the same shell), build your other package using colcon build again.