Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make corrosion_install work for library files and update docs #543

Merged
merged 5 commits into from
Aug 3, 2024

Conversation

gtker
Copy link
Contributor

@gtker gtker commented Aug 2, 2024

Works on #415 and #63.

This only installs the actual library file(s) and not extras such as headers.

Not tested on Windows for compatibility with import library files for shared libraries.

I moved the function definition out to be used as an anchor so it could be used for docs without modifying it, since I'm not entirely sure what the planned feature set of it is going to be.

Gtker added 2 commits August 2, 2024 20:23
Works on corrosion-rs#415.

This only installs the actual library file(s) and not extras such as
headers.

Not tested on Windows for compatibility with import library files for
shared libraries.
Works on corrosion-rs#63.

The function definition is currently prescriptive, since it describes
features that don't currently work.

EXPORT causes a FATAL_ERROR, and PRIVATE_HEADER/PUBLIC_HEADER do
nothing.
Copy link
Collaborator

@jschwe jschwe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, and especially for also adding documentation!

cmake/Corrosion.cmake Outdated Show resolved Hide resolved
[CONFIGURATIONS [Debug|Release|<other-configuration>]]
] [...])
```
* **TARGETS**: Target or targets to install.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should clarify here that the targets must have been targets added by corrosion. Perhaps something like:

Rust library or executable targets imported by corrosion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, but I'm not certain, that we'll need to accept all target kinds, since if the users want to create C++ bindings as well they will need to create a new target that depends on the rust lib target. Then in install(TARGETS rust-lib cpp-bindings EXPORT MyProjectTargets) we need to list all targets and their dependents, otherwise it will error.

cmake/Corrosion.cmake Outdated Show resolved Hide resolved
doc/src/usage.md Show resolved Hide resolved
doc/src/usage.md Outdated Show resolved Hide resolved
cmake/Corrosion.cmake Outdated Show resolved Hide resolved
endif()

install(
IMPORTED_RUNTIME_ARTIFACTS ${INSTALL_TARGET}-shared
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I'm the one that suggested looking into IMPORTED_RUNTIME_ARTIFACTS, but after reading the documentation again, I'm thinking that the usecase is meant to install an IMPORTED executable along with all the dynamic libraries it depends on.

I guess there could be Rust shared libraries, which depend on other shared libraries, so having CMake automatically also install those would be helpful. But I'm not sure if that would actually work as I'm expecting now, so I think we probably really need to test this out in an example project.

Have you tested the shared library install locally and can confirm it works in practice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested the shared library install locally and can confirm it works in practice?

Yes, I have tested it on Linux.

Inside the is_odd directory of my example repository I run

cmake -B build -S . -G Ninja && cmake --build build && cmake --install build --prefix /tmp/install

and it outputs

-- Install configuration: ""
-- Installing: /tmp/install/lib/libis_odd.a
-- Installing: /tmp/install/lib/libis_odd.so

I guess there could be Rust shared libraries, which depend on other shared libraries, so having CMake automatically also install those would be helpful.

I am unsure if this also installs Windows .lib files, but I know for sure that the manual approach doesn't, so I preferred this way.

@gtker
Copy link
Contributor Author

gtker commented Aug 3, 2024

Not sure if I have broken the MacOS tests, but it seems unrelated.

@jschwe
Copy link
Collaborator

jschwe commented Aug 3, 2024

The test failures on macos are unrelated to this PR.

@gtker
Copy link
Contributor Author

gtker commented Aug 3, 2024

@jschwe Do you need anything else from me on this PR?

doc/src/usage.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@jschwe jschwe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still one todo in the documentation that should be addressed before merging. Otherwise, looks fine for an initial implementation. Lets see how it works in practice.
If I have some time next week, I'll try to add a test.

cmake/Corrosion.cmake Outdated Show resolved Hide resolved
@gtker
Copy link
Contributor Author

gtker commented Aug 3, 2024

There is still one todo in the documentation that should be addressed before merging.

Fixed.

If I have some time next week, I'll try to add a test.

Cool. The https://github.com/gtker/corrosion_export repo can be used with the functionality that is now done in corrosion_install removed.

@jschwe jschwe merged commit 9f7c08e into corrosion-rs:master Aug 3, 2024
31 of 36 checks passed
@gtker gtker deleted the update-install branch August 3, 2024 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants