# using external Libraries

**URL:** https://discourse.cmake.org/t/using-external-libraries/15665
**Category:** Code
**Created:** [May 26, 2026, 4:06pm UTC](https://discourse.cmake.org/t/using-external-libraries/15665 "2026-05-26T16:06:40Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![pedahl](https://discourse.cmake.org/user_avatar/discourse.cmake.org/pedahl/32/3307_2.png) [@pedahl](https://discourse.cmake.org/u/pedahl)
#### Post date: [May 26, 2026, 4:06pm UTC](https://discourse.cmake.org/t/using-external-libraries/15665/1 "2026-05-26T16:06:40Z")

</div>

Hi,  
i have a project with a lot of external lib (Windows; dll files).  
I have build for every Library (most of the libraries have many dll) a Config.cmake file, with a component for every .dll and in the projects and subprojects i link again the component.  
It this the correct way to integrate external .dll files (we have only binaries)???  
And how is it intended if a component need another component?  
e.g. I have MyLib which a base\_component, first\_component and second\_component.  
How can i handle it that the base\_component is every time linked against first\_component?  
Do have anyone an example for it?

Bests

Brian

---

<div class="post-metadata">

### Author: ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)
#### Post date: [May 27, 2026, 1:45pm UTC](https://discourse.cmake.org/t/using-external-libraries/15665/2 "2026-05-27T13:45:27Z")

</div>

Hello,

Please note I am not an expert. Maybe I’ll tell you bullshits.

> [@pedahl](#):
>
> I have build for every Library (most of the libraries have many dll) a Config.cmake file, with a component for every .dll and in the projects and subprojects i link again the component.  
> It this the correct way to integrate external .dll files (we have only binaries) ???

I think the DLL should be put in the package, but you’ll ahve to define two kinds of targets:

- targets to link to (.lib)
- targets to copy (.dll)

and document them.

> [@pedahl](#):
>
> And how is it intended if a component need another component?  
> e.g. I have MyLib which a base\_component, first\_component and second\_component.  
> How can i handle it that the base\_component is every time linked against first\_component?

In the CMakeLists.txt of your package, withe the compoents Core and Gui, do:

```cmake
add_library(MyLibCore ...)
add_library(MyLibGu ...)

target_link_libraries(MyLibGui PUBLIC MyLibCore)

...

install(TARGETS ...
install(EXPORT ...)
configure_package_config_file(...)

```
