From 9e926bf902141f382efdff217faf1ef6683eda80 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Tue, 12 Jul 2022 13:58:52 +0200 Subject: [PATCH] Rename rustflags variable to make global scope clear The currently available way of setting Rustflags is by setting the `RUSTFLAGS` environment variable, which affects all crates in the dependency graph. This may be undesirable in some circumstances, so a future commit will the option to specify RUSTFLAGS via `cargo rustc`, which only affects the current crate and not dependencies. This commit prepares by refactoring some names to make the distinction easier. --- cmake/Corrosion.cmake | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cmake/Corrosion.cmake b/cmake/Corrosion.cmake index d7f0c048..86cf973d 100644 --- a/cmake/Corrosion.cmake +++ b/cmake/Corrosion.cmake @@ -252,10 +252,7 @@ function(_add_cargo_build) set(no_default_libraries_arg --no-default-libraries) endif() - set(rustflags_target_property "$>") - # `rustflags_target_property` may contain multiple arguments and double quotes, so we _should_ single quote it to - # preserve any double quotes and keep it as one argument value. However single quotes don't work on windows, so we - # can only add double quotes here. Any double quotes _in_ the rustflags must be escaped like `\\\"`. + set(global_rustflags_target_property "$>") set(features_target_property "$>") set(features_genex "$<$:--features=$>>") @@ -358,8 +355,8 @@ function(_add_cargo_build) corrosion_add_target_rustflags("${target_name}" "-Cdefault-linker-libraries=yes") endif() - set(joined_rustflags "$") - set(rustflags_genex "$<$:RUSTFLAGS=${joined_rustflags}>") + set(global_joined_rustflags "$") + set(global_rustflags_genex "$<$:RUSTFLAGS=${global_joined_rustflags}>") # Used to set a linker for a specific target-triple. set(cargo_target_linker_var "CARGO_TARGET_${_CORROSION_RUST_CARGO_TARGET_UPPER}_LINKER") @@ -389,7 +386,7 @@ function(_add_cargo_build) COMMAND ${CMAKE_COMMAND} -E env "${build_env_variable_genex}" - "${rustflags_genex}" + "${global_rustflags_genex}" "${cargo_target_linker}" "${corrosion_cc_rs_flags}" "${cargo_library_path}"