Skip to content

Commit

Permalink
fix for ZENOHC_CARGO_FLAGS passing
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Nov 20, 2023
1 parent 60fddc1 commit e6b7576
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,15 @@ set_genexpr_condition(libs DEBUG $<CONFIG:Debug> "${libsd}" "${libsr}")
# Build rust sources
#
set_genexpr_condition(cargo_release_flag DEBUG $<CONFIG:Debug> "" "--release")
set(cargo_flags ${ZENOHC_CARGO_FLAGS} ${cargo_release_flag})
# cargo_flags is a list of command line arguments for cargo. It should be represented as a list in CMake,
# i.e. if ZENOHC_CARGO_FLAGS constains space, it shoudl be replaced to list separator ";". This is important for further "add_custom_command" call
# where each list element is passed as separate argument to system exec call.
# This makes impossible to use ";" in ZENOHC_CARGO_FLAGS, let's hope it's not a problem for now.
if (ZENOHC_CARGO_FLAGS MATCHES ";")
message(FATAL_ERROR "ZENOHC_CARGO_FLAGS contains ';' which is not allowed (see comment in CMakeLists.txt))")
endif()
string(REPLACE " " ";" cargo_flags "${ZENOHC_CARGO_FLAGS}")
set(cargo_flags ${cargo_flags} ${cargo_release_flag})
set(cargo_flags ${cargo_flags} --manifest-path=${cargo_toml_dir}/Cargo.toml)

if(ZENOHC_BUILD_WITH_LOGGER_AUTOINIT)
Expand All @@ -192,6 +200,7 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E echo \"RUSTFLAGS = $$RUSTFLAGS\"
COMMAND ${CMAKE_COMMAND} -E echo \"cargo +${ZENOHC_CARGO_CHANNEL} build ${cargo_flags}\"
COMMAND cargo +${ZENOHC_CARGO_CHANNEL} build ${cargo_flags}
VERBATIM
)
add_custom_target(cargo ALL DEPENDS "${libs}")

Expand Down

0 comments on commit e6b7576

Please sign in to comment.