Skip to content

Conversation

@justsmth
Copy link
Contributor

@justsmth justsmth commented Dec 12, 2025

Issues:

Addresses: #261

Description

The -B CLI option for cmake was introduced in v3.13, but is not available in v3.12 or earlier.

Testing

I built cmake v3.5 locally, and verified that this change fixes the build failure we were experiencing.

...
   Compiling cmake v0.1.55 (/home/justsmth/repos/cmake-rs)
   Compiling aws-lc-sys v0.34.0 (/home/justsmth/repos/aws-lc-rs/aws-lc-sys)
warning: [email protected]: Environment Variable found 'AWS_LC_SYS_CMAKE_BUILDER': '1'
warning: [email protected]: Value: 1 is true.
warning: [email protected]: Emitting configuration: cargo:rustc-cfg=x86_64_unknown_linux_gnu
warning: [email protected]: Environment Variable found 'CMAKE': '/home/justsmth/cmake-3.5/bin/cmake'
warning: [email protected]: CMAKE environment variable set: /home/justsmth/cmake-3.5/bin/cmake
warning: [email protected]: Building with: CMake
warning: [email protected]: Symbol Prefix: Some("aws_lc_0_34_0")
warning: [email protected]: Environment Variable found 'CMAKE': '/home/justsmth/cmake-3.5/bin/cmake'
warning: [email protected]: CMAKE environment variable set: /home/justsmth/cmake-3.5/bin/cmake
warning: [email protected]: Target platform: 'x86_64-unknown-linux-gnu'
warning: [email protected]: Compilation of 'c11.c' succeeded - Ok(["/home/justsmth/repos/aws-lc-rs/target/debug/build/aws-lc-sys-a6f8ef1634cae444/out/out-c11/7dfda64fdf5a526c-c11.o"]).
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 11.08s

justsmth referenced this pull request Dec 12, 2025
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).
```
Copy link
Member

@ChrisDenton ChrisDenton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense to me. The -B option was only introduced to this crate fairly recently so we're no worse off than before for older versions.

@ChrisDenton ChrisDenton merged commit 060922d into rust-lang:master Dec 13, 2025
28 checks passed
@github-actions github-actions bot mentioned this pull request Dec 13, 2025
@ChrisDenton ChrisDenton linked an issue Dec 13, 2025 that may be closed by this pull request
@justsmth justsmth deleted the fix-cmake-3.5 branch December 13, 2025 14:01
@justsmth
Copy link
Contributor Author

Make sense to me. The -B option was only introduced to this crate fairly recently so we're no worse off than before for older versions.

We have a few consumers still using older versions of CMake. Any chance another patch release might be posted for this soon?

ChrisDenton pushed a commit that referenced this pull request Dec 13, 2025
## 🤖 New release

* `cmake`: 0.1.55 -> 0.1.56 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.1.56](v0.1.55...v0.1.56)
- 2025-12-13

### Other

- Fallback to bundled CMake if present
([#264](#264))
- Use `cmake -B` only for v3.13 and later
([#262](#262))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@ChrisDenton
Copy link
Member

A new release has been published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build Failures with CMake 3.12 and earlier

2 participants