build cmake

A build dependency for running cmake to build a native library

45 releases

Uses old Rust 2015

0.1.44 May 18, 2020
0.1.42 Aug 27, 2019
0.1.40 May 14, 2019
0.1.37 Mar 28, 2019
0.1.1 Jul 31, 2015

#19 in Build Utils

Download history 38657/week @ 2020-06-09 35635/week @ 2020-06-16 38102/week @ 2020-06-23 39335/week @ 2020-06-30 42089/week @ 2020-07-07 40967/week @ 2020-07-14 39874/week @ 2020-07-21 39193/week @ 2020-07-28 41078/week @ 2020-08-04 41740/week @ 2020-08-11 40575/week @ 2020-08-18 40936/week @ 2020-08-25 39172/week @ 2020-09-01 41465/week @ 2020-09-08 39153/week @ 2020-09-15 35395/week @ 2020-09-22

170,709 downloads per month
Used in 878 crates (218 directly)


629 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());