59 releases

0.1.58 Mar 26, 2026
0.1.57 Dec 17, 2025
0.1.54 Feb 10, 2025
0.1.52 Nov 25, 2024
0.1.1 Jul 31, 2015

#4 in Build Utils

Download history 1084801/week @ 2025-12-27 2174782/week @ 2026-01-03 2550515/week @ 2026-01-10 2746088/week @ 2026-01-17 2930526/week @ 2026-01-24 3147537/week @ 2026-01-31 3333750/week @ 2026-02-07 3191522/week @ 2026-02-14 3367006/week @ 2026-02-21 3964634/week @ 2026-02-28 4100389/week @ 2026-03-07 3871172/week @ 2026-03-14 3825199/week @ 2026-03-21 3855597/week @ 2026-03-28 3928943/week @ 2026-04-04 4206103/week @ 2026-04-11

16,440,856 downloads per month
Used in 6,592 crates (833 directly)

MIT/Apache

50KB
900 lines

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.

Installation

Add this to your Cargo.toml:

[build-dependencies]
cmake = "0.1"

Examples

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());
println!("cargo:rustc-link-lib=static=foo");
use cmake::Config;

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

cmake

Documentation

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

# Cargo.toml
[build-dependencies]
cmake = "0.1"

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

License

This project is licensed under either of

at your option.

Contribution

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.

Dependencies

~210–315KB