# target vs component based install

**URL:** https://discourse.cmake.org/t/target-vs-component-based-install/4285
**Category:** Usage
**Created:** [October 14, 2021, 10:48pm UTC](https://discourse.cmake.org/t/target-vs-component-based-install/4285 "2021-10-14T22:48:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kfsone](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kfsone/32/1880_2.png) [@kfsone](https://discourse.cmake.org/u/kfsone)
#### Post date: [October 14, 2021, 10:48pm UTC](https://discourse.cmake.org/t/target-vs-component-based-install/4285/1 "2021-10-14T22:48:02Z")

</div>

Working on modernizing a non-trivial monorepo with a significant amount of it’s own tooling (code gen, asset conversion, etc). As part of this I wanted to incorporate cmake tooling to build some of the tools and install them into their final locations in the monorepo.

For instance, we have a build target called “Pipeline” which builds all the tools, by depending on targets “CodeGen, Conversion, …, Distribution”. “CodeGen” has multiple sub-targets with multiple sub-targets…

Using `install(...COMPONENT...)` is not nothing, but it introduces duplications and - to get a semblance of the granularity we want - means repeating things in aggregate, which tends to encourage falling back to old-school “everything in variables” pattern.

Is there any facility for building meta-components or anything like that? You can reference a single component from multiple install()s, but you don’t appear to be able to do, e.g:

```auto
INSTALL(TARGETS executable COMPONENT App COMPONENT JustExe ...)
INSTALL(TARGETS library COMPONENT App COMPONENT JustLib ...)

```

This results in components JustExe and JustLib but not App.

---

<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: [October 15, 2021, 11:29pm UTC](https://discourse.cmake.org/t/target-vs-component-based-install/4285/2 "2021-10-15T23:29:38Z")

</div>

@kyle.edwards has done some work with components before. Setting up component dependencies would be something I’d be interested in seeing (though no time to make it happen).

---

<div class="post-metadata">

### Author: ![kfsone](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kfsone/32/1880_2.png) [@kfsone](https://discourse.cmake.org/u/kfsone)
#### Post date: [October 19, 2021, 5:31pm UTC](https://discourse.cmake.org/t/target-vs-component-based-install/4285/3 "2021-10-19T17:31:41Z")

</div>

In the short term I’ll likely fall back on writing macros/functions to move stuff up and out of cmake so I can write my own install wrapper using a config file and allow the user to use _target_ names consistently between build and install.
