From 97d44018fac1b1a2a7c095288c628f5bbd9b3184 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Fri, 31 Dec 2021 10:20:53 +0100 Subject: [PATCH] Fix CORROSION_INSTALL_EXECUTABLE Previously `CORROSION_INSTALL_EXECUTABLE` was unused. The documented behaviour is that corrosion-generator is installed only if the option is set. Thus we skip installing the generator in this case. The option was also missing the help text parameter, which caused the value to always default to off. Signed-off-by: Jonathan Schwender --- CMakeLists.txt | 20 +++++++++++++++----- README.md | 4 ++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d8ac4c6..a1a5ae11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,11 @@ else() set(CORROSION_INSTALL_EXECUTABLE_DEFAULT ON) endif() -option(CORROSION_INSTALL_EXECUTABLE ${CORROSION_INSTALL_EXECUTABLE_DEFAULT}) +option( + CORROSION_INSTALL_EXECUTABLE + "Controls whether corrosion-generator is installed with the package" + ${CORROSION_INSTALL_EXECUTABLE_DEFAULT} +) mark_as_advanced(CORROSION_INSTALL_EXECUTABLE) if (_CORROSION_TOP_LEVEL) @@ -88,10 +92,16 @@ corrosion_import_crate(MANIFEST_PATH generator/Cargo.toml) # Set the link language to CXX since it's already enabled corrosion_set_linker_language(corrosion-generator CXX) -corrosion_install( - TARGETS corrosion-generator - DESTINATION ${CORROSION_INSTALL_PREFIX}${CMAKE_INSTALL_LIBEXECDIR} -) +if (CORROSION_INSTALL_EXECUTABLE) + corrosion_install( + TARGETS corrosion-generator + DESTINATION ${CORROSION_INSTALL_PREFIX}${CMAKE_INSTALL_LIBEXECDIR} + ) +elseif (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.15.0") + message(DEBUG "Not installing corrosion-generator since " + "`CORROSION_INSTALL_EXECUTABLE` is set to ${CORROSION_INSTALL_EXECUTABLE}" + ) +endif() # Generate the Config file include(CMakePackageConfigHelpers) diff --git a/README.md b/README.md index a4dafd8b..a0f1ddfa 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,7 @@ corrosion_import_crate(MANIFEST_PATH rust/Cargo.toml FEATURES chocolate vanilla) That's equivalent to calling `cargo build --features chocolate vanilla`. -It is also possible to specify the features as a target list property on the CMake targest created +It is also possible to specify the features as a target list property on the CMake target created by `corrosion_import_crate`. The property is called `CORROSION_FEATURES`. Finally, regarding features, cargo offers the ability to turn off default features or enable all @@ -184,7 +184,7 @@ subdirectory, `ON` if it is the top-level project This is to support scenarios where it's easier to build corrosion-generator outside of the normal bootstrap path, such as in the case of package managers that make it very easy to import Rust crates for fully reproducible, offline builds. -- `CORROSION_INSTALL_EXECUTABLE:BOOL` - Controls whetehr corrosion-generator is installed with the +- `CORROSION_INSTALL_EXECUTABLE:BOOL` - Controls whether corrosion-generator is installed with the package. Default: `ON` with `CORROSION_GENERATOR_EXECUTABLE` unset, otherwise `OFF` ### Importing C-Style Libraries Written in Rust