How to specify library dir for imported interface?

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

How to specify library dir for imported interface?

Francis Giraldeau
Build fails at link time, because a static library imported using pkg-config is not in the standard path: 

[ 74%] Linking CXX executable valhalla_add_predicted_traffic
/usr/bin/c++   ... -lprime_server ...

Usually, cmake uses the absolute path to the static library, but instead, pkg-config provides the library name and the library dir separately. Here is the imported target:

add_library(libprime_server INTERFACE IMPORTED)
pkg_check_modules(libprime_server REQUIRED libprime_server>=0.6.3)
set_target_properties(libprime_server PROPERTIES
    INTERFACE_LINK_LIBRARIES "${libprime_server_LIBRARIES}"
    INTERFACE_INCLUDE_DIRECTORIES "${libprime_server_INCLUDE_DIRS}")

The library dir is defined in the CMakeCache.txt (both in the LDFLAGS in LIBRARY_DIRS): 

libprime_server_LDFLAGS:INTERNAL=-L/home/francis/local/lib;-lprime_server
libprime_server_LIBRARY_DIRS:INTERNAL=/home/francis/local/lib

However, it seems no property exists to actually specify the library dir of imported target, nor the linker flags to pass when using the imported target.

What would be the best way to specify the library dir for an imported library?

Thanks!

Francis Giraldeau
--
Francis Giraldeau

--

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:
https://cmake.org/mailman/listinfo/cmake