Skip to content

fix(cmake): Align Python3 find strategy with ament_core#40

Open
lbmeng wants to merge 1 commit intoament:rollingfrom
lbmeng:python3
Open

fix(cmake): Align Python3 find strategy with ament_core#40
lbmeng wants to merge 1 commit intoament:rollingfrom
lbmeng:python3

Conversation

@lbmeng
Copy link

@lbmeng lbmeng commented Dec 24, 2025

Standardize Python3 interpreter discovery to match ament_cmake_core's established strategy [1], ensuring consistent interpreter selection across the ROS 2 build system.

Changes:

  • Set CMake variable Python3_FIND_STRATEGY to LOCATION
  • Set CMake variable Python3_FIND_UNVERSIONED_NAMES to FIRST
  • Bump up the minimum required CMake version to 3.20

This resolves potential inconsistencies where find_package(Python3) might select unintended Python interpreter to build uncrustify.

[1] ament_cmake_core/cmake/core/python.cmake

Standardize Python3 interpreter discovery to match ament_cmake_core's
established strategy [1], ensuring consistent interpreter selection
across the ROS 2 build system.

Changes:
- Set CMake variable Python3_FIND_STRATEGY to LOCATION
- Set CMake variable Python3_FIND_UNVERSIONED_NAMES to FIRST
- Bump up the minimum required CMake version to 3.20

This resolves potential inconsistencies where find_package(Python3)
might select unintended Python interpreter to build uncrustify.

[1] ament_cmake_core/cmake/core/python.cmake

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
@cottsay cottsay self-requested a review January 8, 2026 17:43
@cottsay
Copy link
Contributor

cottsay commented Jan 8, 2026

It looks like ament_cmake_core uses the CMP0094 CMake policy to change the strategy. Is there any reason not to do the same thing here so that the behavior is consistent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants