Skip to content

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

Open
@jonhoo

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions