# cmake how to make the build final execute file to another directory

**URL:** https://discourse.cmake.org/t/cmake-how-to-make-the-build-final-execute-file-to-another-directory/6044
**Category:** Usage
**Created:** [July 11, 2022, 3:03pm UTC](https://discourse.cmake.org/t/cmake-how-to-make-the-build-final-execute-file-to-another-directory/6044 "2022-07-11T15:03:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jian\_he](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/9d8465/32.png) [@jian\_he](https://discourse.cmake.org/u/jian_he)
#### Post date: [July 11, 2022, 3:03pm UTC](https://discourse.cmake.org/t/cmake-how-to-make-the-build-final-execute-file-to-another-directory/6044/1 "2022-07-11T15:03:41Z")

</div>

Allow me:  
[https://cmake.org/cmake/help/latest/guide/tutorial/A%20Basic%20Starting%20Point.html](https://cmake.org/cmake/help/latest/guide/tutorial/A%20Basic%20Starting%20Point.html)

current directory: /home/jian/helloc/cmake\_begin/step1  
then

cd …/step1

then it will return the same directory.

Current CMakeLists.txt

> cmake\_minimum\_required(VERSION 3.10)
> 
> project(tutorial)
> 
> add\_executable(tutorial101 tutorial.c)

```auto
cmake ../step1

```

```auto
cmake --build .

```

```auto
then It will generate a executable file then I do 

 ./tutorial101

```

```auto
will print out hello world.
```

---

<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: [July 15, 2022, 2:19pm UTC](https://discourse.cmake.org/t/cmake-how-to-make-the-build-final-execute-file-to-another-directory/6044/2 "2022-07-15T14:19:50Z")

</div>

I think you’re looking for [`CMAKE_RUNTIME_OUTPUT_DIRECTORY`](https://cmake.org/cmake/help/latest/variable/CMAKE_RUNTIME_OUTPUT_DIRECTORY.html).
