Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ros idl generate-py patch #168

Merged
merged 2 commits into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions patch/ros-humble-rosidl-generator-py.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
diff --git a/cmake/rosidl_generator_py_generate_interfaces.cmake b/cmake/rosidl_generator_py_generate_interfaces.cmake
index a6d8263..ecae76b 100644
index a6d8263..f231ea2 100644
--- a/cmake/rosidl_generator_py_generate_interfaces.cmake
+++ b/cmake/rosidl_generator_py_generate_interfaces.cmake
@@ -21,6 +21,7 @@ find_package(PythonInterp 3.6 REQUIRED)
@@ -17,10 +17,9 @@ find_package(rosidl_runtime_c REQUIRED)
find_package(rosidl_typesupport_c REQUIRED)
find_package(rosidl_typesupport_interface REQUIRED)

-find_package(PythonInterp 3.6 REQUIRED)
-
find_package(python_cmake_module REQUIRED)
find_package(PythonExtra MODULE REQUIRED)
+find_package(Python3 REQUIRED COMPONENTS Development NumPy)

# Get a list of typesupport implementations from valid rmw implementations.
rosidl_generator_py_get_typesupports(_typesupport_impls)
@@ -165,52 +166,27 @@ set(rosidl_generator_py_suffix "__rosidl_generator_py")
@@ -165,52 +164,28 @@ set(rosidl_generator_py_suffix "__rosidl_generator_py")
set(_target_name_lib "${rosidl_generate_interfaces_TARGET}${rosidl_generator_py_suffix}")
add_library(${_target_name_lib} SHARED ${_generated_c_files})
target_link_libraries(${_target_name_lib}
Expand All @@ -31,13 +35,13 @@ index a6d8263..ecae76b 100644
${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_c
${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_py
- ${PythonExtra_INCLUDE_DIRS}
)
-)
-
-# Check if numpy is in the include path
-find_file(_numpy_h numpy/numpyconfig.h
- PATHS ${PythonExtra_INCLUDE_DIRS}
-)
-
)
-if(APPLE OR WIN32 OR NOT _numpy_h)
- # add include directory for numpy headers
- set(_python_code
Expand All @@ -57,20 +61,20 @@ index a6d8263..ecae76b 100644
- endif()
- message(STATUS "Using numpy include directory: ${_output}")
- target_include_directories(${_target_name_lib} PUBLIC "${_output}")
-endif()
+if(APPLE)
+set_target_properties(${_target_name_lib} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
+ set_target_properties(${_target_name_lib} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
+ target_include_directories(${_target_name_lib} PUBLIC ${Python3_INCLUDE_DIRS} ${Python3_NumPy_INCLUDE_DIRS})
+else()
+target_link_libraries(${_target_name_lib} PUBLIC Python3::NumPy Python3::Module Python3::Python)
+endif()
+ target_link_libraries(${_target_name_lib} PUBLIC Python3::NumPy Python3::Module Python3::Python)
endif()

rosidl_get_typesupport_target(c_typesupport_target "${rosidl_generate_interfaces_TARGET}" "rosidl_typesupport_c")
-target_link_libraries(${_target_name_lib} ${c_typesupport_target})
+target_link_libraries(${_target_name_lib} PUBLIC ${c_typesupport_target})

foreach(_typesupport_impl ${_typesupport_impls})
find_package(${_typesupport_impl} REQUIRED)
@@ -245,27 +217,28 @@ foreach(_typesupport_impl ${_typesupport_impls})
@@ -245,27 +220,28 @@ foreach(_typesupport_impl ${_typesupport_impls})
endif()
target_link_libraries(
${_target_name}
Expand Down Expand Up @@ -103,7 +107,7 @@ index a6d8263..ecae76b 100644
${_pkg_name}
)
endforeach()
@@ -273,7 +246,7 @@ foreach(_typesupport_impl ${_typesupport_impls})
@@ -273,7 +249,7 @@ foreach(_typesupport_impl ${_typesupport_impls})
add_dependencies(${_target_name}
${rosidl_generate_interfaces_TARGET}__${_typesupport_impl}
)
Expand All @@ -112,7 +116,7 @@ index a6d8263..ecae76b 100644
"rosidl_runtime_c"
"rosidl_generator_py"
)
@@ -288,7 +261,7 @@ set(PYTHON_EXECUTABLE ${_PYTHON_EXECUTABLE})
@@ -288,7 +264,7 @@ set(PYTHON_EXECUTABLE ${_PYTHON_EXECUTABLE})

# Depend on rosidl_generator_py generated targets from our dependencies
foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES})
Expand All @@ -121,21 +125,18 @@ index a6d8263..ecae76b 100644
endforeach()

set_lib_properties("")
@@ -352,4 +325,4 @@ if(BUILD_TESTING AND rosidl_generate_interfaces_ADD_LINTER_TESTS)
@@ -352,4 +328,4 @@ if(BUILD_TESTING AND rosidl_generate_interfaces_ADD_LINTER_TESTS)
MAX_LINE_LENGTH 0
"${_output_path}")
endif()
-endif()
+endif()
\ No newline at end of file
diff --git a/rosidl_generator_py-extras.cmake.in b/rosidl_generator_py-extras.cmake.in
index 80bed29..c2be2ce 100644
index 80bed29..ba70acc 100644
--- a/rosidl_generator_py-extras.cmake.in
+++ b/rosidl_generator_py-extras.cmake.in
@@ -1,7 +1,9 @@
# generated from rosidl_generator_py/rosidl_generator_py-extras.cmake
+find_package(Python3 REQUIRED COMPONENTS Development NumPy)
+
@@ -2,6 +2,6 @@
include("${CMAKE_CURRENT_LIST_DIR}/register_py.cmake")
rosidl_generator_py_extras(
"${rosidl_generator_py_DIR}/../../../lib/rosidl_generator_py/rosidl_generator_py"
Expand Down