diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:53 +0000 |
commit | a86c5f7cae7ec9a3398300555a0b644689d946a1 (patch) | |
tree | 39fe4b107c71174fd1e8a8ceb9a4d2aa14116248 /cmake/modules/FindSinsp.cmake | |
parent | Releasing progress-linux version 4.2.6-1~progress7.99u1. (diff) | |
download | wireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.tar.xz wireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.zip |
Merging upstream version 4.4.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/modules/FindSinsp.cmake')
-rw-r--r-- | cmake/modules/FindSinsp.cmake | 146 |
1 files changed, 107 insertions, 39 deletions
diff --git a/cmake/modules/FindSinsp.cmake b/cmake/modules/FindSinsp.cmake index 9729b028..58126224 100644 --- a/cmake/modules/FindSinsp.cmake +++ b/cmake/modules/FindSinsp.cmake @@ -22,7 +22,7 @@ # SINSP_DLL - (Windows) Name of the libsinsp and libscap DLLs include( FindWSWinLibs ) -FindWSWinLibs( "libsinsp-.*" "SINSP_HINTS" ) +FindWSWinLibs( "falcosecurity-libs-.*" SINSP_HINTS ) include(CMakeDependentOption) @@ -31,29 +31,33 @@ if( NOT USE_REPOSITORY) pkg_check_modules(SINSP libsinsp) endif() +# Include both legacy (#include <sinsp.h>) and current (#include <libsinsp/sinsp.h>) paths for now. if(NOT SINSP_FOUND) # pkg_check_modules didn't work, so look for ourselves. - find_path(SINSP_INCLUDE_DIRS - NAMES sinsp.h + find_path(_sinsp_include_dirs NO_CACHE + NAMES libsinsp/sinsp.h HINTS "${SINSP_INCLUDEDIR}" "${SINSP_HINTS}/include" - PATH_SUFFIXES falcosecurity/userspace/libsinsp + PATH_SUFFIXES falcosecurity /usr/include /usr/local/include ) + if(_sinsp_include_dirs) + list(APPEND _sinsp_include_dirs ${_sinsp_include_dirs}/libsinsp) + endif() - find_path(_scap_include_dir + find_path(_scap_include_dir NO_CACHE NAMES scap.h HINTS "${SINSP_INCLUDEDIR}" "${SINSP_HINTS}/include" - PATH_SUFFIXES falcosecurity/userspace/libscap + PATH_SUFFIXES falcosecurity/libscap /usr/include /usr/local/include ) if(_scap_include_dir) - list(APPEND SINSP_INCLUDE_DIRS _scap_include_dir) + list(APPEND _sinsp_include_dirs ${_scap_include_dir}) endif() unset(_scap_include_dir) - find_library(SINSP_LINK_LIBRARIES + find_library(_sinsp_link_libs NO_CACHE NAMES sinsp HINTS "${SINSP_LIBDIR}" "${SINSP_HINTS}/lib" PATHS falcosecurity @@ -63,21 +67,18 @@ if(NOT SINSP_FOUND) set(_scap_libs scap - scap_engine_util - scap_event_schema - driver_event_schema - scap_engine_bpf - scap_engine_gvisor - scap_engine_kmod scap_engine_nodriver scap_engine_noop scap_engine_savefile scap_engine_source_plugin - scap_engine_udig + scap_engine_test_input + scap_error + scap_event_schema + scap_platform_util ) foreach(_scap_lib ${_scap_libs}) - find_library(_lib + find_library(_lib NO_CACHE NAMES ${_scap_lib} HINTS "${SINSP_LIBDIR}" "${SINSP_HINTS}/lib" PATHS falcosecurity @@ -85,58 +86,108 @@ if(NOT SINSP_FOUND) /usr/local/lib ) if (_lib) - list(APPEND SINSP_LINK_LIBRARIES ${_lib}) + list(APPEND _sinsp_link_libs ${_lib}) + unset(_lib) endif() endforeach() unset(_scap_libs) unset(_scap_lib) - unset(_lib) - if(SINSP_INCLUDE_DIRS AND JSONCPP_LIBRARY) - set(SINSP_FOUND 1) - endif() - find_path(JSONCPP_INCLUDE_DIR + find_path(_jsoncpp_include_dir NO_CACHE NAMES json/json.h HINTS "${SINSP_INCLUDEDIR}" "${SINSP_HINTS}/include" - PATH_SUFFIXES jsoncpp + PATH_SUFFIXES falcosecurity jsoncpp + PATHS /usr/include /usr/local/include ) - if (JSON_INCLUDE_DIR) - list(APPEND SINSP_INCLUDE_DIRS ${JSONCPP_INCLUDE_DIR}) + if (_jsoncpp_include_dir) + list(APPEND _sinsp_include_dirs ${_jsoncpp_include_dir}) + unset(_jsoncpp_include_dir) endif() - find_library(JSONCPP_LIBRARY + find_library(_jsoncpp_lib NO_CACHE NAMES jsoncpp - HINTS "${SINSP_LIBDIR}" "${SINSP_HINTS}/lib" + HINTS "${SINSP_LIBDIR}" "${SINSP_HINTS}/lib" "${SINSP_HINTS}/lib/falcosecurity" + PATHS + /usr/lib + /usr/local/lib + ) + if (_jsoncpp_lib) + list(APPEND _sinsp_link_libs ${_jsoncpp_lib}) + unset(_jsoncpp_lib) + endif() + + find_library(_re2_lib NO_CACHE + NAMES re2 + HINTS "${SINSP_LIBDIR}" "${SINSP_HINTS}/lib" "${SINSP_HINTS}/lib/falcosecurity" PATHS /usr/lib /usr/local/lib ) - if (JSONCPP_LIBRARY) - list(APPEND JSONCPP_LIBRARY ${JSONCPP_LIBRARY}) + if (_re2_lib) + list(APPEND _sinsp_link_libs ${_re2_lib}) + unset(_re2_lib) endif() - find_path(TBB_INCLUDE_DIR + find_path(_tbb_include_dir NO_CACHE NAMES tbb/tbb.h HINTS "${SINSP_INCLUDEDIR}" "${SINSP_HINTS}/include" + PATHS /usr/include /usr/local/include ) - if (TBB_INCLUDE_DIR) - list(APPEND SINSP_INCLUDE_DIRS ${TBB_INCLUDE_DIR}) + if (_tbb_include_dir) + list(APPEND _sinsp_include_dirs ${_tbb_include_dir}) + unset(_tbb_include_dir) endif() - find_library(TBB_LIBRARY - NAMES tbb - HINTS "${SINSP_LIBDIR}" "${SINSP_HINTS}/lib" + find_library(_tbb_lib NO_CACHE + NAMES tbb tbb12 + HINTS "${SINSP_LIBDIR}" "${SINSP_HINTS}/lib" "${SINSP_HINTS}/lib/falcosecurity" + PATHS + /usr/lib + /usr/local/lib + ) + if (_tbb_lib) + list(APPEND _sinsp_link_libs ${_tbb_lib}) + unset(_tbb_lib) + endif() + + # This is terrible, but libsinsp/libscap doesn't support dynamic linking on Windows (yet). + find_path(_zlib_include_dir NO_CACHE + NAMES zlib/zlib.h + HINTS "${SINSP_INCLUDEDIR}" "${SINSP_HINTS}/include" + PATHS + /usr/include + /usr/local/include + ) + if (_zlib_include_dir) + list(APPEND _sinsp_include_dirs ${_zlib_include_dir}) + unset(_zlib_include_dir) + endif() + + find_library(_zlib_lib NO_CACHE + NAMES zlibstatic + HINTS "${SINSP_LIBDIR}" "${SINSP_HINTS}/lib" "${SINSP_HINTS}/lib/falcosecurity" PATHS /usr/lib /usr/local/lib ) - if (TBB_LIBRARY) - list(APPEND JSONCPP_LIBRARY ${TBB_LIBRARY}) + if (_zlib_lib) + list(APPEND _sinsp_link_libs ${_zlib_lib}) + unset(_zlib_lib) + endif() + + if(_sinsp_include_dirs AND _sinsp_link_libs) + list(REMOVE_DUPLICATES _sinsp_include_dirs) + set(SINSP_INCLUDE_DIRS ${_sinsp_include_dirs} CACHE PATH "Paths to libsinsp and libscap headers") + set(SINSP_LINK_LIBRARIES ${_sinsp_link_libs} CACHE PATH "Paths to libsinsp, libscap, etc.") + set(SINSP_FOUND 1) + unset(_sinsp_include_dirs) + unset(_sinsp_link_libs) endif() + endif() # As https://cmake.org/cmake/help/latest/command/link_directories.html @@ -171,6 +222,23 @@ else() set(SINSP_LINK_LIBRARIES) endif() -cmake_dependent_option(FALCO_PLUGINS "Paths to Falco plugins. Semicolon-separated" "" SINSP_FOUND "") - mark_as_advanced(SINSP_INCLUDE_DIRS SINSP_LINK_LIBRARIES) + +# Windows plugins + +set(_falco_plugins) +if(WIN32 AND SINSP_FOUND AND NOT FALCO_PLUGINS) + FindWSWinLibs( "falcosecurity-plugins-.*" _falco_plugin_dir) + if(_falco_plugin_dir) + file( GLOB _falco_plugins LIST_DIRECTORIES false "${_falco_plugin_dir}/*.dll" ) + unset(_falco_plugin_dir) + endif() +endif() + +# XXX It looks like we can either autodiscover this value or provide an option but not both. +if(_falco_plugins) + set(FALCO_PLUGINS ${_falco_plugins} CACHE FILEPATH "Paths to Falco plugins. Semicolon-separated") + unset(_falco_plugins) +else() + cmake_dependent_option(FALCO_PLUGINS "Paths to Falco plugins. Semicolon-separated" "" "SINSP_FOUND" "") +endif() |