Skip to content

Make ament_include_directories_order a function to allow paths with backslashes on windows. - #371

Merged
sloretz merged 6 commits into
masterfrom
escape_windows_paths
Jan 4, 2022
Merged

sloretz merged 6 commits into
masterfrom
escape_windows_paths

Conversation

@sloretz

@sloretz sloretz commented Dec 23, 2021 •

Copy link
Copy Markdown
Contributor

This fixes a CMake error that can happen when include directory paths have back slashes in them on Windows.

I attempted to use answers from a few SO posts: https://stackoverflow.com/questions/13737370/cmake-error-invalid-escape-sequence-u , but replacing the slashes can't be done inside the macro. The problem is ARGN isn't a real variable in a CMake macro. Instead it gets substituted as a string. This means the back slashes in the path get evaluated as if the un-escaped string was typed in a CMake file. Making the macro a function should resolve this problem.

15:32:23 CMake Error at C:/ci/ws/install/share/ament_cmake_include_directories/cmake/ament_include_directories_order.cmake:30 (_ament_include_directories_order):
15:32:23   Syntax error in cmake code at
15:32:23 
15:32:23     C:/ci/ws/install/share/ament_cmake_include_directories/cmake/ament_include_directories_order.cmake:30
15:32:23 
15:32:23   when parsing string
15:32:23 
15:32:23     C:/ci/ws/install/include;C:\Python38\lib\site-packages\numpy\core\include
15:32:23 
15:32:23   Invalid character escape '\P'.
15:32:23 Call Stack (most recent call first):
15:32:23   C:/ci/ws/install/share/ament_cmake_target_dependencies/cmake/ament_target_dependencies.cmake:138 (ament_include_directories_order)
15:32:23   C:/ci/ws/install/share/rosidl_generator_c/cmake/rosidl_generator_c_generate_interfaces.cmake:129 (ament_target_dependencies)
15:32:23   C:/ci/ws/install/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include)
15:32:23   C:/ci/ws/install/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions)
15:32:23   CMakeLists.txt:17 (rosidl_generate_interfaces)

This PR is required to fix ros2/rosidl_python#149 , which itself is required to fix ros2/rcl_interfaces#133

@sloretz sloretz added the bug Something isn't working label Dec 23, 2021
@sloretz sloretz self-assigned this Dec 23, 2021
@sloretz

sloretz commented Dec 23, 2021

Copy link
Copy Markdown
Contributor Author

CI (build: --packages-up-to rcl test: --packages-select ament_cmake_include_directories)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Signed-off-by: Shane Loretz <[email protected]>
@sloretz

sloretz commented Dec 24, 2021

Copy link
Copy Markdown
Contributor Author

CI re-run

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Signed-off-by: Shane Loretz <[email protected]>
@sloretz
sloretz marked this pull request as draft December 24, 2021 01:32
@sloretz sloretz changed the title Repalce backslashes with forward slashes on Windows Make ament_include_directories_order a function to allow paths with backslashes on windows. Dec 29, 2021
@sloretz

sloretz commented Dec 29, 2021

Copy link
Copy Markdown
Contributor Author

Switching to a CMake function did the trick 🎉

CI re-re-run

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@sloretz
sloretz marked this pull request as ready for review December 29, 2021 19:55

@audrow audrow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@sloretz
sloretz merged commit b474e31 into master Jan 4, 2022
@delete-merged-branch
delete-merged-branch Bot deleted the escape_windows_paths branch January 4, 2022 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants