-
Notifications
You must be signed in to change notification settings - Fork 142
Description
Background
I've received push back from a certain core ROS 2 member on bumping CMake from 3.5 to 3.12 on some packages in rolling.
Just for fun, I tried compiling a core package on 3.5. It fails.
None of ROS 2 CI runs on 3.5. It's the CMake recommendation to run CI at the same version as your declared minimum version to catch this kind of issue. ALAS, all of the ROS infrastructure is using much much newer than 3.5.
Analysis
ament_cmake_core does NOT specify a minimum required CMake version to consume it. Tons of ROS 2 packages declare their minimum CMake version of 3.5. This will no longer work, so everyone should bump to 3.12 (or later).
Expected
In /opt/ros/rolling/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake, there should be:
cmake_minimum_required(VERSION 3.12)
Actual
There is no warning, it just fails to find the python3 modules.
Recommendation
Pending the approval, I'd like to add a line to the export to declare a minimum CMake version of 3.12.
Commentary
I'm sure the ament devs know I can be pushy about upgrading to modern CMake. REP-2000 says we can on 3.12 now, so is it time to start enforcing that? It would make my life a lot easier if I stopped having to care about pre-3.12 behavior in CMake when developing in ROS. Things like GNUInstallDirs are great for portable installs to give package maintainers outside of the ROS 2 infra team flexibility to define installation paths. Maybe in Jazzy, we can start using header FILE_SETs.
Setting the CXX standard to 17 is a misnomer if you are using 3.5 because it doesn't support it.
https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD.html#cxx-standard
Reference: https://alexreinking.com/blog/how-to-use-cmake-without-the-agonizing-pain-part-1.html
Logs
Trying common_interfaces:
ryan@B650-970:~/Dev/ros2_ws/src/common_interfaces$ colcon build
[0.663s] WARNING:colcon.colcon_core.package_selection:Some selected packages are already built in one or more underlay workspaces:
'geometry_msgs' is in: /opt/ros/rolling
'trajectory_msgs' is in: /opt/ros/rolling
'sensor_msgs' is in: /opt/ros/rolling
'diagnostic_msgs' is in: /opt/ros/rolling
'sensor_msgs_py' is in: /opt/ros/rolling
'visualization_msgs' is in: /opt/ros/rolling
'common_interfaces' is in: /opt/ros/rolling
'std_srvs' is in: /opt/ros/rolling
'nav_msgs' is in: /opt/ros/rolling
'std_msgs' is in: /opt/ros/rolling
If a package in a merged underlay workspace is overridden and it installs headers, then all packages in the overlay must sort their include directories by workspace order. Failure to do so may result in build failures or undefined behavior at run time.
If the overridden package is used by another package in any underlay, then the overriding package in the overlay must be API and ABI compatible or undefined behavior at run time may occur.
If you understand the risks and want to override a package anyways, add the following to the command line:
--allow-overriding common_interfaces diagnostic_msgs geometry_msgs nav_msgs sensor_msgs sensor_msgs_py std_msgs std_srvs trajectory_msgs visualization_msgs
This may be promoted to an error in a future release of colcon-override-check.
Starting >>> std_msgs
Starting >>> std_srvs
--- stderr: std_srvs
CMake Error at /opt/ros/rolling/share/ament_cmake_core/cmake/core/python.cmake:21 (find_package):
By not providing "FindPython3.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Python3", but
CMake did not find one.
Could not find a package configuration file provided by "Python3" with any
of the following names:
Python3Config.cmake
python3-config.cmake
Add the installation prefix of "Python3" to CMAKE_PREFIX_PATH or set
"Python3_DIR" to a directory containing one of the above files. If
"Python3" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
/opt/ros/rolling/share/ament_cmake_core/cmake/core/all.cmake:55 (include)
/opt/ros/rolling/share/ament_cmake_core/cmake/ament_cmake_core-extras.cmake:17 (include)
/opt/ros/rolling/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:41 (include)
/opt/ros/rolling/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package)
/opt/ros/rolling/share/ament_cmake/cmake/ament_cmakeConfig.cmake:41 (include)
CMakeLists.txt:14 (find_package)
---
Failed <<< std_srvs [0.59s, exited with code 1]
Aborted <<< std_msgs [0.61s]
Summary: 0 packages finished [1.19s]
1 package failed: std_srvs
1 package aborted: std_msgs
2 packages had stderr output: std_msgs std_srvs
11 packages not processedFindPython3 was added in 3.12.