1
+ diff --git a/cmake/register_py.cmake b/cmake/register_py.cmake
2
+ index f31c534..4671ec0 100644
3
+ --- a/cmake/register_py.cmake
4
+ +++ b/cmake/register_py.cmake
5
+ @@ -14,6 +14,7 @@
6
+
7
+ macro(rosidl_generator_py_extras BIN GENERATOR_FILES TEMPLATE_DIR)
8
+ find_package(ament_cmake_core QUIET REQUIRED)
9
+ +
10
+ # Make sure extension points are registered in order
11
+ find_package(rosidl_generator_c QUIET REQUIRED)
12
+ find_package(rosidl_typesupport_c QUIET REQUIRED)
1
13
diff --git a/cmake/rosidl_generator_py_generate_interfaces.cmake b/cmake/rosidl_generator_py_generate_interfaces.cmake
2
- index a6d8263..ecae76b 100644
14
+ index a6d8263..0f7a12a 100644
3
15
--- a/cmake/rosidl_generator_py_generate_interfaces.cmake
4
16
+++ b/cmake/rosidl_generator_py_generate_interfaces.cmake
5
- @@ -21,6 +21,7 @@ find_package(PythonInterp 3.6 REQUIRED)
17
+ @@ -17,10 +17,9 @@ find_package(rosidl_runtime_c REQUIRED)
18
+ find_package(rosidl_typesupport_c REQUIRED)
19
+ find_package(rosidl_typesupport_interface REQUIRED)
6
20
21
+ - find_package(PythonInterp 3.6 REQUIRED)
22
+ -
7
23
find_package(python_cmake_module REQUIRED)
8
- find_package(PythonExtra MODULE REQUIRED)
9
- + find_package(Python3 REQUIRED COMPONENTS Development NumPy)
24
+ - find_package(PythonExtra MODULE REQUIRED)
25
+ + find_package(PythonExtra REQUIRED)
26
+ + find_package(Python3 REQUIRED COMPONENTS Interpreter Development NumPy)
10
27
11
28
# Get a list of typesupport implementations from valid rmw implementations.
12
29
rosidl_generator_py_get_typesupports(_typesupport_impls)
13
- @@ -165,52 +166,27 @@ set(rosidl_generator_py_suffix "__rosidl_generator_py")
30
+ @@ -165,52 +164,26 @@ set(rosidl_generator_py_suffix "__rosidl_generator_py")
14
31
set(_target_name_lib "${rosidl_generate_interfaces_TARGET}${rosidl_generator_py_suffix}")
15
32
add_library(${_target_name_lib} SHARED ${_generated_c_files})
16
33
target_link_libraries(${_target_name_lib}
@@ -31,13 +48,13 @@ index a6d8263..ecae76b 100644
31
48
${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_c
32
49
${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_py
33
50
- ${PythonExtra_INCLUDE_DIRS}
34
- )
35
-
51
+ - )
52
+ -
36
53
- # Check if numpy is in the include path
37
54
- find_file(_numpy_h numpy/numpyconfig.h
38
55
- PATHS ${PythonExtra_INCLUDE_DIRS}
39
- - )
40
- -
56
+ )
57
+
41
58
- if(APPLE OR WIN32 OR NOT _numpy_h)
42
59
- # add include directory for numpy headers
43
60
- set(_python_code
@@ -57,20 +74,27 @@ index a6d8263..ecae76b 100644
57
74
- endif()
58
75
- message(STATUS "Using numpy include directory: ${_output}")
59
76
- target_include_directories(${_target_name_lib} PUBLIC "${_output}")
60
- - endif()
61
77
+ if(APPLE)
62
78
+ set_target_properties(${_target_name_lib} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
63
- + else()
64
- + target_link_libraries(${_target_name_lib} PUBLIC Python3::NumPy Python3::Module Python3::Python)
65
- + endif()
79
+ endif()
80
+ + target_link_libraries(${_target_name_lib} PRIVATE Python3::NumPy Python3::Python)
66
81
67
82
rosidl_get_typesupport_target(c_typesupport_target "${rosidl_generate_interfaces_TARGET}" "rosidl_typesupport_c")
68
83
- target_link_libraries(${_target_name_lib} ${c_typesupport_target})
69
84
+ target_link_libraries(${_target_name_lib} PUBLIC ${c_typesupport_target})
70
85
71
86
foreach(_typesupport_impl ${_typesupport_impls})
72
87
find_package(${_typesupport_impl} REQUIRED)
73
- @@ -245,27 +217,28 @@ foreach(_typesupport_impl ${_typesupport_impls})
88
+ @@ -223,7 +196,7 @@ foreach(_typesupport_impl ${_typesupport_impls})
89
+ set(_pyext_suffix "__pyext")
90
+ set(_target_name "${PROJECT_NAME}__${_typesupport_impl}${_pyext_suffix}")
91
+
92
+ - add_library(${_target_name} SHARED
93
+ + python3_add_library(${_target_name} SHARED
94
+ ${_generated_extension_${_typesupport_impl}_files}
95
+ )
96
+ add_dependencies(
97
+ @@ -245,27 +218,28 @@ foreach(_typesupport_impl ${_typesupport_impls})
74
98
endif()
75
99
target_link_libraries(
76
100
${_target_name}
@@ -103,7 +127,7 @@ index a6d8263..ecae76b 100644
103
127
${_pkg_name}
104
128
)
105
129
endforeach()
106
- @@ -273,7 +246 ,7 @@ foreach(_typesupport_impl ${_typesupport_impls})
130
+ @@ -273,7 +247 ,7 @@ foreach(_typesupport_impl ${_typesupport_impls})
107
131
add_dependencies(${_target_name}
108
132
${rosidl_generate_interfaces_TARGET}__${_typesupport_impl}
109
133
)
@@ -112,7 +136,7 @@ index a6d8263..ecae76b 100644
112
136
"rosidl_runtime_c"
113
137
"rosidl_generator_py"
114
138
)
115
- @@ -288,7 +261 ,7 @@ set(PYTHON_EXECUTABLE ${_PYTHON_EXECUTABLE})
139
+ @@ -288,7 +262 ,7 @@ set(PYTHON_EXECUTABLE ${_PYTHON_EXECUTABLE})
116
140
117
141
# Depend on rosidl_generator_py generated targets from our dependencies
118
142
foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES})
@@ -121,7 +145,7 @@ index a6d8263..ecae76b 100644
121
145
endforeach()
122
146
123
147
set_lib_properties("")
124
- @@ -352,4 +325 ,4 @@ if(BUILD_TESTING AND rosidl_generate_interfaces_ADD_LINTER_TESTS)
148
+ @@ -352,4 +326 ,4 @@ if(BUILD_TESTING AND rosidl_generate_interfaces_ADD_LINTER_TESTS)
125
149
MAX_LINE_LENGTH 0
126
150
"${_output_path}")
127
151
endif()
0 commit comments