52 releases

0.1.51 Aug 15, 2024
0.1.50 Mar 28, 2023
0.1.49 Oct 29, 2022
0.1.48 Jan 6, 2022
0.1.1 Jul 31, 2015

#2 in Build Utils

Download history 501461/week @ 2024-07-27 482451/week @ 2024-08-03 531310/week @ 2024-08-10 551321/week @ 2024-08-17 556498/week @ 2024-08-24 542712/week @ 2024-08-31 578478/week @ 2024-09-07 514681/week @ 2024-09-14 590629/week @ 2024-09-21 587136/week @ 2024-09-28 605719/week @ 2024-10-05 606033/week @ 2024-10-12 653391/week @ 2024-10-19 637189/week @ 2024-10-26 614473/week @ 2024-11-02 509354/week @ 2024-11-09

2,520,942 downloads per month
Used in 2,866 crates (581 directly)

MIT/Apache

45KB
802 lines

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.


lib.rs:

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");

Dependencies

~215–305KB