@@ -17,7 +17,7 @@ find_package(rosidl_runtime_c REQUIRED)
17
17
find_package (rosidl_typesupport_c REQUIRED )
18
18
find_package (rosidl_typesupport_interface REQUIRED )
19
19
20
- find_package (PythonInterp 3.5 REQUIRED )
20
+ find_package (Python3 REQUIRED COMPONENTS Interpreter NumPy )
21
21
22
22
find_package (python_cmake_module REQUIRED )
23
23
find_package (PythonExtra MODULE REQUIRED )
@@ -126,10 +126,8 @@ endif()
126
126
127
127
set (_target_suffix "__py" )
128
128
129
+ set (PYTHON_EXECUTABLE ${Python3_EXECUTABLE} )
129
130
set (_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} )
130
- if (WIN32 AND "${CMAKE_BUILD_TYPE} " STREQUAL "Debug" )
131
- set (PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE_DEBUG} )
132
- endif ()
133
131
134
132
# move custom command into a subdirectory to avoid multiple invocations on Windows
135
133
set (_subdir "${CMAKE_CURRENT_BINARY_DIR} /${rosidl_generate_interfaces_TARGET}${_target_suffix} " )
@@ -180,31 +178,9 @@ target_include_directories(${_target_name_lib}
180
178
${PythonExtra_INCLUDE_DIRS}
181
179
)
182
180
183
- # Check if numpy is in the include path
184
- find_file (_numpy_h numpy/numpyconfig.h
185
- PATHS ${PythonExtra_INCLUDE_DIRS}
186
- )
187
181
188
- if (APPLE OR WIN32 OR NOT _numpy_h )
189
- # add include directory for numpy headers
190
- set (_python_code
191
- "import numpy"
192
- "print(numpy.get_include())"
193
- )
194
- execute_process (
195
- COMMAND "${PYTHON_EXECUTABLE} " "-c" "${_python_code} "
196
- OUTPUT_VARIABLE _output
197
- RESULT_VARIABLE _result
198
- OUTPUT_STRIP_TRAILING_WHITESPACE
199
- )
200
- if (NOT _result EQUAL 0 )
201
- message (FATAL_ERROR
202
- "execute_process(${PYTHON_EXECUTABLE} -c '${_python_code} ') returned "
203
- "error code ${_result} " )
204
- endif ()
205
- message (STATUS "Using numpy include directory: ${_output} " )
206
- target_include_directories (${_target_name_lib} PUBLIC "${_output} " )
207
- endif ()
182
+ message (STATUS "Using numpy include directory: ${Python3_NumPy_INCLUDE_DIRS} " )
183
+ target_include_directories (${_target_name_lib} PUBLIC "${Python3_NumPy_INCLUDE_DIRS} " )
208
184
209
185
rosidl_target_interfaces (${_target_name_lib}
210
186
${rosidl_generate_interfaces_TARGET} rosidl_typesupport_c )
0 commit comments