corrosion-rs / corrosion

Marrying Rust and CMake - Easy Rust and C/C++ Integration!
https://corrosion-rs.github.io/corrosion/
MIT License
1.02k stars 97 forks source link

cmake export (find_package) becomes portable #509

Closed thorsten-klein closed 2 months ago

thorsten-klein commented 2 months ago

Description: Currently the cmake export CorrosionConfig.cmake adds a hardcoded path (CMAKE_INSTALL_FULL_DATADIR) to CMAKE_MODULE_PATH. Unfortunately this path is only valid during build time of corrosion. If the resulting package is shipped (e.g. via a package manager like conan), then the path and therefore also the corrosion package becomes invalid.

Solution: Instead, the import prefix of the package (PACKAGE_PREFIX_DIR) is used.

jschwe commented 2 months ago

Thanks, sounds reasonable.

e.g. via a package manager like conan

Can I assume you tested the fix and can confirm it works with conan?

thorsten-klein commented 2 months ago

Can I assume you tested the fix and can confirm it works with conan?

Yes, tested with cmake 3.26.3 in conan. I am able to consume corrosion now via conan (by using env variable CMAKE_PREFIX_PATH)