[IMPROVEMENT] Use Corrosion to build Rust code #1630
Merged
+36
−44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Currently, using the CMake Ninja generator fails when Rust code is enabled, because the dependencies and outputs of the Rust code compilation are not fully declared. I tried to fix this with the
BYPRODUCTS
feature, but it seemed like it wouldn’t really work. Instead, I ported the Rust build to Corrosion, which is a CMake package designed to integrate CMake and Cargo. Corrosion is used by other projects that combine C++ and Rust, like the work‐in‐progress Rust port of the fish shell. Now people can get faster, more reliable builds using Ninja, and the CMake code is simpler and cleaner.Developers and users do not need to explicitly install Corrosion, thanks to CMake’s
FetchContent
feature. However, if Corrosion is installed on the system, that version will be used.I bumped the minimum CMake requirement to 3.15.0, as Corrosion requires this version and CMake was warning that compatibility for versions as old as the current declaration will be removed in the future. However, if this is not desired, I could lower it back down so that users on older versions of CMake can still build the project as long as they disable Rust, and the
policy_max
argument ofcmake_minimum_required
could be used to fix the warning.