# Install components with presets

**URL:** https://discourse.cmake.org/t/install-components-with-presets/3590
**Category:** Usage
**Created:** [June 18, 2021, 8:49am UTC](https://discourse.cmake.org/t/install-components-with-presets/3590 "2021-06-18T08:49:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![KUGA2](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kuga2/32/4968_2.png) [@KUGA2](https://discourse.cmake.org/u/KUGA2)
#### Post date: [June 18, 2021, 8:49am UTC](https://discourse.cmake.org/t/install-components-with-presets/3590/1 "2021-06-18T08:49:52Z")

</div>

I usually install components with:  
`cmake -DCOMPONENT=componentA -P cmake_install.cmake`  
With workdir in Build dir (specified in configure call)

With presets, the Build dir is burried somewhere in the CMakePresets.json file. I do not know it without parsing the file and completing the macros:  
` "binaryDir": "${sourceDir}/Build/$env{TOOLCHAIN}-$env{BUILD_TYPE}-${generator}",`

This is a pain so I hoped, I could use `cmake --install` (introduced in 3.15) like  
`cmake --install --component componentA --preset presetA`  
but it did not work.

Is there an other way or would this be a new feature?

---

<div class="post-metadata">

### Author: ![KUGA2](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kuga2/32/4968_2.png) [@KUGA2](https://discourse.cmake.org/u/KUGA2)
#### Post date: [June 18, 2021, 10:23am UTC](https://discourse.cmake.org/t/install-components-with-presets/3590/2 "2021-06-18T10:23:02Z")

</div>

A workaround is:

```auto
add_custom_target(install_componentA
   # Dont use cmake --install for compatibility
   COMMAND ${CMAKE_COMMAND} cmake -DCOMPONENT=componentA -P ${CMAKE_BINARY_DIR}/cmake_install.cmake
)

```

And then use:  
`cmake --build --preset presetA --target install_componentA`

---

<div class="post-metadata">

### Author: ![claremacrae](https://discourse.cmake.org/user_avatar/discourse.cmake.org/claremacrae/32/1470_2.png) [@claremacrae](https://discourse.cmake.org/u/claremacrae)
#### Post date: [June 27, 2021, 3:49pm UTC](https://discourse.cmake.org/t/install-components-with-presets/3590/3 "2021-06-27T15:49:59Z")

</div>

I made a proposal in [Help converting most of a CI matrix to presets?](https://discourse.cmake.org/t/help-converting-most-of-a-ci-matrix-to-presets/3391) that should help you with this… I’d appreciate in up-vote there if possible…

I’ll also add a comment linking to this one…
