# Link between "cmake -B" and CMAKE\_CURRENT\_BINARY\_DIR

**URL:** https://discourse.cmake.org/t/link-between-cmake-b-and-cmake-current-binary-dir/9520
**Category:** Code
**Created:** [November 28, 2023, 9:45am UTC](https://discourse.cmake.org/t/link-between-cmake-b-and-cmake-current-binary-dir/9520 "2023-11-28T09:45:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)
#### Post date: [November 28, 2023, 9:45am UTC](https://discourse.cmake.org/t/link-between-cmake-b-and-cmake-current-binary-dir/9520/1 "2023-11-28T09:45:26Z")

</div>

Hello,

Could you please confirm me that **CMAKE\_CURRENT\_BINARY\_DIR** is set by `cmake -B` ?

If so, it would be good the documentation mentions explicitly this link (documentation of one of them referring the other one).

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [November 28, 2023, 1:21pm UTC](https://discourse.cmake.org/t/link-between-cmake-b-and-cmake-current-binary-dir/9520/2 "2023-11-28T13:21:28Z")

</div>

`CMAKE_CURRENT_BINARY_DIR` changes on each `add_subdirectory` call, so this seems like the wrong link to me. It is, instead, closer to `CMAKE_BINARY_DIR`.

---

<div class="post-metadata">

### Author: ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)
#### Post date: [November 28, 2023, 1:32pm UTC](https://discourse.cmake.org/t/link-between-cmake-b-and-cmake-current-binary-dir/9520/3 "2023-11-28T13:32:04Z")

</div>

So the **-B** switch would match to the **CMAKE\_CURRENT\_BINARY\_DIR** of the root CMakeLists.txt, and then would be the same as **CMAKE\_BINARY\_DIR**?

EDIT : fixed typo on the switch

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [November 29, 2023, 11:49am UTC](https://discourse.cmake.org/t/link-between-cmake-b-and-cmake-current-binary-dir/9520/4 "2023-11-29T11:49:48Z")

</div>

> [@Oodini](#):
>
> So the **-D** switch

If you meant `-B`, then this sounds right to me.
