You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The minimum supported rust version (MSRV) was increased to 1.46, due to a cargo issue that recently
surfaced on CI when using crates.io. On MacOS 12 and Windows-2022 at least Rust 1.54 is required.
MacOS 10 and 11 are no longer officially supported and untested in CI.
The minimum required CMake version is now 3.15.
Adding a PRE_BUILD custom command on a cargo-build_<target_name> CMake target will no
longer work as expected. To support executing user defined commands before cargo build is
invoked users should use the newly added targets cargo-prebuild (before all cargo build invocations)
or cargo-prebuild_<target_name> as a dependency target.
Example: add_dependencies(cargo-prebuild code_generator_target)
Removed add_crate() function. Use corrosio_import_crate() instead.
Removed cargo_link_libraries() function. Use corrosion_link_libraries() instead.
Removed experimental CMake option CORROSION_EXPERIMENTAL_PARSER.
The corresponding stable option is CORROSION_NATIVE_TOOLING albeit with inverted semantics.
Previously Corrosion would set the HOST_CC and HOST_CXX environment variables when invoking
cargo build, if the environment variables CC and CXX outside of CMake where set.
However this did not work as expected in all cases and sometimes the HOST_CC variable would be set
to a cross-compiler for unknown reasons. For this reason HOST_CC and HOST_CXX are not set by
corrosion anymore, but users can still set them manually if required via corrosion_set_env_vars().
The CARGO_RUST_FLAGS family of cache variables were removed. Corrosion does not internally use them
anymore.
Potentially breaking
The working directory when invoking cargo build was changed to the directory of the Manifest
file. This now allows cargo to pick up .cargo/config.toml files located in the source tree.
(205)
Corrosion internally invokes cargo build. When passing arguments to cargo build, Corrosion
now uses the CMake VERBATIM option. In rare cases this may require you to change how you quote
parameters passed to corrosion (e.g. via corrosion_add_target_rustflags()).
For example setting a cfg option previously required double escaping the rustflag like this "--cfg=something=\\\"value\\\"", but now it can be passed to corrosion without any escapes: --cfg=something="value".
Corrosion now respects the CMake OUTPUT_DIRECTORY target properties. More details in the "New features" section.
New features
Support setting rustflags for only the main target and none of its dependencies (215).
A new function corrosion_add_target_local_rustflags(target_name rustc_flag [more_flags ...])
is added for this purpose.
This is useful in cases where you only need rustflags on the main-crate, but need to set different
flags for different targets. Without "local" Rustflags this would require rebuilds of the
dependencies when switching targets.
Support explicitly selecting a linker (208).
The linker can be selected via corrosion_set_linker(target_name linker).
Please note that this only has an effect for targets, where the final linker invocation is done
by cargo, i.e. targets where foreign code is linked into rust code and not the other way around.
Corrosion now respects the CMake OUTPUT_DIRECTORY target properties and copies build artifacts to the expected
locations (217), if the properties are set.
This feature requires at least CMake 3.19 and is enabled by default if supported. Please note that the OUTPUT_NAME
target properties are currently not supported.
Specifically, the following target properties are now respected:
Corrosion now supports packages with potentially multiple binaries (bins) and a library (lib) at the
same time. The only requirement is that the names of all bins and libs in the whole project must be unique.
Users can set the names in the Cargo.toml by adding name = <unique_name> in the [[bin]] and [lib] tables.
FindRust now has improved support for the VERSION option of find_package and will now attempt to find a matching
toolchain version. Previously it was only checked if the default toolchain matched to required version.
For rustup managed toolchains a CMake error is issued with a helpful message if the required target for
the selected toolchain is not installed.
Fixes
Fix a CMake developer Warning when a Multi-Config Generator and Rust executable targets
(#213).
FindRust now respects the QUIET option to find_package() in most cases.
Deprecation notice
Support for the MSVC Generators with CMake toolchains before 3.20 is deprecated and will be removed in the next
release (v0.4). All other Multi-config Generators already require CMake 3.20.
Internal Changes
The CMake Generator written in Rust and CorrosionGenerator.cmake which are responsible for parsing cargo metadata output to create corresponding CMake targets for all Rust targets now share most code.
This greatly simplified the CMake generator written in Rust and makes it much easier maintaining and adding
new features regardless of how cargo metadata is parsed.