-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Support installing libraries #415
Comments
To clarify: the install step is essential to reproduce this issue, correct? |
Yes, the install step is essential to reproduce this issue. It seems that Corrosion is appending a -static suffix to the target name for static libraries, which is causing a mismatch during the linking phase because the library with the -static suffix is not being installed.
|
Using an installed library is curenntly not supported, but it would make sense to add support.
Corrosion creates an INTERFACE target that links to either the |
INTERFACE libraries basically cannot be installed as far as I can tell, but IMPORTED'ed libraries have some minor support. And in-fact with the existing code you can sort of kinda install to the degree cmake allows installing prebuilt binaries.
This is pretty limited and actually doesnt even support headers either, but is documented https://cmake.org/cmake/help/latest/command/install.html#imported-runtime-artifacts Hilariously INTERFACE libraries supposedly do support installing public headers per https://discourse.cmake.org/t/interface-library-not-getting-installed-and-no-error-reported/2185/22 (See the 3.19 test cases and the newer FILE_SET features) Hopefully these workarounds help someone else, but it does not look very good for being able to treat corrosion targets like real first-class cmake targets as it stands. Beyond simple installs both INTERFACE and IMPORTED targets have many other limitations you might experience in a large cmake build. |
Thanks. Mentioning how to do this in the docs would be helpful. 😉 |
I created a repo for a library that works both with Headline is that if(BUILD_SHARED_LIBS)
install(FILES $<TARGET_PROPERTY:is_odd-shared,IMPORTED_LOCATION> DESTINATION lib)
else()
install(FILES $<TARGET_PROPERTY:is_odd-static,IMPORTED_LOCATION> DESTINATION lib)
endif() will copy the library. It seems this issue is tightly coupled to #64, #117, and #63. Ideally I think getting |
@gtker I am unable to reproduce your solution. With a cdylib crate:
I am not able to get to the generated .so through any of the properties IMPORTED_LOCATION, LOCATION, INTERFACE_LINK_LIBRARIES, etc. of the EDIT: in my case (not sure why), there is an intermediate target generated called |
I believe this is always the case as mentioned in #415 (comment) although it would probably be considered an implementation detail and would be subject to change at some point, which is why it would be great to have a working |
Pull requests improving
Some comments about this:
Example (for the first comment about testing if a target exists): if(TARGET ${target_name}-shared)
install(FILES $<TARGET_PROPERTY:is_odd-shared,IMPORTED_LOCATION> DESTINATION lib)
endif()
if(TARGET ${target_name}-static)
install(FILES $<TARGET_PROPERTY:is_odd-static,IMPORTED_LOCATION> DESTINATION lib)
endif() |
Is it OK if I don't create tests for the current
I'll take a look. In the snippet I just used the same format for both shared and static to make it easier to understand what was going on. Ideally I would want people to be able to add headers to the "top level" corrosion target and have that also be installed correctly to make Would it be OK if I submitted PRs of partial features? Like having it install the library files, then the headers, then configs, and so on. |
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.
The way I see it there's a few things that need to be done for this be complete (which would also fix #64, and possibly also #117):
I will try to get through all of these, although I'm not sure when it will be done. |
* Make corrosion_install work for library files Works on #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. * Add `corrosion_install` to public docs Works on #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. * Change corrosion_install according to PR feedback Changes requested in #543. * Fix typo in corrosion_install docs Co-authored-by: Tobias Fella <[email protected]> * Update corrosion_install docstring to remove TODO --------- Co-authored-by: Gtker <[email protected]> Co-authored-by: Tobias Fella <[email protected]>
soname documentation was added in this commit so this issue can be closed now. |
Current Behavior
When attempting to use a Rust library
my_lib
in a C++ applicationmy_app
, using Corrosion, the linker reports an error during the linking phase.Error Output:
Relevant issue: #261 (comment)
Expected Behavior
The
my_app
application should successfully link with themy_lib
Rust library without the need for renaming the output static library file.I was able to temporarily resolve this issue by renaming the output static library as follows:
Steps To Reproduce
Here is a snippet of the CMakeLists.txt file which reproduces the issue:
cmake -S. -Bbuild -DRust_CARGO_TARGET=mips-unknown-linux-gnu ...
Environment
CMake configure log with Debug log-level
No response
CMake Build step log
No response
The text was updated successfully, but these errors were encountered: