# Explicitly link against public/interface dependencies?

**URL:** <https://discourse.cmake.org/t/explicitly-link-against-public-interface-dependencies/5484>\
**Category:** Code\
**Created:** [April 18, 2022, 11:51am UTC](https://discourse.cmake.org/t/explicitly-link-against-public-interface-dependencies/5484 "2022-04-18T11:51:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![silverqx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/silverqx/32/2353_2.png) [@silverqx](https://discourse.cmake.org/u/silverqx)\
**Post date:** [April 18, 2022, 11:51am UTC](https://discourse.cmake.org/t/explicitly-link-against-public-interface-dependencies/5484/1 "2022-04-18T11:51:54Z")

</div>

Hi, I want to ask if I should explicitly call the `find_package()` and `target_link_libraries()` if they are provided by a library through `INTERFACE_LINK_LIBRARIES`.

A short explanation of what I mean 🤔, I have a shared library `TinyOrm::TinyOrm` that has a public or interface dependencies for eg. `Qt::Core`, `Qt::Sql`, and `range-v3::range-v3` and now I have a project `hello::hello` that links against this `TinyOrm` library.

Should I link against it like this:

```auto
find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core Sql)
tiny_find_package(Qt${QT_VERSION_MAJOR} ${minQtVersion} CONFIG
    REQUIRED COMPONENTS Core Sql
)
tiny_find_package(range-v3 ${minRangeV3Version} CONFIG REQUIRED)
find_package(TinyOrm 0.1.0 CONFIG REQUIRED)

target_link_libraries(hello
    PRIVATE
        Qt${QT_VERSION_MAJOR}::Core
        Qt${QT_VERSION_MAJOR}::Sql
        range-v3::range-v3
        TinyOrm::TinyOrm
)

```

Or like this 🕶:

```auto
find_package(TinyOrm 0.1.0 CONFIG REQUIRED)

target_link_libraries(hello PRIVATE TinyOrm::TinyOrm)

```

Thank you for advice and suggestion. 🙏

---

<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 18, 2022, 2:00pm UTC](https://discourse.cmake.org/t/explicitly-link-against-public-interface-dependencies/5484/2 "2022-04-18T14:00:21Z")

</div>

The second one. However, `TinyOrm` will need to use `find_package` (probably via `find_dependency` from `include(FindDependencyMacro)`) to make its dependency targets available.

---

<div class="post-metadata">

**Author:** ![silverqx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/silverqx/32/2353_2.png) [@silverqx](https://discourse.cmake.org/u/silverqx)\
**Post date:** [April 18, 2022, 2:05pm UTC](https://discourse.cmake.org/t/explicitly-link-against-public-interface-dependencies/5484/3 "2022-04-18T14:05:56Z")

</div>

Ok 👌, I’ve been confused about this since I started using CMake.

But it is logical, why would I duplicate that when it is already defined in the `INTERFACE_LINK_LIBRARIES`.
