Revert cmake include dirs behaviour
This commit is contained in:
parent
4d9da2b7a7
commit
7fc96e3eb2
|
|
@ -76,17 +76,23 @@ function(r2r_cargo)
|
||||||
string (REPLACE ";" " " RUSTFLAGS_STR "${RUSTFLAGS}")
|
string (REPLACE ";" " " RUSTFLAGS_STR "${RUSTFLAGS}")
|
||||||
set(ENV{RUSTFLAGS} ${RUSTFLAGS_STR})
|
set(ENV{RUSTFLAGS} ${RUSTFLAGS_STR})
|
||||||
|
|
||||||
|
# get include paths
|
||||||
|
get_property(includeDirs DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY INCLUDE_DIRECTORIES)
|
||||||
|
list(REMOVE_DUPLICATES includeDirs)
|
||||||
|
string (REPLACE ";" ":" CMAKE_INCLUDE_DIRS_STR "${includeDirs}")
|
||||||
|
set(ENV{CMAKE_INCLUDE_DIRS} ${CMAKE_INCLUDE_DIRS_STR})
|
||||||
|
|
||||||
# custom target for building using cargo
|
# custom target for building using cargo
|
||||||
option(CARGO_CLEAN "Invoke cargo clean before building" OFF)
|
option(CARGO_CLEAN "Invoke cargo clean before building" OFF)
|
||||||
if(CARGO_CLEAN)
|
if(CARGO_CLEAN)
|
||||||
add_custom_target(cargo_target ALL
|
add_custom_target(cargo_target ALL
|
||||||
COMMAND ${CMAKE_COMMAND} "-E" "env" "cargo" "clean" "--profile" "colcon"
|
COMMAND ${CMAKE_COMMAND} "-E" "env" "cargo" "clean" "--profile" "colcon"
|
||||||
COMMAND ${CMAKE_COMMAND} "-E" "env" "RUSTFLAGS=$ENV{RUSTFLAGS}" "CMAKE_IDL_PACKAGES=$ENV{CMAKE_IDL_PACKAGES}" "cargo" "build" "--profile" "colcon"
|
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"
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
add_custom_target(cargo_target ALL
|
add_custom_target(cargo_target ALL
|
||||||
COMMAND ${CMAKE_COMMAND} "-E" "env" "RUSTFLAGS=$ENV{RUSTFLAGS}" "CMAKE_IDL_PACKAGES=$ENV{CMAKE_IDL_PACKAGES}" "cargo" "build" "--profile" "colcon"
|
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"
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,19 @@ pub fn setup_bindgen_builder() -> bindgen::Builder {
|
||||||
non_exhaustive: false,
|
non_exhaustive: false,
|
||||||
});
|
});
|
||||||
if !cfg!(feature = "doc-only") {
|
if !cfg!(feature = "doc-only") {
|
||||||
|
if let Ok(cmake_includes) = env::var("CMAKE_INCLUDE_DIRS") {
|
||||||
|
// we are running from cmake, do special thing.
|
||||||
|
let mut includes = cmake_includes.split(':').collect::<Vec<_>>();
|
||||||
|
includes.sort_unstable();
|
||||||
|
includes.dedup();
|
||||||
|
|
||||||
|
for x in &includes {
|
||||||
|
let clang_arg = format!("-I{}", x);
|
||||||
|
println!("adding clang arg: {}", clang_arg);
|
||||||
|
builder = builder.clang_arg(clang_arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let ament_prefix_var_name = "AMENT_PREFIX_PATH";
|
let ament_prefix_var_name = "AMENT_PREFIX_PATH";
|
||||||
let ament_prefix_var = {
|
let ament_prefix_var = {
|
||||||
let mut ament_str = env::var_os(ament_prefix_var_name).expect("Source your ROS!");
|
let mut ament_str = env::var_os(ament_prefix_var_name).expect("Source your ROS!");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue