Skip to content

Skip CMake configure step when CMakeCache.txt is present in build folder #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub struct Config {
env: Vec<(OsString, OsString)>,
static_crt: Option<bool>,
uses_cxx11: bool,
always_configure: bool,
}

/// Builds the native library rooted at `path` with the default cmake options.
Expand Down Expand Up @@ -112,7 +113,8 @@ impl Config {
cmake_target: None,
env: Vec::new(),
static_crt: None,
uses_cxx11: false
uses_cxx11: false,
always_configure: true,
}
}

Expand Down Expand Up @@ -234,6 +236,15 @@ impl Config {
self
}

/// Forces CMake to always run before building the custom target.
///
/// In some cases, when you have a big project, you can disable
/// subsequents runs of cmake to make `cargo build` faster.
pub fn always_configure(&mut self, always_configure: bool) -> &mut Config {
self.always_configure = always_configure;
self
}

/// Run this configuration, compiling the library with all the configured
/// options.
///
Expand Down Expand Up @@ -496,7 +507,10 @@ impl Config {
cmd.env(k, v);
}

run(cmd.env("CMAKE_PREFIX_PATH", cmake_prefix_path), "cmake");
if self.always_configure || !build.join("CMakeCache.txt").exists() {
println!("CMake project was already configured. Skipping configuration step.");
run(cmd.env("CMAKE_PREFIX_PATH", cmake_prefix_path), "cmake");
}

let mut makeflags = None;
let mut parallel_args = Vec::new();
Expand Down