# ExternalProject\_Add creates wrong folder

**URL:** https://discourse.cmake.org/t/externalproject-add-creates-wrong-folder/1041
**Category:** Code
**Tags:** os:windows
**Created:** [April 16, 2020, 9:25am UTC](https://discourse.cmake.org/t/externalproject-add-creates-wrong-folder/1041 "2020-04-16T09:25:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Lotte1990](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lotte1990/32/529_2.png) [@Lotte1990](https://discourse.cmake.org/u/Lotte1990)
#### Post date: [April 16, 2020, 9:25am UTC](https://discourse.cmake.org/t/externalproject-add-creates-wrong-folder/1041/1 "2020-04-16T09:25:25Z")

</div>

In my project’s CMakeLists.txt I’m adding external projects like this:

```
externalproject_add(xxx GIT_REPOSITORY xxxrepo SOURCE_DIR ../../../3rdParty/xxx/src BUILD_DIR ../../../3rdParty/xxx/build)
externalproject_add(yyy GIT_REPOSITORY yyyrepo SOURCE_DIR ../../../3rdParty/yyy/src BUILD_DIR ../../../3rdParty/yyy/build)

```

The (out of tree) “3rdParty” folder already exists and has some other content. I would like CMake to add the folders “xxx” and “yyy” to this “3rdParty” folder. However, when I configure my project, what happens is that within the “3rdParty” folder, another “3rdParty” folder is created (perhaps because it already exists?). So the files end up in “…/…/…/3rdParty/3rdParty/xxx/src” and “…/…/…/3rdParty/3rdParty/yyy/src” etc instead of “…/…/…/3rdParty/xxx/src” and “…/…/…/3rdParty/yyy/src”.

I tried to create the folders before calling externalproject\_add using file(MAKE\_DIRECTORY …), which does work as expected. Now the folders are created correctly, but externalproject\_add still creates its own 3rdParty/3Party folder puts everything there.

Am I doing something wrong or is this a bug? I would like to know how to fix it. Thanks in advance!

Edit: I’m running CMake 3.17.1 (cmake-gui) on Windows 10.

---

<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: [April 16, 2020, 5:47pm UTC](https://discourse.cmake.org/t/externalproject-add-creates-wrong-folder/1041/2 "2020-04-16T17:47:31Z")

</div>

My guess is that things like `STAMP_DIR` and such are still using some other prefix. Are things fixed if you move `STAMP_DIR`, `TMP_DIR`, and any others mentioned in the docs?

I recommend using absolute paths in these kinds of things anyways, but I don’t think that’s related to the behavior at hand.

---

<div class="post-metadata">

### Author: ![Lotte1990](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lotte1990/32/529_2.png) [@Lotte1990](https://discourse.cmake.org/u/Lotte1990)
#### Post date: [April 17, 2020, 9:46am UTC](https://discourse.cmake.org/t/externalproject-add-creates-wrong-folder/1041/3 "2020-04-17T09:46:01Z")

</div>

Ok, so I found my -rather stupid- mistake. I was using BUILD\_DIR instead of BINARY\_DIR in externalproject\_add.
