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
|  
Report Content as Inappropriate

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
        INTERFACE_LINK_LIBRARIES Threads::Threads ${CMAKE_DL_LIBS})

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


[1]: https://stackoverflow.com/questions/44410924/using-cmake-dl-libs-on-an-imported-target
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

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

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Loading...