Comments (8)
Could you clarify what exactly is happening? Corrosion infernally uses Cargo, and cargo does something called feature unification in workspaces.
from corrosion.
Illustrative examples:
set ( RUST_FEATURES )
foreach( _feature IN ITEMS ENABLE_X ENABLE_Y ENABLE_Z )
if( ${_feature} )
list ( APPEND RUST_FEATURES "${_feature}" )
endif()
endforeach()
staticlib_crate receives features (OK)
corrosion_import_crate ( MANIFEST_PATH "${CMAKE_SOURCE_DIR}/rust/staticlib_crate/Cargo.toml" FEATURES ${RUST_FEATURES} )
bin_crate complains about features unless i also add then to it's Cargo.toml (BAD)
corrosion_import_crate ( MANIFEST_PATH "${CMAKE_SOURCE_DIR}/rust/Cargo.toml" CRATES staticlib_crate bin_crate FEATURES ${RUST_FEATURES} )
staticlib_crate does not receive features (BAD)
corrosion_import_crate ( MANIFEST_PATH "${CMAKE_SOURCE_DIR}/rust/Cargo.toml" CRATES staticlib_crate bin_crate )
corrosion_set_features ( staticlib_crate FEATURES ${RUST_FEATURES} )
edit: maybe this is related... the two crates are independent. bin_crate does not depend on staticlib_crate
from corrosion.
What cmake version are you using?
from corrosion.
cmake 3.22.1
from corrosion.
bin_crate complains about features unless i also add then to it's Cargo.toml (BAD)
That is expected. The FEATURES
argument only is intended for single crates and less so for workspaces.
For me, your example code fails to update the RUST_FEATURES
variable. I don't quite follow what you want to achieve with the if.
set ( RUST_FEATURES )
foreach( _feature IN ITEMS ENABLE_X ENABLE_Y ENABLE_Z )
if( ${_feature} )
list ( APPEND RUST_FEATURES "${_feature}" )
else()
# fails with a fatal error on my machine.
message(FATAL_ERROR "if evaluates to false")
endif()
endforeach()
FYI, here is the test project that Corrosion has for enabling features: https://github.com/corrosion-rs/corrosion/blob/master/test/features/features/CMakeLists.txt
There is no bin
crate in this constellation, but it shouldn't play a role either.
from corrosion.
Right, the features are originally cmake options that can be enabled and disabled.
option ( ENABLE_X "describe what X does" ON )
option ( ENABLE_Y "describe what Y does" ON )
option ( ENABLE_Z "describe what Z does" ON )
I was lazy and just named the rust features exactly the same.
In corrosion-rs you "enable" features by placing them after FEATURES.
The foreach
loop tests if each option is enabled, collecting enabled ones to the temporary variable RUST_FEATURES, which is expanded after FEATURES.
I'll see if I can adapt the features test you pointed out to replicate the problem.
from corrosion.
I adapted the features test and was not able to reproduce.
Just in case I deleted the build dir of my code and reconfigured, now it works.
So I guess this is a false positive, and the cause was probably some temporary file from previous attempts.
They are deleted so I can't replicate the issue to find out more. Close the issue?
from corrosion.
Okay, great to hear that it works for you now.
from corrosion.
Related Issues (20)
- Support `$<CONFIG>` in `OUTPUT_DIRECTORY` HOT 6
- [Bug]: Some crate requires AR_<triple> environment to cross-compile HOT 1
- [Bug]: Regression caused by passing AR? commit b72c8ceb52f5d0235ce0fc268cfeff20ce56e8d8? HOT 1
- Upstream Rust language support
- [Bug]:cross compile failed HOT 1
- [Bug]: cross compilation from linux to windows with build tools fails. HOT 4
- [Enhancement]: Vcpkg support HOT 5
- [Bug]: "multiple rules generate" with Ninja Multiconfig in CROSS_CONFIG mode HOT 10
- [Bug]: Macos build with -F rather than -L HOT 4
- unused crates in a workspace not included in package, but still expected HOT 3
- corrosion_import_crate: issue with PROFILE argument in combination with CRATES
- [Bug]: corrosion_link_libraries does not include transitive dependencies HOT 2
- Breaking change to target names containing dashes with Rust 1.79 HOT 3
- corrosion_experimental_cbindgen always triggers rebuilds of files that include the generated header HOT 3
- corrosion_link_libraries behavior vs. expectation HOT 1
- [Bug]: undefined symbols during link-time on Windows with LLVM HOT 8
- [Bug]: On error, FindRust puts `Rust_FOUND` in wrong scope HOT 1
- Detect and issue a warning if a different corrosion version is already included.
- [Bug]: strip=true and missing pdb files on Windows HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from corrosion.