Open
Description
Most CMake configurations use the ON|OFF
convention to indicate a boolean value. It would be more ergonomic to add a new setter like fn define_bool(&mut self, key: &str, value: bool)
. Some build.rs
scripts could also compute these values during execution, so having this function would simplify
cfg.define("SOMETHING", if flag { "ON" } else { "OFF" });
into
cfg.define_bool("SOMETHING", flag);
Workaround
Without this, I had to add this to all projects that needed this functionality:
trait CfgBool {
fn define_bool(&mut self, key: &str, value: bool);
}
impl CfgBool for cmake::Config {
fn define_bool(&mut self, key: &str, value: bool) {
self.define(key, if value { "ON" } else { "OFF" });
}
}
Metadata
Metadata
Assignees
Labels
No labels