# Library Install based on Usage

**URL:** <https://discourse.cmake.org/t/library-install-based-on-usage/4246>\
**Category:** Code\
**Created:** [October 11, 2021, 4:56pm UTC](https://discourse.cmake.org/t/library-install-based-on-usage/4246 "2021-10-11T16:56:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![VRonin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vronin/32/1369_2.png) [@VRonin](https://discourse.cmake.org/u/VRonin)\
**Post date:** [October 11, 2021, 4:56pm UTC](https://discourse.cmake.org/t/library-install-based-on-usage/4246/1 "2021-10-11T16:56:19Z")

</div>

Hi All,  
In my application I use a dynamically linked library as a git submodule (I’m open to use `ExternalProject` if that helps). The library, however will have it’s own install that looks something like:

```auto
install(TARGETS MyLib
    EXPORT MyLibTargets
    RUNTIME
        DESTINATION ${CMAKE_INSTALL_BINDIR}
        COMPONENT MyLib_Runtime
    LIBRARY
        DESTINATION ${CMAKE_INSTALL_LIBDIR}
        COMPONENT MyLib_Runtime
        NAMELINK_COMPONENT MyLib_Development
    INCLUDES
        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
        COMPONENT MyLib_Development
    ARCHIVE
        DESTINATION ${CMAKE_INSTALL_LIBDIR}
        COMPONENT MyLib_Development
)

```

Which is totally fine when the library is installed as a standalone project but what I would like to do is to just have the runtime included in my install output and redirected to a folder of my choice.  
Is this possible at all?

---

<div class="post-metadata">

**Author:** ![erlendaasland](https://discourse.cmake.org/user_avatar/discourse.cmake.org/erlendaasland/32/1866_2.png) [@erlendaasland](https://discourse.cmake.org/u/erlendaasland)\
**Post date:** [October 11, 2021, 5:32pm UTC](https://discourse.cmake.org/t/library-install-based-on-usage/4246/2 "2021-10-11T17:32:37Z")

</div>

AFAIK, using `ExternalProject_add` with an `INSTALL_COMMAND` tweak is your best option.

[https://cmake.org/cmake/help/latest/module/ExternalProject.html](https://cmake.org/cmake/help/latest/module/ExternalProject.html)
