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

Remove python_cmake_module and set hints #204

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions rosidl_generator_py/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ if(BUILD_TESTING)

find_package(test_interface_files REQUIRED)

find_package(python_cmake_module REQUIRED)
find_package(PythonExtra MODULE REQUIRED)

include(cmake/register_py.cmake)
include(cmake/rosidl_generator_py_get_typesupports.cmake)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.

find_package(python_cmake_module REQUIRED)
find_package(PythonExtra REQUIRED)
find_package(rmw REQUIRED)
find_package(rosidl_runtime_c REQUIRED)
find_package(rosidl_typesupport_c REQUIRED)
find_package(rosidl_typesupport_interface REQUIRED)

# By default, without the settings below, find_package(Python3) will attempt
# to find the newest python version it can, and additionally will find the
# most specific version. For instance, on a system that has
# /usr/bin/python3.10, /usr/bin/python3.11, and /usr/bin/python3, it will find
# /usr/bin/python3.11, even if /usr/bin/python3 points to /usr/bin/python3.10.
# The behavior we want is to prefer the "system" installed version unless the
# user specifically tells us othewise through the Python3_EXECUTABLE hint.
# Setting CMP0094 to NEW means that the search will stop after the first
# python version is found. Setting Python3_FIND_UNVERSIONED_NAMES means that
# the search will prefer /usr/bin/python3 over /usr/bin/python3.11. And that
# latter functionality is only available in CMake 3.20 or later, so we need
# at least that version.
cmake_minimum_required(VERSION 3.20)
cmake_policy(SET CMP0094 NEW)
set(Python3_FIND_UNVERSIONED_NAMES FIRST)

find_package(Python3 REQUIRED COMPONENTS Interpreter Development NumPy)

# Get a list of typesupport implementations from valid rmw implementations.
Expand Down Expand Up @@ -184,7 +198,9 @@ foreach(_typesupport_impl ${_typesupport_impls})
${rosidl_generate_interfaces_TARGET}__rosidl_typesupport_c
)

set_target_properties(${_target_name} PROPERTIES DEBUG_POSTFIX "${PythonExtra_POSTFIX}")
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
set_target_properties(${_target_name} PROPERTIES DEBUG_POSTFIX "_d")
endif()
# 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}")
Expand Down
2 changes: 0 additions & 2 deletions rosidl_generator_py/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

<buildtool_export_depend>ament_cmake</buildtool_export_depend>
<buildtool_export_depend>ament_index_python</buildtool_export_depend>
<buildtool_export_depend>python_cmake_module</buildtool_export_depend>
<buildtool_export_depend>rosidl_generator_c</buildtool_export_depend>
<buildtool_export_depend>rosidl_pycommon</buildtool_export_depend>
<buildtool_export_depend>rosidl_typesupport_c</buildtool_export_depend>
Expand Down Expand Up @@ -53,7 +52,6 @@
<test_depend>ament_lint_common</test_depend>
<test_depend>python3-numpy</test_depend>
<test_depend>python3-pytest</test_depend>
<test_depend>python_cmake_module</test_depend>
<test_depend>rmw</test_depend>
<test_depend>rosidl_cmake</test_depend>

Expand Down