From c0875c5b982881c272d81ca533aa3e212e89954f Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Fri, 6 Aug 2021 10:30:29 -0700 Subject: [PATCH 1/2] Use FindPython3 and make python3 dependency explicit Signed-off-by: Shane Loretz --- rclcpp/CMakeLists.txt | 8 +++++--- rclcpp/package.xml | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rclcpp/CMakeLists.txt b/rclcpp/CMakeLists.txt index c1cb8bf3e2..96e84d04e4 100644 --- a/rclcpp/CMakeLists.txt +++ b/rclcpp/CMakeLists.txt @@ -109,6 +109,8 @@ set(${PROJECT_NAME}_SRCS src/rclcpp/waitable.cpp ) +find_package(Python3 REQUIRED COMPONENTS Interpreter) + # "watch" template for changes configure_file( "resource/logging.hpp.em" @@ -122,7 +124,7 @@ set(python_code_logging string(REPLACE ";" "$" python_code_logging "${python_code_logging}") add_custom_command(OUTPUT include/rclcpp/logging.hpp COMMAND ${CMAKE_COMMAND} -E make_directory "include/rclcpp" - COMMAND ${PYTHON_EXECUTABLE} ARGS -c "${python_code_logging}" + COMMAND Python3::Interpreter ARGS -c "${python_code_logging}" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/logging.hpp.em.watch" COMMENT "Expanding logging.hpp.em" VERBATIM @@ -146,7 +148,7 @@ foreach(interface_file ${interface_files}) string(REPLACE ";" "$" python_${interface_name}_traits "${python_${interface_name}_traits}") add_custom_command(OUTPUT include/rclcpp/node_interfaces/${interface_name}_traits.hpp COMMAND ${CMAKE_COMMAND} -E make_directory "include/rclcpp/node_interfaces" - COMMAND ${PYTHON_EXECUTABLE} ARGS -c "${python_${interface_name}_traits}" + COMMAND Python3::Interpreter ARGS -c "${python_${interface_name}_traits}" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${interface_name}_traits.hpp.em.watch" COMMENT "Expanding interface_traits.hpp.em into ${interface_name}_traits.hpp" VERBATIM @@ -166,7 +168,7 @@ foreach(interface_file ${interface_files}) string(REPLACE ";" "$" python_get_${interface_name} "${python_get_${interface_name}}") add_custom_command(OUTPUT include/rclcpp/node_interfaces/get_${interface_name}.hpp COMMAND ${CMAKE_COMMAND} -E make_directory "include/rclcpp/node_interfaces" - COMMAND ${PYTHON_EXECUTABLE} ARGS -c "${python_get_${interface_name}}" + COMMAND Python3::Interpreter ARGS -c "${python_get_${interface_name}}" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/get_${interface_name}.hpp.em.watch" COMMENT "Expanding get_interface.hpp.em into get_${interface_file}.hpp" VERBATIM diff --git a/rclcpp/package.xml b/rclcpp/package.xml index 56726b9490..ae5228e6df 100644 --- a/rclcpp/package.xml +++ b/rclcpp/package.xml @@ -11,6 +11,7 @@ Dirk Thomas ament_cmake_ros + python3 ament_index_cpp builtin_interfaces From 2640cb727058bb7776738870f6a1d7093172cc7c Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Fri, 6 Aug 2021 10:33:30 -0700 Subject: [PATCH 2/2] Need CMake 3.12 for FindPython3 Signed-off-by: Shane Loretz --- rclcpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rclcpp/CMakeLists.txt b/rclcpp/CMakeLists.txt index 96e84d04e4..76876b4b2d 100644 --- a/rclcpp/CMakeLists.txt +++ b/rclcpp/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(rclcpp)