Releases: corrosion-rs/corrosion
Releases · corrosion-rs/corrosion
Beta v0.3
Changes since v0.2.2
Breaking
- 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. Please also note that on MacOS 12 at least Rust 1.54 is required. - MacOS 10 and 11 are no longer officially supported and untested in CI.
- Increase the minimum required CMake version to 3.15.
- Corrosion internally invokes
cargo build
. When passing arguments tocargo build
, Corrosion
now uses the CMakeVERBATIM
option. This may require you to change how you quote
parameters passed to corrosion (e.g. viacorrosion_add_target_rustflags()
).
For example setting acfg
option previously required double escaping the rustflag like this
"--cfg=something=\\\"value\\\""
, but now it should be passed to corrosion without any escapes:
--cfg=something="value"
.
Breaking: Removed previously deprecated functionality
- Removed
add_crate()
function. Usecorrosio_import_crate
instead. - Removed
cargo_link_libraries()
function. Usecorrosion_link_libraries()
instead. - Removed experimental CMake option
CORROSION_EXPERIMENTAL_PARSER
. This option was never included in an official
release and has been marked as deprecated on the master branch since May 22.
The corresponding stable option isCORROSION_NATIVE_TOOLING
albeit with inverted semantics. - Previously Corrosion would set the
HOST_CC
andHOST_CXX
environment variables when invoking
cargo build, if the environment variablesCC
andCXX
outside of CMake where set.
However this did not work as expected in all cases and sometimes theHOST_CC
variable would be set
to a cross-compiler for unknown reasons. For this reasonHOST_CC
andHOST_CXX
are not set by
corrosion anymore, but users can still set them manually if required viacorrosion_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) - Adding a
PRE_BUILD
custom command on acargo-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 targetscargo-prebuild
(before all cargo build invocations)
orcargo-prebuild_<target_name>
as a dependency target.
Example:add_dependencies(cargo-prebuild code_generator_target)
New features
- Support setting rustflags for only the main target and none of it's dependencies (215).
A new functioncorrosion_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 viacorrosion_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 theOUTPUT_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 allbin
s andlib
s in the whole project must be unique.
Users can set the names in theCargo.toml
by addingname = <unique_name>
in the[[bin]]
and[lib]
tables. - FindRust now has improved support for the
VERSION
option offind_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 tofind_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 howcargo metadata
is parsed.
v0.2.2
v0.2.1
Fixes
- Fix missing variables provided by corrosion, when corrosion is used as a subdirectory (181):
Public Variables set by Corrosion were not visible when using Corrosion as a subdirectory, due to the wrong scope of the variables. This was fixed by promoting the respective variables to Cache variables.
v0.2.0
Breaking changes
- Removed the integrator build script (#156).
The build script provided by corrosion (for rust code that links in foreign code) is no longer necessary,
so users can just remove the dependency.
Deprecations
- Direct usage of the following target properties has been deprecated. The names of the custom properties are
no longer considered part of the public API and may change in the future. Instead, please use the functions
provided by corrosion. Internally different property names are used depending on the CMake version.CORROSION_FEATURES
,CORROSION_ALL_FEATURES
,CORROSION_NO_DEFAULT_FEATURES
. Instead please use
corrosion_set_features()
. See the updated Readme for details.CORROSION_ENVIRONMENT_VARIABLES
. Please usecorrosion_set_env_vars()
instead.CORROSION_USE_HOST_BUILD
. Please usecorrosion_set_hostbuild()
instead.
- The Minimum CMake version will likely be increased for the next major release. At the very least we want to drop
support for CMake 3.12, but requiring CMake 3.16 or even 3.18 is also on the table. If you are using a CMake version
that would be no longer supported by corrosion, please comment on issue
#168, so that we can gauge the number of affected users.
New features
- Add
NO_STD
option tocorrosion_import_crate
(#154). - Remove the requirement of building the Rust based generator crate for CMake >= 3.19. This makes using corrosion as
a subdirectory as fast as the installed version (since everything is done in CMake).
(#131, #161)
If you do choose to install Corrosion, then by default the old Generator is still compiled and installed, so you can
fall back to using it in case you use multiple cmake versions on the same machine for different projects.
Fixes
- Fix Corrosion on MacOS 11 and 12 (#167 and
#164). - Improve robustness of parsing the LLVM version (exported in
Rust_LLVM_VERSION
). It now also works for
Rust versions, where the LLVM version is reported asMAJOR.MINOR
. (#148) - Fix a bug which occurred when Corrosion was added multiple times via
add_subdirectory()
(#143). - Set
CC_<target_triple_undercore>
andCXX_<target_triple_undercore>
environment variables for the invocation of
cargo build
to the compilers selected by CMake (if any)
(#138 and #161).
This should ensure that C dependencies built in cargo buildscripts via cc-rs
use the same compiler as CMake built dependencies. Users can override the compiler by specifying the higher
priority environment variable variants with dashes instead of underscores (See cc-rs documentation for details). - Fix Ninja-Multiconfig Generator support for CMake versions >= 3.20. Previous CMake versions are missing a feature,
which prevents us from supporting the Ninja-Multiconfig generator. (#137)
v0.1.0
This is the first release of corrosion after it was moved to the new corrosion-rs organization.
Since there are no previous releases, this is not a complete changelog but only lists changes since
September 2021.
New features
- Add --profile support for rust >= 1.57:
Allows users to specify a custom cargo profile withcorrosion_import_crate(... PROFILE <profilename>)
. - Add support for specifying per-target Rustflags:
Rustflags can be added viacorrosion_add_target_rustflags(<target_name> [rustflags1...])
- Add
Rust_IS_NIGHTLY
andRust_LLVM_VERSION
variables:
This may be useful if you want to conditionally enabled features when using a nightly toolchain or a specific LLVM Version. - Let
FindRust
fail gracefully if rustc is not found:
This allows usingFindRust
in a more general setting (without corrosion). - Add support for cargo feature selection:
See the README for details on how to select features.
Fixes
- Fix the cargo-clean target
- Fix #84: CorrosionConfig.cmake looks in wrong place for Corrosion::Generator when CMAKE_INSTALL_LIBEXEC is an absolute path
- Fix #116: (Option CORROSION_INSTALL_EXECUTABLE not working)
- Fix building on Windows with rust >= 1.57
Known issues:
- Corrosion is currently not working on macos-11 and newer. See issue #104.
Contributions are welcome.