diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:08 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:08 +0000 |
commit | 29b5ab554790bb57337a3b6ab9dcd963cf69d22e (patch) | |
tree | be1456d2bc6c1fb078695fad7bc8f6b212062d3c /cmake/FindPkgLibraries.cmake | |
parent | Initial commit. (diff) | |
download | libgit2-29b5ab554790bb57337a3b6ab9dcd963cf69d22e.tar.xz libgit2-29b5ab554790bb57337a3b6ab9dcd963cf69d22e.zip |
Adding upstream version 1.7.2+ds.upstream/1.7.2+ds
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/FindPkgLibraries.cmake')
-rw-r--r-- | cmake/FindPkgLibraries.cmake | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cmake/FindPkgLibraries.cmake b/cmake/FindPkgLibraries.cmake new file mode 100644 index 0000000..220bb2c --- /dev/null +++ b/cmake/FindPkgLibraries.cmake @@ -0,0 +1,28 @@ +include(FindPkgConfig) + +# This function will find and set up a pkg-config based module. +# If a pc-file was found, it will resolve library paths to +# absolute paths. Furthermore, the function will automatically +# fall back to use static libraries in case no dynamic libraries +# were found. +function(FIND_PKGLIBRARIES prefix package) + pkg_check_modules(${prefix} ${package}) + if(NOT ${prefix}_FOUND) + return() + endif() + + foreach(LIBRARY ${${prefix}_LIBRARIES}) + find_library(${LIBRARY}_RESOLVED ${LIBRARY} PATHS ${${prefix}_LIBRARY_DIRS}) + if(${${LIBRARY}_RESOLVED} STREQUAL "${LIBRARY}_RESOLVED-NOTFOUND") + message(FATAL_ERROR "could not resolve ${LIBRARY}") + endif() + list(APPEND RESOLVED_LIBRARIES ${${LIBRARY}_RESOLVED}) + endforeach() + + set(${prefix}_FOUND 1 PARENT_SCOPE) + set(${prefix}_LIBRARIES ${RESOLVED_LIBRARIES} PARENT_SCOPE) + set(${prefix}_INCLUDE_DIRS ${${prefix}_INCLUDE_DIRS} PARENT_SCOPE) + set(${prefix}_LDFLAGS ${${prefix}_LDFLAGS} PARENT_SCOPE) + + message(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}") +endfunction() |