Prevent populated imported static library dependencies

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

target_link_libraries(myapp PRIVATE ${DCMTK_LIBRARIES})

leads to a link command containing

-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

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).

1 Like

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:

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.