# Handling the installation of external dependencies

**URL:** <https://discourse.cmake.org/t/handling-the-installation-of-external-dependencies/4467>\
**Category:** Code\
**Created:** [November 11, 2021, 12:03am UTC](https://discourse.cmake.org/t/handling-the-installation-of-external-dependencies/4467 "2021-11-11T00:03:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dylan\_Reedy](https://discourse.cmake.org/user_avatar/discourse.cmake.org/dylan_reedy/32/1533_2.png) [@Dylan\_Reedy](https://discourse.cmake.org/u/Dylan_Reedy)\
**Post date:** [November 11, 2021, 12:03am UTC](https://discourse.cmake.org/t/handling-the-installation-of-external-dependencies/4467/1 "2021-11-11T00:03:38Z")

</div>

Hi all,

I’m trying to get my project, which has a non-CMake-target dependency, to link its dependency publically:

```auto
target_link_libraries(MyLibrary
    PUBLIC
         $<BUILD_INTERFACE:${MyDependency}>
         $<INSTALL_INTERFACE:lib/libMyDependency.so>
)

```

This builds and links MyLibrary without issue, but MyLibrary.config comes out wrong:

```auto
set_target_properties(MyPackage::MyLibrary PROPERTIES
     ...
     INTERFACE_LINK_LIBRARIES "MyPackage::MyCMakeDependency;lib/libMyDependency.so"
     ...
)

```

I would’ve expected `lib/libMyDependency.so` to be prefixed with `${_IMPORT_PREFIX}` in the same way that my interface include directories are. Any thoughts on what I’m doing wrong here?

Thanks!

---

<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:** [November 11, 2021, 1:11am UTC](https://discourse.cmake.org/t/handling-the-installation-of-external-dependencies/4467/2 "2021-11-11T01:11:58Z")

</div>

That wouldn’t work because if a string such as `"dl"` shows up, that should _not_ get `${_IMPORT_PREFIX}` on it. I would recommend making a target and exporting it:

```cmake
# in build
add_library(external UNKNOWN IMPORTED)
set_target_properties(external PROPERTIES
  IMPORTED_LOCATION "$<BUILD_INTERFACE:${MyDependency}>$<INSTALL_INTERFACE:…>")

```

I don’t know how easy it is to get `${_IMPORT_PREFIX}` as you need it in that property though.
