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

[Question] How do I get information back from CMake after configuring a library? #169

Open
btzy opened this issue Nov 26, 2022 · 1 comment

Comments

@btzy
Copy link

btzy commented Nov 26, 2022

I have a CMake library that conditionally adds link time dependencies based on the output of a check_cxx_source_compiles command. That's all fine when building a CMake project, but when building a Cargo library I need to add a line like this into build.rs:

println!("cargo:rustc-link-lib=framework=XXX");

To mimic the behaviour of the CMake library, I will need to somehow retrieve the value of the variable that is set by the check_cxx_source_compiles command. That might not be possible directly, but it should be possible determine the value by reading (in build.rs) the output of the CMake configure command.

Is there a way to go about doing that? Or more generally, does cmake-rs have a good way to get information back from CMake after the CMake library is configured?

@Xaldew
Copy link

Xaldew commented Feb 2, 2023

Looks like this is the same problem I ran into here:

https://stackoverflow.com/questions/74851275/rust-cargo-cmake-integration-with-c-library-dependencies

As far as I can tell, this crate is currently only driving the configuration/building process, so it does not have access to any information like that.

I guess in the future, one can imagine parsing the cmake install-config (e.g., https://gitlab.kitware.com/cmake/community/-/wikis/doc/tutorials/How-to-create-a-ProjectConfig.cmake-file) but that is probably a massive undertaking

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

No branches or pull requests

2 participants