File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 35
35
//! use cmake::Config;
36
36
//!
37
37
//! let dst = Config::new("libfoo")
38
- //! .define("FOO", "BAR")
38
+ //! .define("FOO", "BAR") // -DFOO=BAR
39
+ //! .define_bool("BAZ", true) // -DBAZ=ON
39
40
//! .cflag("-foo")
40
41
//! .build();
41
42
//! println!("cargo:rustc-link-search=native={}", dst.display());
@@ -272,6 +273,11 @@ impl Config {
272
273
self
273
274
}
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
+
275
281
/// Registers a dependency for this compilation on the native library built
276
282
/// by Cargo previously.
277
283
///
You can’t perform that action at this time.
0 commit comments