From 4b6622edd73366add9b9f52a7742b5c74413d6bc Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Thu, 25 Jan 2024 12:01:05 -0800 Subject: [PATCH] More fixes. Signed-off-by: Chris Lalancette --- rosidl_generator_py/CMakeLists.txt | 11 +++-------- rosidl_generator_py/cmake/custom_command.cmake | 4 +++- .../rosidl_generator_py_generate_interfaces.cmake | 11 ++++++----- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/rosidl_generator_py/CMakeLists.txt b/rosidl_generator_py/CMakeLists.txt index a0c5186e..fe6e6c5d 100644 --- a/rosidl_generator_py/CMakeLists.txt +++ b/rosidl_generator_py/CMakeLists.txt @@ -25,11 +25,6 @@ if(BUILD_TESTING) find_package(python_cmake_module REQUIRED) find_package(PythonExtra MODULE REQUIRED) - set(BUILDTYPE_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}") - if(WIN32 AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - set(BUILDTYPE_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_DEBUG}") - endif() - include(cmake/register_py.cmake) include(cmake/rosidl_generator_py_get_typesupports.cmake) @@ -72,18 +67,18 @@ if(BUILD_TESTING) string(REPLACE ";" ":" pythonpath "${pythonpath}") endif() ament_add_pytest_test(test_interfaces_py "test/test_interfaces.py" - PYTHON_EXECUTABLE "${BUILDTYPE_PYTHON_EXECUTABLE}" + PYTHON_EXECUTABLE PythonExtra::Interpreter APPEND_ENV "PYTHONPATH=${pythonpath}" APPEND_LIBRARY_DIRS "${_append_library_dirs}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_py" ) ament_add_pytest_test(test_cli_extension test/test_cli_extension.py - PYTHON_EXECUTABLE "${BUILDTYPE_PYTHON_EXECUTABLE}" + PYTHON_EXECUTABLE PythonExtra::Interpreter ) ament_add_pytest_test(test_property_py test/test_property.py - PYTHON_EXECUTABLE "${BUILDTYPE_PYTHON_EXECUTABLE}" + PYTHON_EXECUTABLE PythonExtra::Interpreter APPEND_ENV "PYTHONPATH=${pythonpath}" APPEND_LIBRARY_DIRS "${_append_library_dirs}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_py" diff --git a/rosidl_generator_py/cmake/custom_command.cmake b/rosidl_generator_py/cmake/custom_command.cmake index db109734..7519a94e 100644 --- a/rosidl_generator_py/cmake/custom_command.cmake +++ b/rosidl_generator_py/cmake/custom_command.cmake @@ -20,7 +20,9 @@ # add_subdirectory() call. add_custom_command( OUTPUT ${_generated_extension_files} ${_generated_py_files} ${_generated_c_files} - COMMAND Python3::Interpreter ${rosidl_generator_py_BIN} + # This assumes that python_cmake_module was found, which is always the case since this is only + # called from rosidl_generator_py_generate_interfaces.cmake + COMMAND PythonExtra::Interpreter ${rosidl_generator_py_BIN} --generator-arguments-file "${generator_arguments_file}" --typesupport-impls "${_typesupport_impls}" DEPENDS ${target_dependencies} ${rosidl_generate_interfaces_TARGET} diff --git a/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake b/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake index 8f1608c7..800c1b8d 100644 --- a/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake +++ b/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake @@ -72,10 +72,10 @@ foreach(_generated_py_file ${_generated_py_files}) endforeach() if(NOT _generated_c_files STREQUAL "") - foreach(_typesupport_impl ${_typesupport_impls}) - list(APPEND _generated_extension_${_typesupport_impl}_files "${_output_path}/_${PROJECT_NAME}_s.ep.${_typesupport_impl}.c") - list(APPEND _generated_extension_files "${_generated_extension_${_typesupport_impl}_files}") - endforeach() + foreach(_typesupport_impl ${_typesupport_impls}) + list(APPEND _generated_extension_${_typesupport_impl}_files "${_output_path}/_${PROJECT_NAME}_s.ep.${_typesupport_impl}.c") + list(APPEND _generated_extension_files "${_generated_extension_${_typesupport_impl}_files}") + endforeach() endif() set(_dependency_files "") set(_dependencies "") @@ -185,9 +185,10 @@ foreach(_typesupport_impl ${_typesupport_impls}) ${rosidl_generate_interfaces_TARGET}__rosidl_typesupport_c ) + set_target_properties(${_target_name} PROPERTIES DEBUG_POSTFIX "${PythonExtra_POSTFIX}") # target_compile_options(${_target_name} PRIVATE ${_extension_compile_flags}) # TODO(sloretz) use target_compile_options when python extension passes -Wpedantic - set_target_properties(${_target_name} PROPERTIES COMPILE_OPTIONS "${_extension_compile_flags}") # XXX + set_target_properties(${_target_name} PROPERTIES COMPILE_OPTIONS "${_extension_compile_flags}") set_target_properties(${_target_name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${_output_path}