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 3535//! use cmake::Config;
3636//!
3737//! let dst = Config::new("libfoo")
38- //! .define("FOO", "BAR")
38+ //! .define("FOO", "BAR") // -DFOO=BAR
39+ //! .define_bool("BAZ", true) // -DBAZ=ON
3940//! .cflag("-foo")
4041//! .build();
4142//! println!("cargo:rustc-link-search=native={}", dst.display());
@@ -272,6 +273,11 @@ impl Config {
272273 self
273274 }
274275
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+
275281 /// Registers a dependency for this compilation on the native library built
276282 /// by Cargo previously.
277283 ///
You can’t perform that action at this time.
0 commit comments