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

Provide a way to opt out of CMAKE_INSTALL_PREFIX auto-setting #230

Open
jonhoo opened this issue Dec 27, 2024 · 0 comments
Open

Provide a way to opt out of CMAKE_INSTALL_PREFIX auto-setting #230

jonhoo opened this issue Dec 27, 2024 · 0 comments

Comments

@jonhoo
Copy link

jonhoo commented Dec 27, 2024

Currently, cmake will auto-set CMAKE_INSTALL_PREFIX to the output directory if it's not already set

cmake-rs/src/lib.rs

Lines 699 to 703 in 94da9de

if !self.defined("CMAKE_INSTALL_PREFIX") {
let mut dstflag = OsString::from("-DCMAKE_INSTALL_PREFIX=");
dstflag.push(&dst);
cmd.arg(dstflag);
}

This probably makes sense on a general basis, but can cause some issues for crates whose C dependencies get grumpy if the install path is very long (e.g., jonhoo/rust-ibverbs#41). While callers can always set CMAKE_INSTALL_PREFIX to something shorter (e.g., jonhoo/rust-ibverbs#44), especially since chances are no install step is executed, it may be preferable to allow bypassing the logic in cmake entirely somehow and let the guest project's CMake rules (including the built-in ones) take effect. A bool option on the builder should probably be sufficient.

It's worth pointing out that the current logic isn't as obviously correct if the calling code exports binary artifacts from the C build, because those built artifacts may in turn rely on CMAKE_INSTALL_PREFIX in some way, which is unlikely to match the Rust build directory on whatever the intended runtime target system is.

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

1 participant