# CMake Error: Unknown argument --install

**URL:** https://discourse.cmake.org/t/cmake-error-unknown-argument-install/13445
**Category:** Usage
**Created:** [January 22, 2025, 1:31am UTC](https://discourse.cmake.org/t/cmake-error-unknown-argument-install/13445 "2025-01-22T01:31:15Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![vfdff](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vfdff/32/5296_2.png) [@vfdff](https://discourse.cmake.org/u/vfdff)
#### Post date: [January 22, 2025, 1:31am UTC](https://discourse.cmake.org/t/cmake-error-unknown-argument-install/13445/1 "2025-01-22T01:31:15Z")

</div>

I download cmake-3.31.4.tar.gz and try to build it local, so I use the following comands:

> mkdir build install  
> cd build  
> cmake …/ --build . --install …/intall

it reports a strange error as I can see the option **–install** with cmake --help,

> CMake Error: Unknown argument --install

my local cmake version is

> cmake version 3.31.0

---

<div class="post-metadata">

### Author: ![Angew](https://discourse.cmake.org/user_avatar/discourse.cmake.org/angew/32/229_2.png) [@Angew](https://discourse.cmake.org/u/Angew)
#### Post date: [January 22, 2025, 8:23am UTC](https://discourse.cmake.org/t/cmake-error-unknown-argument-install/13445/2 "2025-01-22T08:23:42Z")

</div>

Short version: these cannot be used together.

Full version:  
CMake has several modes in which it can be run, which are triggered by different command-line arguments:

- Generate a buildsystem: no special argument, or use `-B` and maybe `-S`
- Build a project: `cmake --build`
- Install a project: `cmake --install`
- And many others

You can think of `cmake --build` and `cmake --install` as subcommands in the same way as e.g. `git status` and `git commit`. Just like `git status . commit .` does not work, neither does `cmake --build --install`.

---

<div class="post-metadata">

### Author: ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)
#### Post date: [January 22, 2025, 2:39pm UTC](https://discourse.cmake.org/t/cmake-error-unknown-argument-install/13445/3 "2025-01-22T14:39:50Z")

</div>

try `cmake --build . --target install`  
but the corresponding project must, of course, support installation.

---

<div class="post-metadata">

### Author: ![vfdff](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vfdff/32/5296_2.png) [@vfdff](https://discourse.cmake.org/u/vfdff)
#### Post date: [January 23, 2025, 7:32am UTC](https://discourse.cmake.org/t/cmake-error-unknown-argument-install/13445/4 "2025-01-23T07:32:58Z")

</div>

Thanks @adaldev @Angew ,but I still fail even with **cmake …/ --build .**

> (base) root@szvphis3874429:/home/zhongyunde/cann\_code/asl/aoetools/aoe/buildtmp# cmake …/ --build .  
> CMake Error: Unknown argument --build

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [January 23, 2025, 7:47am UTC](https://discourse.cmake.org/t/cmake-error-unknown-argument-install/13445/5 "2025-01-23T07:47:27Z")

</div>

Please take a look at: [https://cmake.org/cmake/help/latest/manual/cmake.1.html](https://cmake.org/cmake/help/latest/manual/cmake.1.html)  
Especially:

> [Build a Project](https://cmake.org/cmake/help/latest/manual/cmake.1.html#build-a-project)  
> cmake --build \<dir\> [\<options\>] [-- \<build-tool-options\>]

---

<div class="post-metadata">

### Author: ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)
#### Post date: [January 23, 2025, 7:54am UTC](https://discourse.cmake.org/t/cmake-error-unknown-argument-install/13445/6 "2025-01-23T07:54:56Z")

</div>

See Jakub Zarzewski answer. You have also switched the command and the path.

Besides, as told within the doc, my command line is only available if a target command “install” is generated. It may depend on how the CMakeLists is written. I’m not sure about what are exactly the requirements to have this target.

---

<div class="post-metadata">

### Author: ![vfdff](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vfdff/32/5296_2.png) [@vfdff](https://discourse.cmake.org/u/vfdff)
#### Post date: [January 23, 2025, 8:29am UTC](https://discourse.cmake.org/t/cmake-error-unknown-argument-install/13445/7 "2025-01-23T08:29:51Z")

</div>

Thanks it works fine with **cmake -S … -B build**

---

<div class="post-metadata">

### Author: ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)
#### Post date: [January 23, 2025, 10:22am UTC](https://discourse.cmake.org/t/cmake-error-unknown-argument-install/13445/8 "2025-01-23T10:22:53Z")

</div>

There seems to be a confusion in usage.  
cmake -S … -B build will only perform configuration and generation  
cmake --build . \<–target install\> will build an already generated project (and optionally install the result)

Fine if you achieved what you wanted. Regards  
A.
