build cmake

A build dependency for running cmake to build a native library

43 releases

0.1.42 Aug 27, 2019
0.1.40 May 14, 2019
0.1.37 Mar 28, 2019
0.1.35 Sep 30, 2018
0.1.1 Jul 31, 2015

#6 in Build Utils

Download history 34377/week @ 2019-12-17 19474/week @ 2019-12-24 23221/week @ 2019-12-31 38443/week @ 2020-01-07 35958/week @ 2020-01-14 33052/week @ 2020-01-21 33631/week @ 2020-01-28 31289/week @ 2020-02-04 29029/week @ 2020-02-11 30471/week @ 2020-02-18 30925/week @ 2020-02-25 33906/week @ 2020-03-03 33936/week @ 2020-03-10 38716/week @ 2020-03-17 39897/week @ 2020-03-24 34983/week @ 2020-03-31

149,705 downloads per month
Used in 636 crates (168 directly)


610 lines



A build dependency for running the cmake build tool to compile a native library.

# Cargo.toml
cmake = "0.1"

The CMake executable is assumed to be cmake unless the CMAKE environmental variable is set.


This project is licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in cmake by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


A build dependency for running cmake to build a native library

This crate provides some necessary boilerplate and shim support for running the system cmake command to build a native library. It will add appropriate cflags for building code to link into Rust, handle cross compilation, and use the necessary generator for the platform being targeted.

The builder-style configuration allows for various variables and such to be passed down into the build as well.


Add this to your Cargo.toml:

cmake = "0.1"


use cmake;

// Builds the project in the directory located in `libfoo`, installing it
// into $OUT_DIR
let dst = cmake::build("libfoo");

println!("cargo:rustc-link-search=native={}", dst.display());
use cmake::Config;

let dst = Config::new("libfoo")
                 .define("FOO", "BAR")
println!("cargo:rustc-link-search=native={}", dst.display());