Skip to content

Commit 2289cee

Browse files
committed
Add CARGO_MANIFEST_DIR to the C++ include path by default
1 parent 4f1e072 commit 2289cee

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cpp_build/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ The OUT_DIR environment variable was not set.
5656
NOTE: rust-cpp's build function must be run in a build script."#));
5757

5858
static ref CPP_DIR: PathBuf = OUT_DIR.join("rust_cpp");
59+
60+
static ref CARGO_MANIFEST_DIR: PathBuf =
61+
PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect(r#"
62+
-- rust-cpp fatal error --
63+
64+
The CARGO_MANIFEST_DIR environment variable was not set.
65+
NOTE: rust-cpp's build function must be run in a build script."#));
5966
}
6067

6168
fn gen_cpp_lib(visitor: &Handle) -> PathBuf {
@@ -248,6 +255,7 @@ impl Config {
248255
pub fn new() -> Config {
249256
let mut gcc = gcc::Build::new();
250257
gcc.cpp(true);
258+
gcc.include(&*CARGO_MANIFEST_DIR);
251259
Config { gcc: gcc }
252260
}
253261

0 commit comments

Comments
 (0)