rosfishros2colcon

Colcon: How to change the Cmake path


While installing ROS 2 on MacOS, I encountered some problem with Colcon. It seems that it uses the wrong Cmake path.

Running

colcon build --symlink-install --packages-skip-by-dep python_qt_binding

causes the following error:make: /opt/homebrew/Cellar/cmake/3.25.0/bin/cmake: No such file or directory

Full Output:

Starting >>> ament_package
Starting >>> ament_lint
Starting >>> gtest_vendor
Starting >>> fastcdr
Starting >>> ament_cppcheck
Starting >>> iceoryx_hoofs
Starting >>> osrf_pycommon
Starting >>> osrf_testing_tools_cpp
--- stderr: fastcdr                                                                                                                  
make: /opt/homebrew/Cellar/cmake/3.25.0/bin/cmake: No such file or directory
make: *** [cmake_check_build_system] Error 1
---
Failed   <<< fastcdr [0.50s, exited with code 2]
Aborted  <<< osrf_testing_tools_cpp [0.49s]
Aborted  <<< osrf_pycommon [0.50s]
Aborted  <<< ament_cppcheck [0.51s]
Aborted  <<< ament_lint [0.53s]
Aborted  <<< ament_package [0.54s]
Aborted  <<< gtest_vendor [0.53s]
Aborted  <<< iceoryx_hoofs [0.68s]                             

Summary: 0 packages finished [2.13s]
  1 package failed: fastcdr
  7 packages aborted: ament_cppcheck ament_lint ament_package gtest_vendor iceoryx_hoofs osrf_pycommon osrf_testing_tools_cpp
  3 packages had stderr output: fastcdr gtest_vendor iceoryx_hoofs
  310 packages not processed
[2.326s] ERROR:colcon.colcon_notification.desktop_notification.terminal_notifier:Could not find the colcon-terminal-notifier.app in the install prefix '/opt/homebrew'

The correct Cmake path would be:

>>> which cmake                                                                                                             
/opt/homebrew/Cellar/cmake/3.26.0/bin/cmake

Setting the correct path like this

set -x CMAKE_COMMAND /opt/homebrew/Cellar/cmake/3.26.0/bin

didn't have any effect.


Solution

  • I had this problem too and found I could use the --cmake-clean-cache argument to colcon to clear the cached CMake configuration:

    colcon build --cmake-clean-cache
    

    This fixed the dependency on old CMake for me, and exposed another build problem to fix.

    Documentation for this and other build arguments is in the colcon reference.