Skip to content

Commit

Permalink
overwrite cmake feature flags if cargo feature flags are different
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Sep 24, 2024
1 parent 80f8d99 commit e62e278
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,17 @@ set_genexpr_condition(cargo_flags DEBUG $<CONFIG:Debug>
"--release;--manifest-path=${cargo_toml_dir_release}/Cargo.toml")
set(cargo_flags ${cargo_flags} ${ZENOHC_CARGO_FLAGS})

if(ZENOHC_BUILD_WITH_SHARED_MEMORY)
if (("${cargo_flags}" MATCHES ^.*shared-memory.*$) AND NOT(ZENOHC_BUILD_WITH_SHARED_MEMORY))
set(ZENOHC_BUILD_WITH_SHARED_MEMORY TRUE)
message(STATUS "Due to ZENOHC_CARGO_FLAGS setting ZENOHC_BUILD_WITH_SHARED_MEMORY = TRUE")
elseif(ZENOHC_BUILD_WITH_SHARED_MEMORY)
set(cargo_flags ${cargo_flags} --features=shared-memory)
endif()

if(ZENOHC_BUILD_WITH_UNSTABLE_API)
if (("${cargo_flags}" MATCHES ^.*unstable.*$) AND NOT(ZENOHC_BUILD_WITH_UNSTABLE_API))
set(ZENOHC_BUILD_WITH_UNSTABLE_API TRUE)
message(STATUS "Due to ZENOHC_CARGO_FLAGS setting ZENOHC_BUILD_WITH_UNSTABLE_API = TRUE")
elseif(ZENOHC_BUILD_WITH_UNSTABLE_API)
set(cargo_flags ${cargo_flags} --features=unstable)
endif()

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ spin = "0.9.5"
unwrap-infallible = "0.1.5"
const_format = "0.2.32"
zenoh = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false, features = ["internal"] }
zenoh-ext = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", optional = true }
zenoh-ext = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" , optional = true }
zenoh-runtime = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" }
zenoh-util = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" }
flume = "*"
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,9 @@ cmake ../zenoh-c -DZENOHC_CARGO_CHANNEL="+1.72.0"

It's necessary sometimes to build zenoh-c library with set of features different from default. For example: enable TCP and UDP only. This can be done by changing `ZENOHC_CARGO_FLAGS` parameter for cmake (notice ";" instead of space due to cmake peculiarities)

Available features can be found in Zenoh [Cargo.toml](https://github.com/eclipse-zenoh/zenoh/blob/main/zenoh/Cargo.toml)

Available features can be found in [Cargo.toml](./Cargo.toml)
```bash
cmake ../zenoh-c -DZENOHC_CARGO_FLAGS="--no-default-features;--features=zenoh/transport_tcp,zenoh/transport_udp"
cmake ../zenoh-c -DZENOHC_CARGO_FLAGS="--no-default-features;--features=transport_tcp,transport_udp"
```

## Versioning
Expand Down

0 comments on commit e62e278

Please sign in to comment.