3 # This function will find and set up a pkg-config based module.
4 # If a pc-file was found, it will resolve library paths to
5 # absolute paths. Furthermore, the function will automatically
6 # fall back to use static libraries in case no dynamic libraries
8 FUNCTION(FIND_PKGLIBRARIES prefix package)
9 PKG_CHECK_MODULES(${prefix} ${package})
10 IF(NOT ${prefix}_FOUND)
14 FOREACH(LIBRARY ${${prefix}_LIBRARIES})
15 FIND_LIBRARY(${LIBRARY}_RESOLVED ${LIBRARY} PATHS ${${prefix}_LIBRARY_DIRS})
16 IF(${${LIBRARY}_RESOLVED} STREQUAL "${LIBRARY}_RESOLVED-NOTFOUND")
17 MESSAGE(FATAL_ERROR "could not resolve ${LIBRARY}")
19 LIST(APPEND RESOLVED_LIBRARIES ${${LIBRARY}_RESOLVED})
22 SET(${prefix}_FOUND 1 PARENT_SCOPE)
23 SET(${prefix}_LIBRARIES ${RESOLVED_LIBRARIES} PARENT_SCOPE)
24 SET(${prefix}_INCLUDE_DIRS ${${prefix}_INCLUDE_DIRS} PARENT_SCOPE)
25 SET(${prefix}_LDFLAGS ${${prefix}_LDFLAGS} PARENT_SCOPE)
27 MESSAGE(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}")