Skip to content

Commit 1c35379

Browse files
1 parent 17de859 commit 1c35379

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ find_package(rosidl_runtime_c REQUIRED)
1717
find_package(rosidl_typesupport_c REQUIRED)
1818
find_package(rosidl_typesupport_interface REQUIRED)
1919

20-
find_package(PythonInterp 3.5 REQUIRED)
20+
find_package(Python3 REQUIRED COMPONENTS Interpreter NumPy)
2121

2222
find_package(python_cmake_module REQUIRED)
2323
find_package(PythonExtra MODULE REQUIRED)
@@ -126,10 +126,8 @@ endif()
126126

127127
set(_target_suffix "__py")
128128

129+
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
129130
set(_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
130-
if(WIN32 AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
131-
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE_DEBUG})
132-
endif()
133131

134132
# move custom command into a subdirectory to avoid multiple invocations on Windows
135133
set(_subdir "${CMAKE_CURRENT_BINARY_DIR}/${rosidl_generate_interfaces_TARGET}${_target_suffix}")
@@ -180,31 +178,9 @@ target_include_directories(${_target_name_lib}
180178
${PythonExtra_INCLUDE_DIRS}
181179
)
182180

183-
# Check if numpy is in the include path
184-
find_file(_numpy_h numpy/numpyconfig.h
185-
PATHS ${PythonExtra_INCLUDE_DIRS}
186-
)
187181

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}")
208184

209185
rosidl_target_interfaces(${_target_name_lib}
210186
${rosidl_generate_interfaces_TARGET} rosidl_typesupport_c)

0 commit comments

Comments
 (0)