From 5333d0b417452d282fec185f37bd60b2fe5cb97e Mon Sep 17 00:00:00 2001 From: Mauro Ezequiel Moltrasio Date: Thu, 14 Sep 2023 16:34:13 +0200 Subject: [PATCH] build(scap): add libdirs to pkgconfig Signed-off-by: Mauro Ezequiel Moltrasio --- cmake/modules/libscap.cmake | 13 ++++++++++++- userspace/libscap/libscap.pc.in | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cmake/modules/libscap.cmake b/cmake/modules/libscap.cmake index 1ea76acd28..b831a584fa 100644 --- a/cmake/modules/libscap.cmake +++ b/cmake/modules/libscap.cmake @@ -80,12 +80,22 @@ endforeach() # Installation targets and their dependencies set(libscap_link_libraries) +set(libscap_link_libdirs) foreach(libscap_install_lib ${LIBSCAP_INSTALL_LIBS}) list(APPEND libscap_link_libraries ${libscap_install_lib}) get_target_property(install_lib_link_libraries ${libscap_install_lib} LINK_LIBRARIES) foreach (install_lib_link_library ${install_lib_link_libraries}) if (NOT ${install_lib_link_library} IN_LIST libscap_subdir_targets) - list(APPEND libscap_link_libraries ${install_lib_link_library}) + if(${install_lib_link_library} MATCHES "/") + # We have a path. Convert it to -L + -l. + get_filename_component(scap_lib_dir ${install_lib_link_library} DIRECTORY) + list(APPEND libscap_link_libdirs -L${scap_lib_dir}) + get_filename_component(scap_lib_base ${install_lib_link_library} NAME_WE) + string(REGEX REPLACE "^lib" "" scap_lib_base ${scap_lib_base}) + list(APPEND libscap_link_libraries ${scap_lib_base}) + else() + list(APPEND libscap_link_libraries ${install_lib_link_library}) + endif() endif() endforeach() endforeach() @@ -97,6 +107,7 @@ foreach(libscap_link_library ${libscap_link_libraries}) endforeach() string(REPLACE ";" " " LIBSCAP_LINK_LIBRARIES_FLAGS "${libscap_link_flags}") +string(REPLACE ";" " " LIBSCAP_LINK_LIBDIRS_FLAGS "${libscap_link_libdirs}") configure_file(${LIBSCAP_DIR}/userspace/libscap/libscap.pc.in ${PROJECT_BINARY_DIR}/libscap/libscap.pc @ONLY) install(TARGETS ${LIBSCAP_INSTALL_LIBS} diff --git a/userspace/libscap/libscap.pc.in b/userspace/libscap/libscap.pc.in index f05740e1ef..cc5de61994 100644 --- a/userspace/libscap/libscap.pc.in +++ b/userspace/libscap/libscap.pc.in @@ -6,5 +6,5 @@ Name: libscap Description: lib for System CAPture Version: @FALCOSECURITY_LIBS_VERSION@ -Libs: -L${libdir}/@LIBS_PACKAGE_NAME@ @LIBSCAP_LINK_LIBRARIES_FLAGS@ +Libs: -L${libdir}/@LIBS_PACKAGE_NAME@ @LIBSCAP_LINK_LIBDIRS_FLAGS@ @LIBSCAP_LINK_LIBRARIES_FLAGS@ Cflags: -I${includedir}/@LIBS_PACKAGE_NAME@/userspace/libscap