Using CMAKE_DL_LIBS on an imported target

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Using CMAKE_DL_LIBS on an imported target

Björn Pollex
Hi everyone,

I’m reposting here the same question I’ve already posted on Stackoverflow [1], in the hopes of reaching a more appropriate audience.

I have an imported target (an external library) that required -ldl, so I'm adding ${CMAKE_DL_LIBS} to the INTERFACE_LINK_LIBRARIES property like this:

    set_property(TARGET some_lib PROPERTY

Now, when I use that target elsewhere, like this:

    target_link_libraries(my_target some_lib)

I get a linker error that `dladdr` is undefined. However, when I explicitly add CMAKE_DL_LIBS to that target, it works:

    target_link_libraries(my_target some_lib ${CMAKE_DL_LIBS})

So it seems that this is not propagate correctly. Is there a way to make this work without explicitly specifying CMAKE_DL_LIBS in the using target?

Kind regards,

        Björn Pollex


Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: