Skip to content

Commit

Permalink
build: Add support for linking to shared falcosecurity libraries.
Browse files Browse the repository at this point in the history
* cmake/modules/falcosecurity-libs.cmake (USE_BUNDLED_FALCOSECURITY_LIBS):
New option.  Look for libsinsp via pkg-config unless it's enabled.
* userspace/sysdig/CMakeLists.txt: Adjust link directives accordingly.
Remove extraneous zlib include.

Signed-off-by: Maxim Cournoyer <[email protected]>
  • Loading branch information
Apteryks committed May 19, 2024
1 parent c1ee30f commit 35ea4d3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
13 changes: 13 additions & 0 deletions cmake/modules/falcosecurity-libs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
# limitations under the License.
#

option(USE_BUNDLED_FALCOSECURITY_LIBS "Enable building of the bundled falcosecurity libraries" ${USE_BUNDLED_DEPS})

if(NOT USE_BUNDLED_FALCOSECURITY_LIBS)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBSINSP REQUIRED IMPORTED_TARGET libsinsp)
message(STATUS "Found libsinsp:
include: ${LIBSINSP_INCLUDE_DIRS}
lib: ${LIBSINSP_LIBRARIES}
cflags: ${LIBSINSP_CFLAGS}")
return()
endif()

# else(): using bundled falcosecurity libs
set(FALCOSECURITY_LIBS_CMAKE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/falcosecurity-libs-repo")
set(FALCOSECURITY_LIBS_CMAKE_WORKING_DIR "${CMAKE_BINARY_DIR}/falcosecurity-libs-repo")

Expand Down
15 changes: 10 additions & 5 deletions userspace/sysdig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ if(NOT WIN32)
include(ncurses)
endif() # NOT WIN32

include(zlib)
include(luajit)

include_directories("${PROJECT_BINARY_DIR}/userspace/sinspui")
Expand Down Expand Up @@ -84,6 +83,12 @@ if(USE_BUNDLED_DEPS)
add_dependencies(csysdig luajit)
endif()

if(USE_BUNDLED_FALCOSECURITY_LIBS)
set(SINSP_LIB sinsp)
else()
set(SINSP_LIB PkgConfig::LIBSINSP)
endif()

target_include_directories(
sysdig
PUBLIC
Expand All @@ -108,7 +113,7 @@ if(NOT WIN32)
include_directories(${PROJECT_BINARY_DIR}/driver/src)

target_link_libraries(sysdig
sinsp
"${SINSP_LIB}"
"${LUAJIT_LIB}"
"${YAMLCPP_LIB}")

Expand All @@ -117,7 +122,7 @@ if(NOT WIN32)
endif()

target_link_libraries(csysdig
sinsp
"${SINSP_LIB}"
"${LUAJIT_LIB}"
"${CURSES_LIBRARIES}"
"${YAMLCPP_LIB}")
Expand All @@ -140,12 +145,12 @@ else()
add_definitions(-DNOCURSESUI)

target_link_libraries(sysdig
sinsp
"${SINSP_LIB}"
"${LUAJIT_LIB}"
"${YAMLCPP_LIB}")

target_link_libraries(csysdig
sinsp
"${SINSP_LIB}"
"${LUAJIT_LIB}"
"${YAMLCPP_LIB}")

Expand Down

0 comments on commit 35ea4d3

Please sign in to comment.