# ExternalProject\_Add command succeed on 3.30.6 and fails on 3.31.1

**URL:** https://discourse.cmake.org/t/externalproject-add-command-succeed-on-3-30-6-and-fails-on-3-31-1/13146
**Category:** Usage
**Tags:** os:linux, gen:ninja
**Created:** [December 6, 2024, 11:51pm UTC](https://discourse.cmake.org/t/externalproject-add-command-succeed-on-3-30-6-and-fails-on-3-31-1/13146 "2024-12-06T23:51:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jonbc](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/7c8e57/32.png) [@jonbc](https://discourse.cmake.org/u/jonbc)
#### Post date: [December 6, 2024, 11:51pm UTC](https://discourse.cmake.org/t/externalproject-add-command-succeed-on-3-30-6-and-fails-on-3-31-1/13146/1 "2024-12-06T23:51:12Z")

</div>

I’ve downloaded:

- v3.30.6 for linux-x86-64 from the [v3.30.6 github release](https://github.com/Kitware/CMake/releases/tag/v3.30.6)
- v3.31.1 for linux-x86-64 from the [v3.31.1 github release](https://github.com/Kitware/CMake/releases/tag/v3.31.1)

I clean the build tree then build with cmake and the command succeeds on 3.30.6 but fails on 3.31.1.

The command looks like:

```cmake
ExternalProject_Add(
  target_name
  PREFIX "/path/"
  DOWNLOAD_DIR "/path"
  SOURCE_DIR "/path"
  BINARY_DIR "/path/build"
)

```

The error occurs at the install step for `target_name`. It says:

```txt
No install step for '<target_name>'
/some/path/<target_name>-install /some/path/<target_name>-install
cd <source_dir>;<binary_dir> && /usr/bin/cmake -E echo_append
&& /usr/bin/cmake -E touch /some/path/<target_name>-install
/bin/sh: 1: cd: can't cd to <SOURCE_DIR>;<BINARY_DIR>
ninja: build stopped: subcommand failed.

```

Please let me know if you need more information.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [December 7, 2024, 9:04pm UTC](https://discourse.cmake.org/t/externalproject-add-command-succeed-on-3-30-6-and-fails-on-3-31-1/13146/2 "2024-12-07T21:04:19Z")

</div>

Please provide the content of the `CMakeLists.txt` file of the external project you are adding. So far, I cannot reproduce the problem with CMake 3.31.1, but I’m on macOS at the moment.

Also, setting `PREFIX` to the same directory as `SOURCE_DIR` is highly questionable. It will result in ExternalProject creating various directories in the external project’s sources. You should consider the `PREFIX` location to be owned by CMake and CMake could create arbitrary files and directories in there. You definitely don’t want to be mixing that with the sources of any external project. If you didn’t specify `SOURCE_DIR`, ExternalProject would have put the sources in a _subdirectory_ of the prefix path.

Actually, unless you have a very good reason, I’d normally recommend not specifying a `PREFIX` at all and just let ExternalProject use its default. Same for the `BINARY_DIR` for that matter. You’ll run into fewer problems if you avoid straying too far from the defaults and putting things in non-default locations.

---

<div class="post-metadata">

### Author: ![jonbc](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/7c8e57/32.png) [@jonbc](https://discourse.cmake.org/u/jonbc)
#### Post date: [December 9, 2024, 5:41pm UTC](https://discourse.cmake.org/t/externalproject-add-command-succeed-on-3-30-6-and-fails-on-3-31-1/13146/3 "2024-12-09T17:41:51Z")

</div>

I ended up removing PREFIX and changing the `COMMAND`’s (no longer running `cd` in a command) to eventually get it to work on 3.31.2. I believe we were just using it incorrectly.
