Skip to content

fix(build_ros): normalize Windows CMake paths to forward slashes - #7067

Open
aoright wants to merge 1 commit into
prefix-dev:mainfrom
aoright:fix-ros-cmake-windows-path-escape
Open

aoright wants to merge 1 commit into
prefix-dev:mainfrom
aoright:fix-ros-cmake-windows-path-escape

Conversation

@aoright

@aoright aoright commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Description

When building ROS packages on Windows (such as ament_cmake packages generating rosidl Python message bindings), CMake generates install scripts (e.g. cmake_install.cmake). Because native Windows paths contain backslashes (\), CMake string parsing encounters syntax errors such as Invalid character escape '\w' when executing compileall on PYTHON_EXECUTABLE or LIBRARY_PREFIX.

This PR:

  1. Normalizes %PYTHON%, %LIBRARY_PREFIX%, and %SRC_DIR% with forward slashes before passing them to CMake in bld_ament_cmake.bat and bld_catkin.bat.
  2. Quotes CMake path definitions to handle paths with spaces or special characters cleanly.
  3. Adds unit tests verifying that render_build_script_with_platform renders forward-slash conversions and quoted variables for Windows ament_cmake and catkin builds.

Fixes #6955

How Has This Been Tested?

  • Added test_render_ament_cmake_windows and test_render_catkin_windows in crates/pixi_build_ros/src/build_script.rs verifying proper normalization and argument quotation on Windows.
  • Ran cargo test -p pixi-build-ros (all 89 tests passed).

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.
      Tools: Claude

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added sufficient tests to cover my changes.

On Windows, passing native paths with backslashes (such as %PYTHON%) to CMake causes invalid character escape errors (e.g. 'Invalid character escape \'\w\'') when CMake generates install scripts (like cmake_install.cmake in ROS 2 rosidl Python bindings).

Normalize %PYTHON%, %LIBRARY_PREFIX%, and %SRC_DIR% with forward slashes and quote CMake arguments in bld_ament_cmake.bat and bld_catkin.bat.

Closes prefix-dev#6955.

Signed-off-by: aoright <102943475+aoright@users.noreply.github.com>
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.

[pixi-build-ros] Windows: cmake_install.cmake fails with "Invalid character escape" for any ament_cmake package with rosidl-generated Python bindings

1 participant