-
Notifications
You must be signed in to change notification settings - Fork 4
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
pybind11_add_module adds OS-installed ROS include path before ament include paths #9
Comments
Thanks for the report! It looks like something else is going on here. I see a different compile error that doesn't involve
This similarly looks like it's finding the installed header for |
Looks like |
One way to build diff --git a/rosbag2_storage_default_plugins/CMakeLists.txt b/rosbag2_storage_default_plugins/CMakeLists.txt
index f519aba..264b251 100644
--- a/rosbag2_storage_default_plugins/CMakeLists.txt
+++ b/rosbag2_storage_default_plugins/CMakeLists.txt
@@ -34,20 +34,19 @@ add_library(${PROJECT_NAME} SHARED
src/rosbag2_storage_default_plugins/sqlite/sqlite_storage.cpp
src/rosbag2_storage_default_plugins/sqlite/sqlite_statement_wrapper.cpp)
+target_include_directories(${PROJECT_NAME}
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:include>
+)
ament_target_dependencies(${PROJECT_NAME}
- pluginlib
rosbag2_storage
+ pluginlib
rcpputils
rcutils
SQLite3
yaml_cpp_vendor)
-target_include_directories(${PROJECT_NAME}
- PUBLIC
- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
- $<INSTALL_INTERFACE:include>
-)
-
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(${PROJECT_NAME} PRIVATE |
These errors are expected if you're building the master branch of I'll experiment and see if |
The |
It looks like since I opened the original issue, there's been a new Rolling release that has, for better or worse, made the issue obsolete; I just tried again in a brand new |
About the rosbag issue: opened a PR in ros2/rosbag2#623 About this issue: If I understand correctly,
Creating a new
In this case there is a call to
Which leaves me wondering, what happened with |
This isn't exactly a problem with this repository, but I think it might be the best place to fix it, so I'm creating an issue here...
First, the problem:
rosbag2_py
fails to build if there are binary-installed versions of other rosbag2 packages it depends on. See ros2/rosbag2#583 for more details.This is because it uses
pybind11_add_module
, provided by the pybind11 package inpybind11Tools.cmake
, to declare its targets. That macro declares the target and then callstarget_include_directories
; it adds system-installed include paths such as/opt/ros/rolling/include
to the include directories before it is possible to callament_target_dependencies
, which adds include paths from the source workspace. Because the system-installed directories are added first, gcc prefers to use them to locate header files, which causes the compilation to fail if there are any API incompatibilities. If you declare targets withadd_executable
oradd_library
, the right way to fix this is to callament_target_dependencies
before you calltarget_include_directories
ortarget_link_libraries
, but that is not possible with pybind11 becausepybind11_add_module
does this (at line 154):The best solution I've thought of to fix this is to add something like a
ros_pybind11_add_module
macro that has aAMENT_DEPENDENCIES
option; it would duplicate the behavior ofpybind11_add_module
but the above block of code would callament_target_dependencies
with the contents of that option betweenadd_library
andtarget_include_directories
. The down side to this approach is it would also need to be updated any time pybind11 is updated to ensure thatros_pybind11_add_module
's functionality is parallel withpybind11_add_module
.Since pybind11 isn't tied to ROS, it shouldn't need to know anything about ament, but I don't think
rosbag2_py
is the right place to put any custom cmake code that would be useful for any ROS package that uses pybind11; this package seems like the right place to me. Does that sound reasonable to you, or do you have any other suggestions?The text was updated successfully, but these errors were encountered: