FIX: let CMake find Python version that corresponds to ROS distro

This commit is contained in:
-T.K.- 2024-11-14 00:06:58 -08:00
parent 5ce8604297
commit 64cd6aeb6d
1 changed files with 13 additions and 2 deletions

View File

@ -29,8 +29,19 @@ find_package(rclpy REQUIRED)
find_package(gazebo_msgs REQUIRED)
find_package(std_srvs REQUIRED)
# Make sure to find Python 3.8
find_package(Python3 3.8 EXACT COMPONENTS Interpreter Development REQUIRED)
# Make sure to find correct Python version based on ROS distro
if(DEFINED ENV{ROS_DISTRO})
set(ROS_DISTRO_ENV $ENV{ROS_DISTRO})
if(ROS_DISTRO_ENV STREQUAL "foxy")
find_package(Python3 3.8 EXACT COMPONENTS Interpreter Development REQUIRED)
elseif(ROS_DISTRO_ENV STREQUAL "humble")
find_package(Python3 3.10 EXACT COMPONENTS Interpreter Development REQUIRED)
else()
# Not very sure what would the default case be. A fuzzy match?
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
endif()
endif()
link_directories(/usr/local/lib)
include_directories(${YAML_CPP_INCLUDE_DIR})