# Prevent populated imported static library dependencies

**URL:** https://discourse.cmake.org/t/prevent-populated-imported-static-library-dependencies/7086
**Category:** Usage
**Created:** [December 16, 2022, 1:31pm UTC](https://discourse.cmake.org/t/prevent-populated-imported-static-library-dependencies/7086 "2022-12-16T13:31:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![daudrain](https://discourse.cmake.org/user_avatar/discourse.cmake.org/daudrain/32/3013_2.png) [@daudrain](https://discourse.cmake.org/u/daudrain)
#### Post date: [December 16, 2022, 1:31pm UTC](https://discourse.cmake.org/t/prevent-populated-imported-static-library-dependencies/7086/1 "2022-12-16T13:31:26Z")

</div>

Hi,

I am struggling with the current situation: An executable targets depends on external prebuilt DCMTK static libraries . These static DCMTK libraries have been built against crypto and openssl shared libraries, and the link phase expects to find ssl and crypto shared libraries in the directory where they have been built.

So with this following instruction

```auto
target_link_libraries(myapp PRIVATE ${DCMTK_LIBRARIES})

```

leads to a link command containing

```auto
-Lsomeolddirectory/make/build/openssl_1_1_1l/lib
dcmtk/lib/libdcmtls.a
dcmtk/lib/libdcmsr.a
dcmtk/lib/libdcmimage.a
dcmtk/lib/libdcmdsig.a
-lssl
-lcrypto
-ldl
dcmtk/lib/libdcmqrdb.a
dcmtk/lib/libdcmnet.a
dcmtk/lib/libdcmimgle.a
dcmtk/lib/libdcmfg.a
dcmtk/lib/libdcmiod.a
dcmtk/lib/libdcmdata.a
dcmtk/lib/liboflog.a
dcmtk/lib/libofstd.a

```

`DCMTK_LIBRARIES` doesn’t contain ssl or crypto but the static libraries do contain the path `someolddirectory/make/build/openssl_1_1_1l/lib`.

Is there any way to prevent `target_link_libraries` to populate prebuilt static libraries dependencies?

Or is there a way to remove hardcoded library references from static libraries?

Thank you,  
David

---

<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: [December 16, 2022, 1:34pm UTC](https://discourse.cmake.org/t/prevent-populated-imported-static-library-dependencies/7086/2 "2022-12-16T13:34:55Z")

</div>

> [@daudrain](#):
>
> Or is there a way to remove hardcoded library references from static libraries?

DCMTK should move away from using `OpenSSL_LIBRARIES` and instead use an imported target. This allows OpenSSL to be re-found when finding DCMTK so that build-time paths are not baked into the DCMTK install tree. I would encourage `DCMTK_LIBRARIES` to also be specified in terms of imported targets (if not already).

---

<div class="post-metadata">

### Author: ![daudrain](https://discourse.cmake.org/user_avatar/discourse.cmake.org/daudrain/32/3013_2.png) [@daudrain](https://discourse.cmake.org/u/daudrain)
#### Post date: [December 16, 2022, 3:05pm UTC](https://discourse.cmake.org/t/prevent-populated-imported-static-library-dependencies/7086/3 "2022-12-16T15:05:07Z")

</div>

Thank you for your reply.

After replacing `${OPENSSL_LIBS}` with ` OpenSSL::SSL OpenSSL::Crypto` in DCMTK 3.6.6, the generated installed files stopped referencing hardcoded ssl/crypto files: `DCMTKTarget.cmake` does define imported targets, and, for example, `dcmtls` ends up like this:

```auto
set_target_properties(dcmtls PROPERTIES
  INTERFACE_LINK_LIBRARIES "ofstd;dcmdata;dcmnet;OpenSSL::SSL;OpenSSL::Crypto"
)

```

Which makes my build moving forward.

Thank you for your guidance.
