Skip to content

Commit b59be3b

Browse files
authored
Make sure that cmake generate build files in current dir (#194)
This should fix the `Error: could not load cache` BUG. If there are already generated build files in the project directory, then if you execute the command `cmake path/project` in `$OUT_DIR/build`, cmake will not generate new build files in the `$OUT_DIR/build` directory. So `-B .` is needed. https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-B Example: ```sh cd /path/to/project cmake . # output `Build files have been written to: /path/to/project` cd /path/to/build && cmake /path/to/project # we expect the build files will be generated at current dir (/path/to/build) # but unfortunately get `Build files have been written to: /path/to/project` cd /path/to/build && cmake /path/to/project -B . # output `Build files have been written to: /path/to/build`, that is right! ``` Infomation: ``` cmake --version cmake version 3.27.7 CMake suite maintained and supported by Kitware (kitware.com/cmake). ```
1 parent e6bfc1c commit b59be3b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,9 @@ impl Config {
585585
}
586586

587587
cmd.arg(&self.path).current_dir(&build_dir);
588+
589+
cmd.arg("-B").arg(&build_dir);
590+
588591
let mut is_ninja = false;
589592
if let Some(ref generator) = generator {
590593
is_ninja = generator.to_string_lossy().contains("Ninja");

0 commit comments

Comments
 (0)