Commit 7fc96e3 1 parent 4d9da2b commit 7fc96e3 Copy full SHA for 7fc96e3
File tree 2 files changed +21
-2
lines changed
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -76,17 +76,23 @@ function(r2r_cargo)
76
76
string (REPLACE ";" " " RUSTFLAGS_STR "${RUSTFLAGS} " )
77
77
set (ENV{RUSTFLAGS} ${RUSTFLAGS_STR} )
78
78
79
+ # get include paths
80
+ get_property (includeDirs DIRECTORY "${CMAKE_SOURCE_DIR} " PROPERTY INCLUDE_DIRECTORIES )
81
+ list (REMOVE_DUPLICATES includeDirs)
82
+ string (REPLACE ";" ":" CMAKE_INCLUDE_DIRS_STR "${includeDirs} " )
83
+ set (ENV{CMAKE_INCLUDE_DIRS} ${CMAKE_INCLUDE_DIRS_STR} )
84
+
79
85
# custom target for building using cargo
80
86
option (CARGO_CLEAN "Invoke cargo clean before building" OFF )
81
87
if (CARGO_CLEAN)
82
88
add_custom_target (cargo_target ALL
83
89
COMMAND ${CMAKE_COMMAND} "-E" "env" "cargo" "clean" "--profile" "colcon"
84
- COMMAND ${CMAKE_COMMAND} "-E" "env" "RUSTFLAGS=$ENV{RUSTFLAGS} " "CMAKE_IDL_PACKAGES=$ENV{CMAKE_IDL_PACKAGES} " "cargo" "build" "--profile" "colcon"
90
+ COMMAND ${CMAKE_COMMAND} "-E" "env" "RUSTFLAGS=$ENV{RUSTFLAGS} " "CMAKE_IDL_PACKAGES=$ENV{CMAKE_IDL_PACKAGES} " "CMAKE_INCLUDE_DIRS= $ENV{CMAKE_INCLUDE_DIRS_PACKAGES} " " cargo" "build" "--profile" "colcon"
85
91
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
86
92
)
87
93
else ()
88
94
add_custom_target (cargo_target ALL
89
- COMMAND ${CMAKE_COMMAND} "-E" "env" "RUSTFLAGS=$ENV{RUSTFLAGS} " "CMAKE_IDL_PACKAGES=$ENV{CMAKE_IDL_PACKAGES} " "cargo" "build" "--profile" "colcon"
95
+ COMMAND ${CMAKE_COMMAND} "-E" "env" "RUSTFLAGS=$ENV{RUSTFLAGS} " "CMAKE_IDL_PACKAGES=$ENV{CMAKE_IDL_PACKAGES} " "CMAKE_INCLUDE_DIRS= $ENV{CMAKE_INCLUDE_DIRS} " " cargo" "build" "--profile" "colcon"
90
96
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
91
97
)
92
98
endif ()
Original file line number Diff line number Diff line change @@ -49,6 +49,19 @@ pub fn setup_bindgen_builder() -> bindgen::Builder {
49
49
non_exhaustive : false ,
50
50
} ) ;
51
51
if !cfg ! ( feature = "doc-only" ) {
52
+ if let Ok ( cmake_includes) = env:: var ( "CMAKE_INCLUDE_DIRS" ) {
53
+ // we are running from cmake, do special thing.
54
+ let mut includes = cmake_includes. split ( ':' ) . collect :: < Vec < _ > > ( ) ;
55
+ includes. sort_unstable ( ) ;
56
+ includes. dedup ( ) ;
57
+
58
+ for x in & includes {
59
+ let clang_arg = format ! ( "-I{}" , x) ;
60
+ println ! ( "adding clang arg: {}" , clang_arg) ;
61
+ builder = builder. clang_arg ( clang_arg) ;
62
+ }
63
+ }
64
+
52
65
let ament_prefix_var_name = "AMENT_PREFIX_PATH" ;
53
66
let ament_prefix_var = {
54
67
let mut ament_str = env:: var_os ( ament_prefix_var_name) . expect ( "Source your ROS!" ) ;
You can’t perform that action at this time.
0 commit comments