Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
//! use cmake::Config;
//!
//! let dst = Config::new("libfoo")
//! .define("FOO", "BAR")
//! .define("FOO", "BAR") // -DFOO=BAR
//! .define_bool("BAZ", true) // -DBAZ=ON
//! .cflag("-foo")
//! .build();
//! println!("cargo:rustc-link-search=native={}", dst.display());
Expand Down Expand Up @@ -272,6 +273,11 @@ impl Config {
self
}

/// Adds a new `-D` flag with a `ON`/`OFF` value to pass to cmake during the generation step.
pub fn define_bool<K: AsRef<OsStr>>(&mut self, k: K, v: bool) -> &mut Config {
self.define(k, if v { "ON" } else { "OFF" })
}

/// Registers a dependency for this compilation on the native library built
/// by Cargo previously.
///
Expand Down
Loading