Skip to content

Commit

Permalink
build(scap): add libdirs to pkgconfig
Browse files Browse the repository at this point in the history
Signed-off-by: Mauro Ezequiel Moltrasio <[email protected]>
  • Loading branch information
Molter73 authored and poiana committed Sep 29, 2023
1 parent 903749c commit 5333d0b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion cmake/modules/libscap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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<dir> + -l<lib>.
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()
Expand All @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion userspace/libscap/libscap.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5333d0b

Please sign in to comment.