Skip to content

Commit

Permalink
Make rosidl packages use FindPython3 instead of FindPythonInterp (#612)
Browse files Browse the repository at this point in the history
Signed-off-by: Shane Loretz <[email protected]>
  • Loading branch information
sloretz authored Aug 11, 2021
1 parent f24e385 commit 36ed120
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion rosidl_adapter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.12)

project(rosidl_adapter NONE)

Expand Down
9 changes: 4 additions & 5 deletions rosidl_adapter/cmake/rosidl_adapt_interfaces.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ function(rosidl_adapt_interfaces idl_var arguments_file)
"arguments: ${ARG_UNPARSED_ARGUMENTS}")
endif()

find_package(PythonInterp REQUIRED)
if(NOT PYTHON_EXECUTABLE)
message(FATAL_ERROR "Variable 'PYTHON_EXECUTABLE' must not be empty")
endif()
find_package(ament_cmake_core REQUIRED) # for get_executable_path
find_package(Python3 REQUIRED COMPONENTS Interpreter)
get_executable_path(python_interpreter Python3::Interpreter CONFIGURE)

set(idl_output "${CMAKE_CURRENT_BINARY_DIR}/rosidl_adapter/${ARG_TARGET}.idls")
set(cmd
"${PYTHON_EXECUTABLE}" -m rosidl_adapter
"${python_interpreter}" -m rosidl_adapter
--package-name ${PROJECT_NAME}
--arguments-file "${arguments_file}"
--output-dir "${CMAKE_CURRENT_BINARY_DIR}/rosidl_adapter/${PROJECT_NAME}"
Expand Down
3 changes: 3 additions & 0 deletions rosidl_adapter/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<license>Apache License 2.0</license>
<author email="[email protected]">Dirk Thomas</author>

<buildtool_export_depend>ament_cmake_core</buildtool_export_depend>
<buildtool_export_depend>python3</buildtool_export_depend>

<build_depend>ament_cmake</build_depend>

<exec_depend>python3-empy</exec_depend>
Expand Down
2 changes: 1 addition & 1 deletion rosidl_generator_c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.12)

project(rosidl_generator_c C)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ rosidl_write_generator_arguments(
TARGET_DEPENDENCIES ${target_dependencies}
)

find_package(Python3 REQUIRED COMPONENTS Interpreter)

add_custom_command(
OUTPUT ${_generated_headers} ${_generated_sources}
COMMAND ${PYTHON_EXECUTABLE} ${rosidl_generator_c_BIN}
COMMAND Python3::Interpreter
ARGS ${rosidl_generator_c_BIN}
--generator-arguments-file "${generator_arguments_file}"
DEPENDS ${target_dependencies}
COMMENT "Generating C code for ROS interfaces"
Expand Down
1 change: 1 addition & 0 deletions rosidl_generator_c/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<buildtool_depend>ament_cmake_ros</buildtool_depend>

<buildtool_export_depend>ament_cmake_core</buildtool_export_depend>
<buildtool_export_depend>python3</buildtool_export_depend>
<buildtool_export_depend>rosidl_cmake</buildtool_export_depend>

<build_export_depend>rosidl_typesupport_interface</build_export_depend>
Expand Down
2 changes: 1 addition & 1 deletion rosidl_generator_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.12)

project(rosidl_generator_cpp)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ rosidl_write_generator_arguments(
TARGET_DEPENDENCIES ${target_dependencies}
)

find_package(Python3 REQUIRED COMPONENTS Interpreter)

add_custom_command(
OUTPUT ${_generated_headers}
COMMAND ${PYTHON_EXECUTABLE} ${rosidl_generator_cpp_BIN}
COMMAND Python3::Interpreter
ARGS ${rosidl_generator_cpp_BIN}
--generator-arguments-file "${generator_arguments_file}"
DEPENDS ${target_dependencies}
COMMENT "Generating C++ code for ROS interfaces"
Expand Down
1 change: 1 addition & 0 deletions rosidl_generator_cpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<buildtool_depend>ament_cmake</buildtool_depend>

<buildtool_export_depend>ament_cmake_core</buildtool_export_depend>
<buildtool_export_depend>python3</buildtool_export_depend>
<buildtool_export_depend>rosidl_cmake</buildtool_export_depend>

<!-- This is needed for the rosidl_message_type_support_t struct and visibility macros -->
Expand Down
2 changes: 1 addition & 1 deletion rosidl_typesupport_introspection_c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.12)

project(rosidl_typesupport_introspection_c C)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ rosidl_write_generator_arguments(
TARGET_DEPENDENCIES ${target_dependencies}
)

find_package(Python3 REQUIRED COMPONENTS Interpreter)

add_custom_command(
OUTPUT ${_generated_header_files} ${_generated_source_files}
COMMAND ${PYTHON_EXECUTABLE} ${rosidl_typesupport_introspection_c_BIN}
COMMAND Python3::Interpreter
ARGS ${rosidl_typesupport_introspection_c_BIN}
--generator-arguments-file "${generator_arguments_file}"
DEPENDS ${target_dependencies}
COMMENT "Generating C introspection for ROS interfaces"
Expand Down
1 change: 1 addition & 0 deletions rosidl_typesupport_introspection_c/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<buildtool_depend>ament_cmake_ros</buildtool_depend>

<buildtool_export_depend>ament_cmake</buildtool_export_depend>
<buildtool_export_depend>python3</buildtool_export_depend>
<buildtool_export_depend>rosidl_cmake</buildtool_export_depend>

<build_export_depend>rosidl_runtime_c</build_export_depend>
Expand Down
2 changes: 1 addition & 1 deletion rosidl_typesupport_introspection_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.12)

project(rosidl_typesupport_introspection_cpp)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ rosidl_write_generator_arguments(
TARGET_DEPENDENCIES ${target_dependencies}
)

find_package(Python3 REQUIRED COMPONENTS Interpreter)

add_custom_command(
OUTPUT ${_generated_header_files} ${_generated_source_files}
COMMAND ${PYTHON_EXECUTABLE} ${rosidl_typesupport_introspection_cpp_BIN}
COMMAND Python3::Interpreter
ARGS ${rosidl_typesupport_introspection_cpp_BIN}
--generator-arguments-file "${generator_arguments_file}"
DEPENDS ${target_dependencies}
COMMENT "Generating C++ introspection for ROS interfaces"
Expand Down
1 change: 1 addition & 0 deletions rosidl_typesupport_introspection_cpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<buildtool_depend>ament_cmake_ros</buildtool_depend>

<buildtool_export_depend>ament_cmake</buildtool_export_depend>
<buildtool_export_depend>python3</buildtool_export_depend>
<buildtool_export_depend>rosidl_cmake</buildtool_export_depend>

<build_export_depend>rosidl_runtime_c</build_export_depend>
Expand Down

0 comments on commit 36ed120

Please sign in to comment.