# CMake usage philosophy - between build and install, what is the good way ?

**URL:** https://discourse.cmake.org/t/cmake-usage-philosophy-between-build-and-install-what-is-the-good-way/5341
**Category:** Usage
**Tags:** os:windows
**Created:** [March 31, 2022, 8:04am UTC](https://discourse.cmake.org/t/cmake-usage-philosophy-between-build-and-install-what-is-the-good-way/5341 "2022-03-31T08:04:20Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Olivier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/d2c977/32.png) [@Olivier](https://discourse.cmake.org/u/Olivier)
#### Post date: [March 31, 2022, 8:04am UTC](https://discourse.cmake.org/t/cmake-usage-philosophy-between-build-and-install-what-is-the-good-way/5341/1 "2022-03-31T08:04:20Z")

</div>

Hello everyone,  
I’m trying to manage a very old monolythic project which contains either static libs or dynamic (around 98) and a set of exe (around 25). I don’t want to break all the work done for years, so I can’t explode all those projects in mini repos …  
So here are my questions :

1 - On a windows environment, what is the CMake install purpose ? Is there a good reason to keep an unix way of thinking (like installing all my exes/dlls in the same bin folder, the static libs in a lib folder…) ? Or is the installation step (for Windows only!) have to create a folder for each project and install dependancies in order to make the exe work without any intervention ?

2 - Since CMake 3.21, there is a very useful expression : TARGET\_RUNTIME\_DLLS but some of my projects uses a “plugin” pattern and those plugins are not linked to the exe. Is there an elegant way to copy those plugins at the POST\_BUILD step ?

Thank you,  
Olivier.

---

<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: [April 7, 2022, 3:12pm UTC](https://discourse.cmake.org/t/cmake-usage-philosophy-between-build-and-install-what-is-the-good-way/5341/2 "2022-04-07T15:12:40Z")

</div>

> [@Olivier](#):
>
> 1 - On a windows environment, what is the CMake install purpose ? Is there a good reason to keep an unix way of thinking (like installing all my exes/dlls in the same bin folder, the static libs in a lib folder…) ? Or is the installation step (for Windows only!) have to create a folder for each project and install dependancies in order to make the exe work without any intervention ?

An install untangles the results of the build from the build itself. Headers are collected in one place, for example, instead of being split between the source and build tree based on whether it is generated or not. Test libraries and executables also get left behind.

Installs are also able to be relocated (moved as a whole to another directory) unlike builds which are usually very “rooted” to where they were built.

> [@Olivier](#):
>
> 2 - Since CMake 3.21, there is a very useful expression : TARGET\_RUNTIME\_DLLS but some of my projects uses a “plugin” pattern and those plugins are not linked to the exe. Is there an elegant way to copy those plugins at the POST\_BUILD step ?

`file(GET_RUNTIME_DEPENDENCIES)` could probably help here. But plugins are “leaves” just like executables and you can use `$<TARGET_RUNTIME_DLLS>` on them as well AFAIK.

---

<div class="post-metadata">

### Author: ![Olivier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/d2c977/32.png) [@Olivier](https://discourse.cmake.org/u/Olivier)
#### Post date: [April 8, 2022, 6:12am UTC](https://discourse.cmake.org/t/cmake-usage-philosophy-between-build-and-install-what-is-the-good-way/5341/3 "2022-04-08T06:12:01Z")

</div>

Thank you very much @ben.boeckel for this answer.

It’s very helpful.  
Do you think it’s a good idea to create, in my project, a CMake function called find\_plugin which check if the plugin name exists, then add the dependency (because the code of the plugin is inside the same repo and the same top cmake) and finally, with a add\_custom\_command at POST\_BUILD time, copy the plugin and its runtime dlls ? Is that compatible with Modern CMake ?

Olivier

---

<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: [April 9, 2022, 12:59pm UTC](https://discourse.cmake.org/t/cmake-usage-philosophy-between-build-and-install-what-is-the-good-way/5341/4 "2022-04-09T12:59:43Z")

</div>

That could work, but I’m sure there are details that need worked out. Qt has some logic around its plugins that might be useful to look at. @craig.scott may know more.
