We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
define_bool
1 parent faccc07 commit 663888bCopy full SHA for 663888b
src/lib.rs
@@ -35,7 +35,8 @@
35
//! use cmake::Config;
36
//!
37
//! let dst = Config::new("libfoo")
38
-//! .define("FOO", "BAR")
+//! .define("FOO", "BAR") // -DFOO=BAR
39
+//! .define_bool("BAZ", true) // -DBAZ=ON
40
//! .cflag("-foo")
41
//! .build();
42
//! println!("cargo:rustc-link-search=native={}", dst.display());
@@ -272,6 +273,11 @@ impl Config {
272
273
self
274
}
275
276
+ /// Adds a new `-D` flag with a `ON`/`OFF` value to pass to cmake during the generation step.
277
+ pub fn define_bool<K: AsRef<OsStr>>(&mut self, k: K, v: bool) -> &mut Config {
278
+ self.define(k, if v { "ON" } else { "OFF" })
279
+ }
280
+
281
/// Registers a dependency for this compilation on the native library built
282
/// by Cargo previously.
283
///
0 commit comments