Skip to content

Commit

Permalink
Fix CORROSION_INSTALL_EXECUTABLE
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jschwe authored and ogoffart committed Jan 3, 2022
1 parent 8d24382 commit 97d4401
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand 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
Expand Down

0 comments on commit 97d4401

Please sign in to comment.