diff --git a/CMakeLists.txt b/CMakeLists.txt index 915a0a55c5..e0e72c27bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,10 @@ endif() project(Zeek C CXX) -option(ZEEK_STANDALONE "Is Zeek compiled stand-alone or embedded in a parent project." ON) -option(ENABLE_ZEEK_UNIT_TESTS "Should the doctest unit tests be built?" ON) +option(ZEEK_STANDALONE "Build Zeek as stand-alone binary?" ON) +option(ENABLE_ZEEK_UNIT_TESTS "Build the C++ (doctest) unit tests?" ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON + CACHE INTERNAL "Write JSON compile commands database") list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}) @@ -114,6 +116,255 @@ include(cmake/CommonCMakeConfig.cmake) include(cmake/FindClangTidy.cmake) include(cmake/CheckCompilerArch.cmake) +######################################################################## +## Main targets and utilities. + +# Variable for referring back to Zeek's top-level source dir. Used for plugins +# to tell them where to find the Zeek headers. +set(ZEEK_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + +# Tell dynamic plugins where to find scripts such as +# zeek-plugin-create-package.sh. Needed by ZeekPluginConfig.cmake.in. +set(ZEEK_PLUGIN_SCRIPTS_PATH "${PROJECT_SOURCE_DIR}/cmake") + +# Our C++17 base target for propagating compiler and linker flags. +# Note: for now, we only use it for passing library dependencies around. +add_library(zeek_internal INTERFACE) +add_library(Zeek::Internal ALIAS zeek_internal) +set_target_properties(zeek_internal PROPERTIES EXPORT_NAME Internal) +install(TARGETS zeek_internal EXPORT ZeekTargets) +target_compile_features(zeek_internal INTERFACE cxx_std_17) + +# Target for bundling the creation of auto-generated files. +add_custom_target(zeek_autogen_files) + +# Define our main targets and place the output files under src (for historic +# reasons and backwards compatibility). +if (ZEEK_STANDALONE) + add_executable(zeek_exe) + target_link_libraries(zeek_exe PRIVATE $) + add_dependencies(zeek_exe zeek_autogen_files) + set_target_properties(zeek_exe PROPERTIES RUNTIME_OUTPUT_NAME zeek) + if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set_target_properties(zeek_exe PROPERTIES RUNTIME_OUTPUT_DIRECTORY src) + endif() + install(TARGETS zeek_exe RUNTIME DESTINATION bin) + # Export symbols from zeek executable for use by plugins + set_target_properties(zeek_exe PROPERTIES ENABLE_EXPORTS ON) + if ( MSVC ) + set(WINDOWS_EXPORT_ALL_SYMBOLS ON) + endif () + # Tell zeek_target_link_libraries to add library dependencies as PRIVATE. + set(zeek_exe_access PRIVATE) + # Also build the static library when asked for via Conan. + if (CONAN_EXPORTED) + add_library(zeek_lib STATIC) + endif () +else () + add_library(zeek_lib STATIC) +endif() + +if (TARGET zeek_lib) + target_link_libraries(zeek_lib PRIVATE $) + add_dependencies(zeek_lib zeek_autogen_files) + set_target_properties(zeek_lib PROPERTIES RUNTIME_OUTPUT_NAME libzeek) + if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) + set_target_properties(zeek_lie PROPERTIES LIBRARY_OUTPUT_DIRECTORY src) + endif() + install(TARGETS zeek_lib LIBRARY DESTINATION lib) + # Tell zeek_target_link_libraries to add library dependencies as PRIVATE. + set(zeek_lib_access PRIVATE) +endif() + +# When building our fuzzers, we also need one extra top-level target that +# bundles all of our object libraries and other dependencies. +if ( ZEEK_ENABLE_FUZZERS ) + add_library(zeek_fuzzer_shared SHARED) + target_link_libraries(zeek_fuzzer_shared PUBLIC $) + # Tell zeek_target_link_libraries to add library dependencies as PUBLIC. + set(zeek_fuzzer_shared_access PUBLIC) +endif () + +# Convenience function for adding library dependencies to the main target(s). +function(zeek_target_link_libraries lib_target) + foreach (name zeek_exe zeek_lib zeek_fuzzer_shared) + if (TARGET ${name}) + target_link_libraries(${name} ${${name}_access} ${lib_target}) + endif () + endforeach() +endfunction() + +function(zeek_include_directories) + foreach (name zeek_exe zeek_lib zeek_fuzzer_shared) + if (TARGET ${name}) + target_include_directories(${name} ${${name}_access} ${ARGN}) + endif () + endforeach () +endfunction () + +# Convenience function for adding a dependency to the main target(s). +function(zeek_add_dependencies dep) + foreach (name zeek_exe zeek_lib zeek_fuzzer_shared) + if (TARGET ${name}) + add_dependencies(${name} ${dep}) + endif () + endforeach() +endfunction() + +# Interface library for propagating extra flags and include paths to dynamically +# loaded plugins. +add_library(zeek_dynamic_plugin_base INTERFACE) +target_link_libraries(zeek_dynamic_plugin_base + INTERFACE + $) +target_include_directories(zeek_dynamic_plugin_base + INTERFACE + $ + $) +add_library(Zeek::DynamicPluginBase ALIAS zeek_dynamic_plugin_base) +set_target_properties( + zeek_dynamic_plugin_base PROPERTIES + EXPORT_NAME DynamicPluginBase) +install(TARGETS zeek_dynamic_plugin_base EXPORT ZeekTargets) + +# Tell dynamic plugins where to find scripts such as +# zeek-plugin-create-package.sh. +set(ZEEK_PLUGIN_SCRIPTS_PATH "${PROJECT_SOURCE_DIR}/cmake") + +# On macOS, we need to tell the linker that the modules are allowed to have +# undefined symbols. +if (CMAKE_SYSTEM_NAME MATCHES "Darwin") + target_link_options( + zeek_dynamic_plugin_base + INTERFACE + -undefined + dynamic_lookup + -Wl,-bind_at_load) +endif () + +function(add_zeek_dynamic_plugin_build_interface_include_directories) + foreach ( path ${ARGV} ) + target_include_directories( + zeek_dynamic_plugin_base + INTERFACE + $ + ) + endforeach () +endfunction() + +add_zeek_dynamic_plugin_build_interface_include_directories( + ${PROJECT_SOURCE_DIR}/src/include + ${PROJECT_SOURCE_DIR}/auxil/binpac/lib + ${PROJECT_SOURCE_DIR}/auxil/broker/include + ${PROJECT_SOURCE_DIR}/auxil/paraglob/include + ${PROJECT_SOURCE_DIR}/auxil/rapidjson/include + ${CMAKE_BINARY_DIR}/src + ${CMAKE_BINARY_DIR}/src/include + ${CMAKE_BINARY_DIR}/auxil/binpac/lib + ${CMAKE_BINARY_DIR}/auxil/broker/include +) + +# Convenience function for adding an OBJECT library that feeds directly into the +# main target(s). +# +# Usage: +# zeek_add_subdir_library( +# +# SOURCES ... +# [INCLUDE_DIRS ...] +# [DEPENDENCIES ...] +# [INTERNAL_DEPENDENCIES ...] +# [BIFS ...] +# ) +function(zeek_add_subdir_library name) + # Parse arguments. + set(fn_varargs INCLUDE_DIRS DEPENDENCIES INTERNAL_DEPENDENCIES SOURCES BIFS) + cmake_parse_arguments(FN_ARGS "" "" "${fn_varargs}" ${ARGN}) + if (NOT FN_ARGS_SOURCES) + message(FATAL_ERROR "zeek_add_subdir_library called without any SOURCES") + endif() + + # Create target and add the sources. + set(target_name "zeek_${name}_obj") + add_library(${target_name} OBJECT ${FN_ARGS_SOURCES}) + add_dependencies(${target_name} zeek_autogen_files) + target_link_libraries(${target_name} PRIVATE $) + add_clang_tidy_files(${FN_ARGS_SOURCES}) + + # Take care of compiling BIFs. + if (FN_ARGS_BIFS) + foreach ( bif ${FN_ARGS_BIFS} ) + # Generate the target and add the extra dependency. + bif_target(${bif}) + endforeach () + endif() + + # Optionally add include directories and extra dependencies. + if ( FN_ARGS_INCLUDE_DIRS ) + target_include_directories( + ${target_name} + BEFORE + PRIVATE + ${FN_ARGS_INCLUDE_DIRS}) + endif () + if ( FN_ARGS_DEPENDENCIES ) + target_link_libraries(${target_name} PRIVATE ${FN_ARGS_DEPENDENCIES}) + endif () + if ( FN_ARGS_INTERNAL_DEPENDENCIES ) + add_dependencies(${target_name} ${FN_ARGS_INTERNAL_DEPENDENCIES}) + endif () + + # Feed into the main Zeek target(s). + zeek_target_link_libraries(${target_name}) +endfunction() + +######################################################################## +## Utility function for forcing CMake to re-run if files change on disk. + +function(zeek_watch_files) + set_property( + DIRECTORY + APPEND + PROPERTY CMAKE_CONFIGURE_DEPENDS ${ARGN} + ) +endfunction() + +######################################################################## +## Create empty __load__.zeek stubs (override pre-existing ones). + +function(zeek_create_load_script_stubs) + set(file_comment "# Warning, this is an autogenerated file!\n") + foreach ( fpath ${ARGN} ) + file(WRITE "${CMAKE_BINARY_DIR}/${fpath}" "${file_comment}") + zeek_watch_files("${CMAKE_BINARY_DIR}/${fpath}") + endforeach () +endfunction () + +# Note: these files are filled from BifCl.cmake via `file(APPEND ...)` +zeek_create_load_script_stubs( + scripts/builtin-plugins/__load__.zeek + scripts/base/bif/plugins/__load__.zeek + scripts/base/bif/__load__.zeek +) + +######################################################################## +## Create empty __all__*.cc stubs (override pre-existing ones). + +function(zeek_create_bif_autogen_stubs) + set(file_comment "// Warning, this is an autogenerated file!\n") + foreach ( fpath ${ARGN} ) + file(WRITE "${CMAKE_BINARY_DIR}/${fpath}" "${file_comment}") + zeek_watch_files("${CMAKE_BINARY_DIR}/${fpath}") + endforeach () +endfunction () + +# Note: these files are filled from BifCl.cmake via `file(APPEND ...)`. +zeek_create_bif_autogen_stubs( + src/__all__.bif.cc + src/__all__.bif.init.cc + src/__all__.bif.register.cc +) + ######################################################################## ## Project/Build Configuration @@ -247,8 +498,9 @@ set(VERSION_C_IDENT "${VERSION}_plugin_${API_VERSION}") string(REGEX REPLACE "-[0-9]*$" "_git" VERSION_C_IDENT "${VERSION_C_IDENT}") string(REGEX REPLACE "[^a-zA-Z0-9_\$]" "_" VERSION_C_IDENT "${VERSION_C_IDENT}") -if(${ENABLE_DEBUG}) +if(ENABLE_DEBUG) set(VERSION_C_IDENT "${VERSION_C_IDENT}_debug") + target_compile_definitions(zeek_internal INTERFACE DEBUG) endif() if ( NOT BINARY_PACKAGING_MODE ) @@ -425,6 +677,22 @@ if ( NOT MSVC ) endif () FindRequiredPackage(ZLIB) +# Forward user-defined hint for OpenSSL to the plugins. Use a cache variable to +# make sure this variable survives CMake re-runs. +# Note: This variable is picked up in ZeekPluginConfig.cmake.in. +if (OPENSSL_ROOT_DIR) + set(ZeekOpenSSLHint "${OPENSSL_ROOT_DIR}" CACHE INTERNAL "" FORCE) +elseif (DEFINED ENV{OPENSSL_ROOT_DIR}) + set(ZeekOpenSSLHint "$ENV{OPENSSL_ROOT_DIR}" CACHE INTERNAL "" FORCE) +endif () + +# Forward PKG_CONFIG_PATH to the plugins. Use a cache variable to make sure this +# variable survives CMake re-runs. +# Note: This variable is picked up in ZeekPluginConfig.cmake.in. +if (DEFINED ENV{PKG_CONFIG_PATH}) + set(ZeekPkgConfigPath "$ENV{PKG_CONFIG_PATH}" CACHE INTERNAL "" FORCE) +endif () + # Installation directory for the distribution's Python modules. An # override via configure's --python-dir wins, specifying a directory # explicitly. Next is --python-prefix, which includes a versioned @@ -457,11 +725,28 @@ if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/auxil/binpac/CMakeLists.txt) add_subdirectory(auxil/binpac) set(ENABLE_STATIC_ONLY ${ENABLE_STATIC_ONLY_SAVED}) + + # FIXME: avoid hard-coding a path for multi-config generator support. + # See the TODO in ZeekPluginConfig.cmake.in. + set(BINPAC_EXE_PATH "${CMAKE_BINARY_DIR}/auxil/binpac/src/binpac${CMAKE_EXECUTABLE_SUFFIX}") endif () FindRequiredPackage(BinPAC) +# Add an alias (used by our plugin setup). +add_executable(Zeek::BinPAC ALIAS binpac) + if ( NOT BIFCL_EXE_PATH ) - add_subdirectory(auxil/bifcl) + add_subdirectory(auxil/bifcl) + add_executable(Zeek::BifCl ALIAS bifcl) + # FIXME: avoid hard-coding a path for multi-config generator support. + # See the TODO in ZeekPluginConfig.cmake.in. + set(BIFCL_EXE_PATH "${CMAKE_BINARY_DIR}/auxil/bifcl/bifcl${CMAKE_EXECUTABLE_SUFFIX}") + set(_bifcl_exe_path "included") +else ( ) + add_executable(Zeek::BifCl IMPORTED) + set_property(TARGET Zeek::BifCl PROPERTY + IMPORTED_LOCATION "${BIFCL_EXE_PATH}") + set(_bifcl_exe_path "BIFCL_EXE_PATH") endif () if ( NOT GEN_ZAM_EXE_PATH ) @@ -513,14 +798,13 @@ if ( MSVC ) endif () set(zeekdeps ${zeekdeps} paraglob) +# Note: Broker gets some special attention in ZeekConfig.cmake.in. if ( Broker_ROOT ) - find_package(Broker REQUIRED PATHS "${Broker_ROOT}") - set(zeekdeps ${zeekdeps} ${BROKER_LIBRARY}) - set(broker_includes ${BROKER_INCLUDE_DIR}) -elseif ( BROKER_ROOT_DIR ) - find_package(Broker REQUIRED PATHS "${BROKER_ROOT_DIR}") - set(zeekdeps ${zeekdeps} ${BROKER_LIBRARY}) + find_package(Broker REQUIRED CONFIG) + list(APPEND zeekdeps ${BROKER_LIBRARY}) set(broker_includes ${BROKER_INCLUDE_DIR}) + set(ZEEK_HAS_EXTERNAL_BROKER ON) + set(ZEEK_HAS_STATIC_BROKER OFF) else () if ( ZEEK_SANITIZERS ) set(BROKER_SANITIZERS ${ZEEK_SANITIZERS}) @@ -539,11 +823,26 @@ else () set(ENABLE_STATIC_ONLY ${ENABLE_STATIC_ONLY_SAVED}) if ( BUILD_STATIC_BROKER ) - set(zeekdeps ${zeekdeps} broker_static) + list(APPEND zeekdeps broker_static) else() - set(zeekdeps ${zeekdeps} broker) + list(APPEND zeekdeps broker) endif() - set(broker_includes ${CMAKE_CURRENT_SOURCE_DIR}/auxil/broker/include ${CMAKE_CURRENT_BINARY_DIR}/auxil/broker/include) + + set( + broker_includes + ${CMAKE_CURRENT_SOURCE_DIR}/auxil/broker/include + ${CMAKE_CURRENT_BINARY_DIR}/auxil/broker/include) + + if (BUILD_STATIC_BROKER) + set(ZEEK_HAS_STATIC_BROKER ON) + else () + set(ZEEK_HAS_STATIC_BROKER OFF) + endif () + set(ZEEK_HAS_EXTERNAL_BROKER OFF) + + # Tell plugins where to find the Broker CMake package in the source tree. + # This variable is picked up in ZeekPluginConfig.cmake.in. + set(ZEEK_PLUGIN_BROKER_PATH "${CMAKE_CURRENT_BINARY_DIR}/auxil/broker") endif () if ( NOT DISABLE_SPICY ) @@ -909,7 +1208,7 @@ CheckOptionalBuildSources(auxil/zeek-client ZeekClient INSTALL_ZEEK_CLIENT) if ( NOT DISABLE_SPICY ) # The `zeek` binary implicitly depends on the driver object file built # as part of `spicy`; make that dependency explicit. - add_dependencies(zeek spicyz) + zeek_add_dependencies(spicyz) if ( NOT SPICY_ROOT_DIR ) # Make sure we build targets of spicy-plugin after the `spicy` target. @@ -957,6 +1256,41 @@ if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") ConfigurePackaging(${VERSION}) endif () +# Refers back to the "distribution prefix". This is the source tree when +# referring to Zeek from the build directory and the "share" directory under the +# install preifx otherwise. +set(ZEEK_DIST_PREFIX + $ + $) + +# Generate extra config file for the dynamic plugins. +configure_file(src/ZeekPluginConfig.cmake.in ZeekPluginConfig.cmake @ONLY) + +# Write the CMake package and version files. +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/src/ZeekConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/ZeekConfig.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Zeek") +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/ZeekConfigVersion.cmake" + VERSION ${ZEEK_VERSION_NUMBER} + COMPATIBILITY ExactVersion) + +# Write the CMake targets file. +export(EXPORT ZeekTargets FILE ZeekTargets.cmake NAMESPACE Zeek::) + +# TODO: Check whether installing these does not break any of our packages. +# install( +# FILES +# "${CMAKE_CURRENT_BINARY_DIR}/ZeekConfig.cmake" +# "${CMAKE_CURRENT_BINARY_DIR}/ZeekConfigVersion.cmake" +# DESTINATION +# "${CMAKE_INSTALL_LIBDIR}/cmake/Zeek") +# install( +# EXPORT ZeekTargets +# DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Zeek" +# NAMESPACE Zeek::) + ######################################################################## ## Build Summary @@ -970,11 +1304,6 @@ else () set(_install_btest_tools_msg "no pcaps") endif () -set(_bifcl_exe_path "included") -if ( BIFCL_EXE_PATH ) - set(_bifcl_exe_path ${BIFCL_EXE_PATH}) -endif () - set(_binpac_exe_path "included") if ( BINPAC_EXE_PATH ) set(_binpac_exe_path ${BINPAC_EXE_PATH}) diff --git a/auxil/broker b/auxil/broker index a2dd0b3d21..4fc4c31592 160000 --- a/auxil/broker +++ b/auxil/broker @@ -1 +1 @@ -Subproject commit a2dd0b3d210401bc0873ed8e80a591d88cf3fba1 +Subproject commit 4fc4c31592c4823d675314bc981931de9e246057 diff --git a/auxil/spicy-plugin b/auxil/spicy-plugin index 6bf782aa51..a618f2ce08 160000 --- a/auxil/spicy-plugin +++ b/auxil/spicy-plugin @@ -1 +1 @@ -Subproject commit 6bf782aa51d31cc9e08a36073e107c5f869d91f7 +Subproject commit a618f2ce0831c311f9bcff5d020b85fc44345221 diff --git a/cmake b/cmake index 23d5b121a1..f258c75659 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 23d5b121a1492feb15455d6ecaf3940a237beb26 +Subproject commit f258c75659cec6e5dbd91ea18e21bc5dfad284a2 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3732a55ce0..64f0577e42 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,16 +20,6 @@ execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink ".." "${CMAKE_CURRENT_BINARY_DIR}/include/zeek") -# This collects generated bif and pac files from subdirectories. -set(bro_ALL_GENERATED_OUTPUTS CACHE INTERNAL "automatically generated files" FORCE) - -# This collects bif inputs that we'll load automatically. -set(bro_AUTO_BIFS CACHE INTERNAL "BIFs for automatic inclusion" FORCE) -set(bro_REGISTER_BIFS CACHE INTERNAL "BIFs for automatic registering" FORCE) - -set(bro_BASE_BIF_SCRIPTS CACHE INTERNAL "Zeek script stubs for BIFs in base distribution of Zeek" FORCE) -set(bro_PLUGIN_BIF_SCRIPTS CACHE INTERNAL "Zeek script stubs for BIFs in Zeek plugins" FORCE) - # Poor man's JSON escaping as this is rendered into a C string. string(REPLACE "\"" "\\\"" ZEEK_BUILD_INFO_ESCAPED "${ZEEK_BUILD_INFO}") string(REPLACE "\n" "\\n" ZEEK_BUILD_INFO_ESCAPED "${ZEEK_BUILD_INFO_ESCAPED}") @@ -66,16 +56,6 @@ else() set(SIGN_COMPARE_FLAG "-Wno-sign-compare") endif() -# BIF parser/scanner -bison_target(BIFParser builtin-func.y - ${CMAKE_CURRENT_BINARY_DIR}/bif_parse.cc - HEADER ${CMAKE_CURRENT_BINARY_DIR}/bif_parse.h - #VERBOSE ${CMAKE_CURRENT_BINARY_DIR}/bif_parse.output - COMPILE_FLAGS "${BISON_FLAGS}") -flex_target(BIFScanner builtin-func.l ${CMAKE_CURRENT_BINARY_DIR}/bif_lex.cc) -add_flex_bison_dependency(BIFScanner BIFParser) -set_property(SOURCE bif_lex.cc APPEND_STRING PROPERTY COMPILE_FLAGS "${SIGN_COMPARE_FLAG}") - # Rule parser/scanner bison_target(RuleParser rule-parse.y ${CMAKE_CURRENT_BINARY_DIR}/rup.cc @@ -119,6 +99,21 @@ flex_target(Scanner scan.l ${CMAKE_CURRENT_BINARY_DIR}/scan.cc COMPILE_FLAGS "-Pzeek") set_property(SOURCE scan.cc APPEND_STRING PROPERTY COMPILE_FLAGS "${SIGN_COMPARE_FLAG}") +# Add a dependency for the generated files to zeek_autogen_files. +add_custom_target( + zeek_bison_outputs + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/parse.cc + ${CMAKE_CURRENT_BINARY_DIR}/re-parse.cc + ${CMAKE_CURRENT_BINARY_DIR}/re-parse.h + ${CMAKE_CURRENT_BINARY_DIR}/re-scan.cc + ${CMAKE_CURRENT_BINARY_DIR}/rule-parse.cc + ${CMAKE_CURRENT_BINARY_DIR}/rule-parse.h + ${CMAKE_CURRENT_BINARY_DIR}/rule-scan.cc + ${CMAKE_CURRENT_BINARY_DIR}/scan.cc +) +add_dependencies(zeek_autogen_files zeek_bison_outputs) + ######################################################################## ## bifcl-dependent targets @@ -164,6 +159,8 @@ set(BINPAC_AUXSRC ${CMAKE_CURRENT_SOURCE_DIR}/binpac_zeek.h ) +set(BINPAC_OUTPUTS "") + binpac_target(binpac-lib.pac) list(APPEND BINPAC_OUTPUTS "${BINPAC_OUTPUT_CC}") @@ -185,12 +182,6 @@ gen_zam_target(${GEN_ZAM_SRC}) option(USE_SQLITE "Should Zeek use SQLite?" ON) -set(bro_SUBDIR_LIBS CACHE INTERNAL "subdir libraries" FORCE) -set(bro_SUBDIR_DEPS CACHE INTERNAL "subdir dependencies" FORCE) -set(bro_PLUGIN_LIBS CACHE INTERNAL "plugin libraries" FORCE) -set(bro_PLUGIN_DEPS CACHE INTERNAL "plugin dependencies" FORCE) -set(bro_PLUGIN_LINK_LIBS CACHE INTERNAL "plugin link libraries" FORCE) - add_subdirectory(analyzer) add_subdirectory(packet_analysis) add_subdirectory(broker) @@ -276,6 +267,14 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/DebugCmdConstants.h WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) +add_custom_target( + zeek_debugcmd_gen + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/DebugCmdConstants.h + ${CMAKE_CURRENT_BINARY_DIR}/DebugCmdInfoConstants.cc +) +add_dependencies(zeek_autogen_files zeek_debugcmd_gen) + set(_gen_zeek_script_cpp ${CMAKE_CURRENT_BINARY_DIR}/../CPP-gen.cc) add_custom_command(OUTPUT ${_gen_zeek_script_cpp} COMMAND ${CMAKE_COMMAND} -E touch ${_gen_zeek_script_cpp}) @@ -453,16 +452,18 @@ set(THIRD_PARTY_SRCS ) # Highwayhash. Highwayhash is a bit special since it has architecture dependent code... - -set(HH_SRCS - ../auxil/highwayhash/highwayhash/sip_hash.cc - ../auxil/highwayhash/highwayhash/sip_tree_hash.cc - ../auxil/highwayhash/highwayhash/scalar_sip_tree_hash.cc - ../auxil/highwayhash/highwayhash/arch_specific.cc - ../auxil/highwayhash/highwayhash/instruction_sets.cc - ../auxil/highwayhash/highwayhash/nanobenchmark.cc - ../auxil/highwayhash/highwayhash/os_specific.cc - ../auxil/highwayhash/highwayhash/hh_portable.cc +set(hhash_dir ${PROJECT_SOURCE_DIR}/auxil/highwayhash/highwayhash) +zeek_add_subdir_library( + hhash + SOURCES + ${hhash_dir}/sip_hash.cc + ${hhash_dir}/sip_tree_hash.cc + ${hhash_dir}/scalar_sip_tree_hash.cc + ${hhash_dir}/arch_specific.cc + ${hhash_dir}/instruction_sets.cc + ${hhash_dir}/nanobenchmark.cc + ${hhash_dir}/os_specific.cc + ${hhash_dir}/hh_portable.cc ) if (${COMPILER_ARCHITECTURE} STREQUAL "arm") @@ -475,22 +476,28 @@ if (${COMPILER_ARCHITECTURE} STREQUAL "arm") " test_arm_neon) if (test_arm_neon) - list(APPEND HH_SRCS ../auxil/highwayhash/highwayhash/hh_neon.cc) + target_sources(zeek_hhash_obj PRIVATE ${hhash_dir}/hh_neon.cc) endif () - set_source_files_properties(${HH_SRCS} PROPERTIES COMPILE_FLAGS - -mfloat-abi=hard -march=armv7-a -mfpu=neon) + target_compile_options( + zeek_hhash_obj + PRIVATE + -mfloat-abi=hard + -march=armv7-a + -mfpu=neon + ) elseif (${COMPILER_ARCHITECTURE} STREQUAL "aarch64") - list(APPEND HH_SRCS - ../auxil/highwayhash/highwayhash/hh_neon.cc - ) + target_sources(zeek_hhash_obj PRIVATE ${hhash_dir}/hh_neon.cc) elseif (${COMPILER_ARCHITECTURE} STREQUAL "power") - set_source_files_properties(../auxil/highwayhash/highwayhash/hh_vsx.cc PROPERTIES COMPILE_FLAGS + target_sources(zeek_hhash_obj PRIVATE ${hhash_dir}/hh_vsx.cc) + set_source_files_properties(${hhash_dir}/hh_vsx.cc PROPERTIES COMPILE_FLAGS -mvsx) - list(APPEND HH_SRCS - ../auxil/highwayhash/highwayhash/hh_vsx.cc - ) elseif(${COMPILER_ARCHITECTURE} STREQUAL "x86_64") + target_sources( + zeek_hhash_obj + PRIVATE + ${hhash_dir}/hh_avx2.cc + ${hhash_dir}/hh_sse41.cc) if (MSVC) set(_avx_flag /arch:AVX2) # Using an undocumentd compiler flag: https://stackoverflow.com/questions/64053597/how-do-i-enable-sse4-1-and-sse3-but-not-avx-in-msvc/69328426#69328426 @@ -500,15 +507,10 @@ elseif(${COMPILER_ARCHITECTURE} STREQUAL "x86_64") set(_sse_flag -msse4.1) endif() - set_source_files_properties(../auxil/highwayhash/highwayhash/hh_avx2.cc PROPERTIES COMPILE_FLAGS + set_source_files_properties(${hhash_dir}/hh_avx2.cc PROPERTIES COMPILE_FLAGS ${_avx_flag}) - set_source_files_properties(../auxil/highwayhash/highwayhash/hh_sse41.cc PROPERTIES COMPILE_FLAGS + set_source_files_properties(${hhash_dir}/hh_sse41.cc PROPERTIES COMPILE_FLAGS ${_sse_flag}) - - list(APPEND HH_SRCS - ../auxil/highwayhash/highwayhash/hh_avx2.cc - ../auxil/highwayhash/highwayhash/hh_sse41.cc - ) endif () set(zeek_SRCS @@ -538,86 +540,53 @@ set(zeek_SRCS collect_headers(zeek_HEADERS ${zeek_SRCS}) add_library(zeek_objs OBJECT ${zeek_SRCS}) +target_link_libraries(zeek_objs PRIVATE $) +add_dependencies(zeek_objs zeek_autogen_files) +add_clang_tidy_files(${zeek_SRCS}) +zeek_target_link_libraries(zeek_objs) -if (ZEEK_STANDALONE) - add_executable(zeek main.cc - $ - ${zeek_HEADERS} - ${bro_SUBDIR_LIBS} - ${bro_PLUGIN_LIBS} - ) +if (TARGET zeek_exe) + target_sources(zeek_exe PRIVATE main.cc ${zeek_HEADERS}) # npcap/winpcap need to be loaded in delayed mode so that we can set the load path # correctly at runtime. See https://npcap.com/guide/npcap-devguide.html#npcap-feature-native # for why this is necessary. if ( MSVC AND HAVE_WPCAP ) set(zeekdeps ${zeekdeps} delayimp.lib) - set_target_properties(zeek PROPERTIES LINK_FLAGS "/DELAYLOAD:wpcap.dll") + set_target_properties(zeek_exe PROPERTIES LINK_FLAGS "/DELAYLOAD:wpcap.dll") endif() - target_link_libraries(zeek ${bro_PLUGIN_LINK_LIBS} ${zeekdeps} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + target_link_libraries(zeek_exe PRIVATE ${zeekdeps} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) # Export symbols from zeek executable for use by plugins - set_target_properties(zeek PROPERTIES ENABLE_EXPORTS TRUE) + set_target_properties(zeek_exe PROPERTIES ENABLE_EXPORTS TRUE) if ( MSVC ) set(WINDOWS_EXPORT_ALL_SYMBOLS ON) endif () - install(TARGETS zeek RUNTIME DESTINATION bin) - - set(BRO_EXE zeek - CACHE STRING "Zeek executable binary" FORCE) - - set(BRO_EXE_PATH ${CMAKE_CURRENT_BINARY_DIR}/zeek - CACHE STRING "Path to Zeek executable binary" FORCE) endif() -if (NOT ZEEK_STANDALONE OR CONAN_EXPORTED) - add_library(libzeek STATIC $ - ${zeek_HEADERS} - ${bro_SUBDIR_LIBS} - ${bro_PLUGIN_LIBS}) +if (TARGET zeek_lib) + target_sources(zeek_lib PRIVATE ${zeek_HEADERS}) - target_link_libraries(libzeek PUBLIC ${zeekdeps} - ${CMAKE_THREAD_LIBS_INIT} - ${CMAKE_DL_LIBS} - ${bro_SUBDIR_LIBS} - ${bro_PLUGIN_LIBS}) - - target_include_directories(libzeek PUBLIC - ${CMAKE_SOURCE_DIR}/zeek/src - ${CMAKE_SOURCE_DIR}/zeek/src/include - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/zeek/src - ${CMAKE_BINARY_DIR}/zeek/src/include) - - install(TARGETS libzeek LIBRARY DESTINATION lib) + target_link_libraries( + zeek_lib + PUBLIC + ${zeekdeps} + ${CMAKE_THREAD_LIBS_INIT} + ${CMAKE_DL_LIBS}) endif() -# Target to create all the autogenerated files. -add_custom_target(generate_outputs_stage1) -add_dependencies(generate_outputs_stage1 ${bro_ALL_GENERATED_OUTPUTS}) - -# Target to create the joint includes files that pull in the bif code. -bro_bif_create_includes(generate_outputs_stage2a ${CMAKE_CURRENT_BINARY_DIR} "${bro_AUTO_BIFS}") -bro_bif_create_register(generate_outputs_stage2b ${CMAKE_CURRENT_BINARY_DIR} "${bro_REGISTER_BIFS}") -add_dependencies(generate_outputs_stage2a generate_outputs_stage1) -add_dependencies(generate_outputs_stage2b generate_outputs_stage1) - -# Global target to trigger creation of autogenerated code. -add_custom_target(generate_outputs) -add_dependencies(generate_outputs generate_outputs_stage2a generate_outputs_stage2b) - -# Build __load__.zeek files for standard *.bif.zeek. -bro_bif_create_loader(bif_loader "${bro_BASE_BIF_SCRIPTS}") -add_dependencies(bif_loader ${bro_PLUGIN_DEPS} ${bro_SUBDIR_DEPS}) -add_dependencies(zeek_objs bif_loader) - -# Build __load__.zeek files for plugins/*.bif.zeek. -bro_bif_create_loader(bif_loader_plugins "${bro_PLUGIN_BIF_SCRIPTS}") -add_dependencies(bif_loader_plugins ${bro_PLUGIN_DEPS} ${bro_SUBDIR_DEPS}) -add_dependencies(zeek_objs bif_loader_plugins) +zeek_include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/zeek/src + ${CMAKE_BINARY_DIR}/zeek/src/include + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/zeek/src + ${CMAKE_SOURCE_DIR}/zeek/src/include +) # Install *.bif.zeek. install(DIRECTORY ${PROJECT_BINARY_DIR}/scripts/base/bif DESTINATION ${ZEEK_SCRIPT_INSTALL_PATH}/base) diff --git a/src/ZeekConfig.cmake.in b/src/ZeekConfig.cmake.in new file mode 100644 index 0000000000..451ad54665 --- /dev/null +++ b/src/ZeekConfig.cmake.in @@ -0,0 +1,34 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +# Note: ZeekPluginConfig only exists on the build interface to pull in +# additional variables and dependencies for building dynamic plugins. +if ( EXISTS "${CMAKE_CURRENT_LIST_DIR}/ZeekPluginConfig.cmake" ) + include("${CMAKE_CURRENT_LIST_DIR}/ZeekPluginConfig.cmake") +endif () + +set(CMAKE_THREAD_PREFER_PTHREAD ON) +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_dependency(Threads REQUIRED) + +find_dependency(OpenSSL REQUIRED) + +# In our MSVC build, we have these extra dependencies from Conan. +if ( MSVC ) + find_dependency(libpcap) + find_dependency(ZLIB) + find_dependency(c-ares) +endif () + +if ( NOT "@ZEEK_HAS_STATIC_BROKER@" ) + # Always force using the package config file since users might still have + # a legacy FindBroker.cmake in their system. + find_dependency(Broker REQUIRED CONFIG) +endif () + +foreach ( dep @ZEEK_INSTALL_DEPENDENCIES@ ) + find_dependency(${dep} REQUIRED) +endforeach ( ) + +include("${CMAKE_CURRENT_LIST_DIR}/ZeekTargets.cmake") diff --git a/src/ZeekPluginConfig.cmake.in b/src/ZeekPluginConfig.cmake.in new file mode 100644 index 0000000000..2a8c2511e5 --- /dev/null +++ b/src/ZeekPluginConfig.cmake.in @@ -0,0 +1,57 @@ +# Note: this config is used for builtin dynamic plugins outside of the source +# tree of Zeek. Plugins refer back to the Zeek source tree since they need +# access to some parts of Zeek that we don't install. + +# Pull in some path magic that Zeek uses as well. +include(MacDependencyPaths) + +# For finding zeek-plugin-create-package.sh and zeek-plugin-install-package.sh. +set(ZEEK_PLUGIN_SCRIPTS_PATH "@ZEEK_PLUGIN_SCRIPTS_PATH@") + +# For finding Zeek sources. +set(ZEEK_SOURCE_DIR "@ZEEK_SOURCE_DIR@") + +# Provide a hint to ZeekConfig.cmake where to find Broker from the build tree. +# Note: the straightforward way would be setting `Broker_ROOT` instead, but +# plugins may still use CMake < 3.12. +if (NOT "@ZEEK_HAS_EXTERNAL_BROKER@") + set(Broker_DIR "@ZEEK_PLUGIN_BROKER_PATH@" CACHE + PATH "Directory for finding Broker's package file" FORCE) +endif () + +# Provide hint to the plugins where to find standard packages by passing along +# user-defined values. +set(ZeekOpenSSLHint "@ZeekOpenSSLHint@") +if (ZeekOpenSSLHint AND NOT OPENSSL_ROOT_DIR) + set(OPENSSL_ROOT_DIR "${ZeekOpenSSLHint}" CACHE + PATH "Directory hint for finding OpenSSL" FORCE) +endif () + +# Force PKG_CONFIG_PATH environment variable to reflect what we've used when +# building Zeek. +set(ZeekPkgConfigPath "@ZeekPkgConfigPath@") +if (ZeekPkgConfigPath) + set(ENV{PKG_CONFIG_PATH} "${ZeekPkgConfigPath}") +endif () + +# For having a binpac target available. Guarded to shield against including this +# file multiple times. +if (NOT TARGET Zeek::BinPAC) + add_executable(Zeek::BinPAC IMPORTED) + set_property(TARGET Zeek::BinPAC PROPERTY + IMPORTED_LOCATION "@BINPAC_EXE_PATH@") +endif () + +# For having a bifcl target available. Guarded to shield against including this +# file multiple times. +if (NOT TARGET Zeek::BifCl) + add_executable(Zeek::BifCl IMPORTED) + set_property(TARGET Zeek::BifCl PROPERTY + IMPORTED_LOCATION "@BIFCL_EXE_PATH@") +endif () + +# TODO: using BIFCL_EXE_PATH and BINPAC_EXE_PATH does not play well with +# multi-configuration generators. We currently hard-code these paths in +# the main CMakeLists.txt instead of dynamically fetching the right thing. +# A better solution would be either using find_program here or +# `file(GENERATE ...)` from the main CMake file. diff --git a/src/analyzer/CMakeLists.txt b/src/analyzer/CMakeLists.txt index 559a43849b..496de66d32 100644 --- a/src/analyzer/CMakeLists.txt +++ b/src/analyzer/CMakeLists.txt @@ -1,20 +1,14 @@ - -include(ZeekSubdir) - -include_directories(BEFORE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} -) - -add_subdirectory(protocol) - -set(analyzer_SRCS - Analyzer.cc - Manager.cc - Component.cc +zeek_add_subdir_library( + analyzer + INTERNAL_DEPENDENCIES ${BIF_BUILD_TARGET} + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} + SOURCES + Analyzer.cc + Component.cc + Manager.cc ) +# Treat BIFs as builtin (alternative mode). bif_target(analyzer.bif) -bro_add_subdir_library(analyzer ${analyzer_SRCS}) -add_dependencies(bro_analyzer generate_outputs) +add_subdirectory(protocol) diff --git a/src/analyzer/protocol/CMakeLists.txt b/src/analyzer/protocol/CMakeLists.txt index 4bebee739e..4ea6642255 100644 --- a/src/analyzer/protocol/CMakeLists.txt +++ b/src/analyzer/protocol/CMakeLists.txt @@ -1,3 +1,5 @@ +include(ZeekPlugin) + add_subdirectory(bittorrent) add_subdirectory(conn-size) add_subdirectory(dce-rpc) diff --git a/src/analyzer/protocol/bittorrent/CMakeLists.txt b/src/analyzer/protocol/bittorrent/CMakeLists.txt index ca7c9b9e36..2881d8339f 100644 --- a/src/analyzer/protocol/bittorrent/CMakeLists.txt +++ b/src/analyzer/protocol/bittorrent/CMakeLists.txt @@ -1,10 +1,14 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek BitTorrent) -zeek_plugin_cc(BitTorrent.cc BitTorrentTracker.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_pac(bittorrent.pac bittorrent-analyzer.pac bittorrent-protocol.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + BitTorrent + SOURCES + BitTorrent.cc + BitTorrentTracker.cc + Plugin.cc + BIFS + events.bif + PAC + bittorrent.pac + bittorrent-analyzer.pac + bittorrent-protocol.pac +) diff --git a/src/analyzer/protocol/conn-size/CMakeLists.txt b/src/analyzer/protocol/conn-size/CMakeLists.txt index 30b1bedab3..5ed096d5c3 100644 --- a/src/analyzer/protocol/conn-size/CMakeLists.txt +++ b/src/analyzer/protocol/conn-size/CMakeLists.txt @@ -1,10 +1,10 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek ConnSize) -zeek_plugin_cc(ConnSize.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_bif(functions.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + ConnSize + SOURCES + ConnSize.cc + Plugin.cc + BIFS + events.bif + functions.bif +) diff --git a/src/analyzer/protocol/dce-rpc/CMakeLists.txt b/src/analyzer/protocol/dce-rpc/CMakeLists.txt index 286f7fd0b2..39cb498b6e 100644 --- a/src/analyzer/protocol/dce-rpc/CMakeLists.txt +++ b/src/analyzer/protocol/dce-rpc/CMakeLists.txt @@ -1,18 +1,18 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek DCE_RPC) -zeek_plugin_cc(DCE_RPC.cc Plugin.cc) -zeek_plugin_bif(consts.bif types.bif events.bif) -zeek_plugin_pac( - dce_rpc.pac - dce_rpc-protocol.pac - dce_rpc-analyzer.pac - dce_rpc-auth.pac - endpoint-atsvc.pac - endpoint-epmapper.pac - ) -zeek_plugin_end() - +zeek_add_plugin( + Zeek + DCE_RPC + SOURCES + DCE_RPC.cc + Plugin.cc + BIFS + consts.bif + types.bif + events.bif + PAC + dce_rpc.pac + dce_rpc-protocol.pac + dce_rpc-analyzer.pac + dce_rpc-auth.pac + endpoint-atsvc.pac + endpoint-epmapper.pac +) diff --git a/src/analyzer/protocol/dhcp/CMakeLists.txt b/src/analyzer/protocol/dhcp/CMakeLists.txt index 8fa784b4be..2964060d82 100644 --- a/src/analyzer/protocol/dhcp/CMakeLists.txt +++ b/src/analyzer/protocol/dhcp/CMakeLists.txt @@ -1,11 +1,15 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek DHCP) -zeek_plugin_cc(DHCP.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_bif(types.bif) -zeek_plugin_pac(dhcp.pac dhcp-protocol.pac dhcp-analyzer.pac dhcp-options.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + DHCP + SOURCES + DHCP.cc + Plugin.cc + BIFS + events.bif + types.bif + PAC + dhcp.pac + dhcp-protocol.pac + dhcp-analyzer.pac + dhcp-options.pac +) diff --git a/src/analyzer/protocol/dnp3/CMakeLists.txt b/src/analyzer/protocol/dnp3/CMakeLists.txt index aaa7581319..be084cf874 100644 --- a/src/analyzer/protocol/dnp3/CMakeLists.txt +++ b/src/analyzer/protocol/dnp3/CMakeLists.txt @@ -1,10 +1,14 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek DNP3) -zeek_plugin_cc(DNP3.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_pac(dnp3.pac dnp3-analyzer.pac dnp3-protocol.pac dnp3-objects.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + DNP3 + SOURCES + DNP3.cc + Plugin.cc + BIFS + events.bif + PAC + dnp3.pac + dnp3-analyzer.pac + dnp3-protocol.pac + dnp3-objects.pac +) diff --git a/src/analyzer/protocol/dns/CMakeLists.txt b/src/analyzer/protocol/dns/CMakeLists.txt index 76c3129eba..8e6a9c8a93 100644 --- a/src/analyzer/protocol/dns/CMakeLists.txt +++ b/src/analyzer/protocol/dns/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek DNS) -zeek_plugin_cc(DNS.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + DNS + SOURCES + DNS.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/analyzer/protocol/file/CMakeLists.txt b/src/analyzer/protocol/file/CMakeLists.txt index 5c11356991..5408b1851c 100644 --- a/src/analyzer/protocol/file/CMakeLists.txt +++ b/src/analyzer/protocol/file/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek File) -zeek_plugin_cc(File.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + File + SOURCES + File.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/analyzer/protocol/finger/legacy/CMakeLists.txt b/src/analyzer/protocol/finger/legacy/CMakeLists.txt index e89f268a8a..6f006489bd 100644 --- a/src/analyzer/protocol/finger/legacy/CMakeLists.txt +++ b/src/analyzer/protocol/finger/legacy/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek Finger) -zeek_plugin_cc(Finger.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + Finger + SOURCES + Finger.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/analyzer/protocol/ftp/CMakeLists.txt b/src/analyzer/protocol/ftp/CMakeLists.txt index ff6d372295..3420c4eb5f 100644 --- a/src/analyzer/protocol/ftp/CMakeLists.txt +++ b/src/analyzer/protocol/ftp/CMakeLists.txt @@ -1,10 +1,10 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek FTP) -zeek_plugin_cc(FTP.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_bif(functions.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + FTP + SOURCES + FTP.cc + Plugin.cc + BIFS + events.bif + functions.bif +) diff --git a/src/analyzer/protocol/gnutella/CMakeLists.txt b/src/analyzer/protocol/gnutella/CMakeLists.txt index d463ac6af7..7177f2bb4b 100644 --- a/src/analyzer/protocol/gnutella/CMakeLists.txt +++ b/src/analyzer/protocol/gnutella/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek Gnutella) -zeek_plugin_cc(Gnutella.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + Gnutella + SOURCES + Gnutella.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/analyzer/protocol/gssapi/CMakeLists.txt b/src/analyzer/protocol/gssapi/CMakeLists.txt index 74ae705313..c35ae4187b 100644 --- a/src/analyzer/protocol/gssapi/CMakeLists.txt +++ b/src/analyzer/protocol/gssapi/CMakeLists.txt @@ -1,16 +1,14 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek GSSAPI) -zeek_plugin_cc(GSSAPI.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_pac( - gssapi.pac - gssapi-protocol.pac - gssapi-analyzer.pac - ../asn1/asn1.pac - ) -zeek_plugin_end() - +zeek_add_plugin( + Zeek + GSSAPI + SOURCES + GSSAPI.cc + Plugin.cc + BIFS + events.bif + PAC + gssapi.pac + gssapi-protocol.pac + gssapi-analyzer.pac + ${PROJECT_SOURCE_DIR}/src/analyzer/protocol/asn1/asn1.pac +) diff --git a/src/analyzer/protocol/http/CMakeLists.txt b/src/analyzer/protocol/http/CMakeLists.txt index 1b173e6949..eb1f66e9f0 100644 --- a/src/analyzer/protocol/http/CMakeLists.txt +++ b/src/analyzer/protocol/http/CMakeLists.txt @@ -1,10 +1,10 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek HTTP) -zeek_plugin_cc(HTTP.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_bif(functions.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + HTTP + SOURCES + HTTP.cc + Plugin.cc + BIFS + events.bif + functions.bif +) diff --git a/src/analyzer/protocol/ident/CMakeLists.txt b/src/analyzer/protocol/ident/CMakeLists.txt index 22ac6e94a1..549073420d 100644 --- a/src/analyzer/protocol/ident/CMakeLists.txt +++ b/src/analyzer/protocol/ident/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek Ident) -zeek_plugin_cc(Ident.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + Ident + SOURCES + Ident.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/analyzer/protocol/imap/CMakeLists.txt b/src/analyzer/protocol/imap/CMakeLists.txt index 472b465b71..33f340b54f 100644 --- a/src/analyzer/protocol/imap/CMakeLists.txt +++ b/src/analyzer/protocol/imap/CMakeLists.txt @@ -1,12 +1,13 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek IMAP) -zeek_plugin_cc(Plugin.cc) -zeek_plugin_cc(IMAP.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_pac(imap.pac imap-analyzer.pac imap-protocol.pac) -zeek_plugin_end() - +zeek_add_plugin( + Zeek + IMAP + SOURCES + Plugin.cc + IMAP.cc + BIFS + events.bif + PAC + imap.pac + imap-analyzer.pac + imap-protocol.pac +) diff --git a/src/analyzer/protocol/irc/CMakeLists.txt b/src/analyzer/protocol/irc/CMakeLists.txt index 4538172d75..a99f0a5b72 100644 --- a/src/analyzer/protocol/irc/CMakeLists.txt +++ b/src/analyzer/protocol/irc/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek IRC) -zeek_plugin_cc(IRC.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + IRC + SOURCES + IRC.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/analyzer/protocol/krb/CMakeLists.txt b/src/analyzer/protocol/krb/CMakeLists.txt index d052e9bb6c..192b9cf2bc 100644 --- a/src/analyzer/protocol/krb/CMakeLists.txt +++ b/src/analyzer/protocol/krb/CMakeLists.txt @@ -1,26 +1,29 @@ -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek KRB) -zeek_plugin_cc(Plugin.cc) -zeek_plugin_cc(KRB.cc) -zeek_plugin_cc(KRB_TCP.cc) -zeek_plugin_bif(types.bif) -zeek_plugin_bif(events.bif) -zeek_plugin_pac(krb.pac krb-protocol.pac krb-analyzer.pac - krb-asn1.pac - krb-defs.pac - krb-types.pac - krb-padata.pac - ../asn1/asn1.pac +zeek_add_plugin( + Zeek + KRB + SOURCES + Plugin.cc + KRB.cc + KRB_TCP.cc + BIFS + types.bif + events.bif + PAC + krb.pac + krb-protocol.pac + krb-analyzer.pac + krb-asn1.pac + krb-defs.pac + krb-types.pac + krb-padata.pac + ${PROJECT_SOURCE_DIR}/src/analyzer/protocol/asn1/asn1.pac + PAC + krb_TCP.pac + krb-protocol.pac + krb-analyzer.pac + krb-asn1.pac + krb-defs.pac + krb-types.pac + krb-padata.pac + ${PROJECT_SOURCE_DIR}/src/analyzer/protocol/asn1/asn1.pac ) -zeek_plugin_pac(krb_TCP.pac krb-protocol.pac krb-analyzer.pac - krb-asn1.pac - krb-defs.pac - krb-types.pac - krb-padata.pac - ../asn1/asn1.pac -) -zeek_plugin_end() diff --git a/src/analyzer/protocol/login/CMakeLists.txt b/src/analyzer/protocol/login/CMakeLists.txt index cb8217aaeb..215d17dbd6 100644 --- a/src/analyzer/protocol/login/CMakeLists.txt +++ b/src/analyzer/protocol/login/CMakeLists.txt @@ -1,10 +1,14 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek Login) -zeek_plugin_cc(Login.cc RSH.cc Telnet.cc Rlogin.cc NVT.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_bif(functions.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + Login + SOURCES + Login.cc + RSH.cc + Telnet.cc + Rlogin.cc + NVT.cc + Plugin.cc + BIFS + events.bif + functions.bif +) diff --git a/src/analyzer/protocol/mime/CMakeLists.txt b/src/analyzer/protocol/mime/CMakeLists.txt index 6275297dc9..6936945852 100644 --- a/src/analyzer/protocol/mime/CMakeLists.txt +++ b/src/analyzer/protocol/mime/CMakeLists.txt @@ -1,15 +1,14 @@ +# This is not an actual analyzer, but used by others. We still maintain it here +# along with the other analyzers because conceptually it's also parsing a +# protocol just like them. The current structure is merely a left-over from when +# this code was written. -# This is not an actual analyzer, but used by others. We still -# maintain it here along with the other analyzers because conceptually -# it's also parsing a protocol just like them. The current structure -# is merely a left-over from when this code was written. - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek MIME) -zeek_plugin_cc(MIME.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() - +zeek_add_plugin( + Zeek + MIME + SOURCES + MIME.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/analyzer/protocol/modbus/CMakeLists.txt b/src/analyzer/protocol/modbus/CMakeLists.txt index 2560f18a60..edb22e4727 100644 --- a/src/analyzer/protocol/modbus/CMakeLists.txt +++ b/src/analyzer/protocol/modbus/CMakeLists.txt @@ -1,10 +1,13 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek Modbus) -zeek_plugin_cc(Modbus.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_pac(modbus.pac modbus-analyzer.pac modbus-protocol.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + Modbus + SOURCES + Modbus.cc + Plugin.cc + BIFS + events.bif + PAC + modbus.pac + modbus-analyzer.pac + modbus-protocol.pac +) diff --git a/src/analyzer/protocol/mqtt/CMakeLists.txt b/src/analyzer/protocol/mqtt/CMakeLists.txt index 81c8c50b69..471be968bb 100644 --- a/src/analyzer/protocol/mqtt/CMakeLists.txt +++ b/src/analyzer/protocol/mqtt/CMakeLists.txt @@ -1,26 +1,27 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek MQTT) -zeek_plugin_cc(MQTT.cc Plugin.cc) -zeek_plugin_bif(types.bif events.bif) -zeek_plugin_pac(mqtt.pac - mqtt-protocol.pac - commands/connect.pac - commands/connack.pac - commands/publish.pac - commands/puback.pac - commands/pubrec.pac - commands/pubrel.pac - commands/pubcomp.pac - commands/subscribe.pac - commands/suback.pac - commands/unsuback.pac - commands/unsubscribe.pac - commands/disconnect.pac - commands/pingreq.pac - commands/pingresp.pac - ) -zeek_plugin_end() +zeek_add_plugin( + Zeek + MQTT + SOURCES + MQTT.cc + Plugin.cc + BIFS + types.bif + events.bif + PAC + mqtt.pac + mqtt-protocol.pac + commands/connect.pac + commands/connack.pac + commands/publish.pac + commands/puback.pac + commands/pubrec.pac + commands/pubrel.pac + commands/pubcomp.pac + commands/subscribe.pac + commands/suback.pac + commands/unsuback.pac + commands/unsubscribe.pac + commands/disconnect.pac + commands/pingreq.pac + commands/pingresp.pac +) diff --git a/src/analyzer/protocol/mysql/CMakeLists.txt b/src/analyzer/protocol/mysql/CMakeLists.txt index 3ac448c665..deb369a18b 100644 --- a/src/analyzer/protocol/mysql/CMakeLists.txt +++ b/src/analyzer/protocol/mysql/CMakeLists.txt @@ -1,10 +1,13 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek MySQL) - zeek_plugin_cc(MySQL.cc Plugin.cc) - zeek_plugin_bif(events.bif) - zeek_plugin_pac(mysql.pac mysql-analyzer.pac mysql-protocol.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + MySQL + SOURCES + MySQL.cc + Plugin.cc + BIFS + events.bif + PAC + mysql.pac + mysql-analyzer.pac + mysql-protocol.pac +) diff --git a/src/analyzer/protocol/ncp/CMakeLists.txt b/src/analyzer/protocol/ncp/CMakeLists.txt index 62b198553b..55805782b4 100644 --- a/src/analyzer/protocol/ncp/CMakeLists.txt +++ b/src/analyzer/protocol/ncp/CMakeLists.txt @@ -1,10 +1,12 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek NCP) -zeek_plugin_cc(NCP.cc Plugin.cc) -zeek_plugin_bif(events.bif consts.bif) -zeek_plugin_pac(ncp.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + NCP + SOURCES + NCP.cc + Plugin.cc + BIFS + events.bif + consts.bif + PAC + ncp.pac +) diff --git a/src/analyzer/protocol/netbios/CMakeLists.txt b/src/analyzer/protocol/netbios/CMakeLists.txt index 4ae22a6f42..e000eee6e5 100644 --- a/src/analyzer/protocol/netbios/CMakeLists.txt +++ b/src/analyzer/protocol/netbios/CMakeLists.txt @@ -1,13 +1,10 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) -include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR}/../dce-rpc) -include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR}/../smb) - -zeek_plugin_begin(Zeek NetBIOS) -zeek_plugin_cc(NetbiosSSN.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_bif(functions.bif) -zeek_plugin_end() - +zeek_add_plugin( + Zeek + NetBIOS + SOURCES + NetbiosSSN.cc + Plugin.cc + BIFS + events.bif + functions.bif +) diff --git a/src/analyzer/protocol/ntlm/CMakeLists.txt b/src/analyzer/protocol/ntlm/CMakeLists.txt index e2e627f36b..340551d9ba 100644 --- a/src/analyzer/protocol/ntlm/CMakeLists.txt +++ b/src/analyzer/protocol/ntlm/CMakeLists.txt @@ -1,15 +1,14 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek NTLM) -zeek_plugin_cc(NTLM.cc Plugin.cc) -zeek_plugin_bif(types.bif events.bif) -zeek_plugin_pac( - ntlm.pac - ntlm-protocol.pac - ntlm-analyzer.pac - ) -zeek_plugin_end() - +zeek_add_plugin( + Zeek + NTLM + SOURCES + NTLM.cc + Plugin.cc + BIFS + types.bif + events.bif + PAC + ntlm.pac + ntlm-protocol.pac + ntlm-analyzer.pac +) diff --git a/src/analyzer/protocol/ntp/CMakeLists.txt b/src/analyzer/protocol/ntp/CMakeLists.txt index 863e9798aa..3f38c34b8b 100644 --- a/src/analyzer/protocol/ntp/CMakeLists.txt +++ b/src/analyzer/protocol/ntp/CMakeLists.txt @@ -1,10 +1,15 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek NTP) -zeek_plugin_cc(NTP.cc Plugin.cc) -zeek_plugin_bif(types.bif events.bif) -zeek_plugin_pac(ntp.pac ntp-analyzer.pac ntp-mode7.pac ntp-protocol.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + NTP + SOURCES + NTP.cc + Plugin.cc + BIFS + types.bif + events.bif + PAC + ntp.pac + ntp-analyzer.pac + ntp-mode7.pac + ntp-protocol.pac +) diff --git a/src/analyzer/protocol/pia/CMakeLists.txt b/src/analyzer/protocol/pia/CMakeLists.txt index b2bcf0c70c..ad7fdc8a55 100644 --- a/src/analyzer/protocol/pia/CMakeLists.txt +++ b/src/analyzer/protocol/pia/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek PIA) -zeek_plugin_cc(PIA.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + Zeek + PIA + SOURCES + PIA.cc + Plugin.cc +) diff --git a/src/analyzer/protocol/pop3/CMakeLists.txt b/src/analyzer/protocol/pop3/CMakeLists.txt index dcca381140..3de7ae5289 100644 --- a/src/analyzer/protocol/pop3/CMakeLists.txt +++ b/src/analyzer/protocol/pop3/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek POP3) -zeek_plugin_cc(POP3.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + POP3 + SOURCES + POP3.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/analyzer/protocol/radius/CMakeLists.txt b/src/analyzer/protocol/radius/CMakeLists.txt index 3e5477be9e..62c541fa58 100644 --- a/src/analyzer/protocol/radius/CMakeLists.txt +++ b/src/analyzer/protocol/radius/CMakeLists.txt @@ -1,10 +1,13 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek RADIUS) -zeek_plugin_cc(RADIUS.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_pac(radius.pac radius-analyzer.pac radius-protocol.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + RADIUS + SOURCES + RADIUS.cc + Plugin.cc + BIFS + events.bif + PAC + radius.pac + radius-analyzer.pac + radius-protocol.pac +) diff --git a/src/analyzer/protocol/rdp/CMakeLists.txt b/src/analyzer/protocol/rdp/CMakeLists.txt index 7011373593..836dc45ca8 100644 --- a/src/analyzer/protocol/rdp/CMakeLists.txt +++ b/src/analyzer/protocol/rdp/CMakeLists.txt @@ -1,11 +1,20 @@ -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek RDP) - zeek_plugin_cc(RDPEUDP.cc RDP.cc Plugin.cc) - zeek_plugin_bif(events.bif) - zeek_plugin_bif(types.bif) - zeek_plugin_pac(rdp.pac rdp-analyzer.pac rdp-protocol.pac ../asn1/asn1.pac) - zeek_plugin_pac(rdpeudp.pac rdpeudp-analyzer.pac rdpeudp-protocol.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + RDP + SOURCES + RDPEUDP.cc + RDP.cc + Plugin.cc + BIFS + events.bif + types.bif + PAC + rdp.pac + rdp-analyzer.pac + rdp-protocol.pac + ${PROJECT_SOURCE_DIR}/src/analyzer/protocol/asn1/asn1.pac + PAC + rdpeudp.pac + rdpeudp-analyzer.pac + rdpeudp-protocol.pac +) diff --git a/src/analyzer/protocol/rfb/CMakeLists.txt b/src/analyzer/protocol/rfb/CMakeLists.txt index 10c8b2de12..0d902b55d7 100644 --- a/src/analyzer/protocol/rfb/CMakeLists.txt +++ b/src/analyzer/protocol/rfb/CMakeLists.txt @@ -1,9 +1,13 @@ -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek RFB) - zeek_plugin_cc(RFB.cc Plugin.cc) - zeek_plugin_bif(events.bif) - zeek_plugin_pac(rfb.pac rfb-analyzer.pac rfb-protocol.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + RFB + SOURCES + RFB.cc + Plugin.cc + BIFS + events.bif + PAC + rfb.pac + rfb-analyzer.pac + rfb-protocol.pac +) diff --git a/src/analyzer/protocol/rpc/CMakeLists.txt b/src/analyzer/protocol/rpc/CMakeLists.txt index f1da2c9692..e871ec1956 100644 --- a/src/analyzer/protocol/rpc/CMakeLists.txt +++ b/src/analyzer/protocol/rpc/CMakeLists.txt @@ -1,9 +1,13 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek RPC) -zeek_plugin_cc(RPC.cc NFS.cc MOUNT.cc Portmap.cc XDR.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + RPC + SOURCES + RPC.cc + NFS.cc + MOUNT.cc + Portmap.cc + XDR.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/analyzer/protocol/sip/CMakeLists.txt b/src/analyzer/protocol/sip/CMakeLists.txt index e0ae9d2b90..1fb64bf0af 100644 --- a/src/analyzer/protocol/sip/CMakeLists.txt +++ b/src/analyzer/protocol/sip/CMakeLists.txt @@ -1,14 +1,18 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek SIP) -zeek_plugin_cc(Plugin.cc) -zeek_plugin_cc(SIP.cc) -zeek_plugin_cc(SIP_TCP.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_pac(sip.pac sip-analyzer.pac sip-protocol.pac) -zeek_plugin_pac(sip_TCP.pac sip-protocol.pac sip-analyzer.pac) -zeek_plugin_end() - +zeek_add_plugin( + Zeek + SIP + SOURCES + Plugin.cc + SIP.cc + SIP_TCP.cc + BIFS + events.bif + PAC + sip.pac + sip-analyzer.pac + sip-protocol.pac + PAC + sip_TCP.pac + sip-protocol.pac + sip-analyzer.pac +) diff --git a/src/analyzer/protocol/smb/CMakeLists.txt b/src/analyzer/protocol/smb/CMakeLists.txt index 5fbbe190d0..7466dbd263 100644 --- a/src/analyzer/protocol/smb/CMakeLists.txt +++ b/src/analyzer/protocol/smb/CMakeLists.txt @@ -1,90 +1,89 @@ -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) -include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR}/../dce-rpc) - -zeek_plugin_begin(Zeek SMB) -zeek_plugin_cc(SMB.cc Plugin.cc) -zeek_plugin_bif( - smb1_com_check_directory.bif - smb1_com_close.bif - smb1_com_create_directory.bif - smb1_com_echo.bif - smb1_com_logoff_andx.bif - smb1_com_negotiate.bif - smb1_com_nt_create_andx.bif - smb1_com_nt_cancel.bif - smb1_com_query_information.bif - smb1_com_read_andx.bif - smb1_com_session_setup_andx.bif - smb1_com_transaction.bif - smb1_com_transaction_secondary.bif - smb1_com_transaction2.bif - smb1_com_transaction2_secondary.bif - smb1_com_tree_connect_andx.bif - smb1_com_tree_disconnect.bif - smb1_com_write_andx.bif - smb1_events.bif - - smb2_com_close.bif - smb2_com_create.bif - smb2_com_negotiate.bif - smb2_com_read.bif - smb2_com_session_setup.bif - smb2_com_set_info.bif - smb2_com_tree_connect.bif - smb2_com_tree_disconnect.bif - smb2_com_write.bif - smb2_com_transform_header.bif - smb2_events.bif - - events.bif - consts.bif - - types.bif) -zeek_plugin_pac( - smb.pac - smb-common.pac - smb-strings.pac - smb-time.pac - smb-pipe.pac - smb-gssapi.pac - smb-mailslot.pac - - smb1-protocol.pac - smb1-com-check-directory.pac - smb1-com-close.pac - smb1-com-create-directory.pac - smb1-com-echo.pac - smb1-com-locking-andx.pac - smb1-com-logoff-andx.pac - smb1-com-negotiate.pac - smb1-com-nt-cancel.pac - smb1-com-nt-create-andx.pac - smb1-com-nt-transact.pac - smb1-com-query-information.pac - smb1-com-read-andx.pac - smb1-com-session-setup-andx.pac - smb1-com-transaction-secondary.pac - smb1-com-transaction.pac - smb1-com-transaction2.pac - smb1-com-transaction2-secondary.pac - smb1-com-tree-connect-andx.pac - smb1-com-tree-disconnect.pac - smb1-com-write-andx.pac - - smb2-protocol.pac - smb2-com-close.pac - smb2-com-create.pac - smb2-com-ioctl.pac - smb2-com-lock.pac - smb2-com-negotiate.pac - smb2-com-read.pac - smb2-com-session-setup.pac - smb2-com-set-info.pac - smb2-com-tree-connect.pac - smb2-com-tree-disconnect.pac - smb2-com-write.pac - smb2-com-transform-header.pac +zeek_add_plugin( + Zeek + SMB + SOURCES + SMB.cc + Plugin.cc + BIFS + # SMB 1. + smb1_com_check_directory.bif + smb1_com_close.bif + smb1_com_create_directory.bif + smb1_com_echo.bif + smb1_com_logoff_andx.bif + smb1_com_negotiate.bif + smb1_com_nt_create_andx.bif + smb1_com_nt_cancel.bif + smb1_com_query_information.bif + smb1_com_read_andx.bif + smb1_com_session_setup_andx.bif + smb1_com_transaction.bif + smb1_com_transaction_secondary.bif + smb1_com_transaction2.bif + smb1_com_transaction2_secondary.bif + smb1_com_tree_connect_andx.bif + smb1_com_tree_disconnect.bif + smb1_com_write_andx.bif + smb1_events.bif + # SMB 2. + smb2_com_close.bif + smb2_com_create.bif + smb2_com_negotiate.bif + smb2_com_read.bif + smb2_com_session_setup.bif + smb2_com_set_info.bif + smb2_com_tree_connect.bif + smb2_com_tree_disconnect.bif + smb2_com_write.bif + smb2_com_transform_header.bif + smb2_events.bif + # Common boilerplate. + events.bif + consts.bif + types.bif + PAC + # Common boilerplate. + smb.pac + smb-common.pac + smb-strings.pac + smb-time.pac + smb-pipe.pac + smb-gssapi.pac + smb-mailslot.pac + # SMB 1. + smb1-protocol.pac + smb1-com-check-directory.pac + smb1-com-close.pac + smb1-com-create-directory.pac + smb1-com-echo.pac + smb1-com-locking-andx.pac + smb1-com-logoff-andx.pac + smb1-com-negotiate.pac + smb1-com-nt-cancel.pac + smb1-com-nt-create-andx.pac + smb1-com-nt-transact.pac + smb1-com-query-information.pac + smb1-com-read-andx.pac + smb1-com-session-setup-andx.pac + smb1-com-transaction-secondary.pac + smb1-com-transaction.pac + smb1-com-transaction2.pac + smb1-com-transaction2-secondary.pac + smb1-com-tree-connect-andx.pac + smb1-com-tree-disconnect.pac + smb1-com-write-andx.pac + # SMB 2. + smb2-protocol.pac + smb2-com-close.pac + smb2-com-create.pac + smb2-com-ioctl.pac + smb2-com-lock.pac + smb2-com-negotiate.pac + smb2-com-read.pac + smb2-com-session-setup.pac + smb2-com-set-info.pac + smb2-com-tree-connect.pac + smb2-com-tree-disconnect.pac + smb2-com-write.pac + smb2-com-transform-header.pac ) -zeek_plugin_end() diff --git a/src/analyzer/protocol/smtp/CMakeLists.txt b/src/analyzer/protocol/smtp/CMakeLists.txt index 3ffebc66a8..e1618af641 100644 --- a/src/analyzer/protocol/smtp/CMakeLists.txt +++ b/src/analyzer/protocol/smtp/CMakeLists.txt @@ -1,10 +1,10 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek SMTP) -zeek_plugin_cc(SMTP.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_bif(functions.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + SMTP + SOURCES + SMTP.cc + Plugin.cc + BIFS + events.bif + functions.bif +) diff --git a/src/analyzer/protocol/snmp/CMakeLists.txt b/src/analyzer/protocol/snmp/CMakeLists.txt index 988949bbad..d93762aa75 100644 --- a/src/analyzer/protocol/snmp/CMakeLists.txt +++ b/src/analyzer/protocol/snmp/CMakeLists.txt @@ -1,11 +1,15 @@ -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek SNMP) -zeek_plugin_cc(SNMP.cc Plugin.cc) -zeek_plugin_bif(types.bif) -zeek_plugin_bif(events.bif) -zeek_plugin_pac(snmp.pac snmp-protocol.pac snmp-analyzer.pac ../asn1/asn1.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + SNMP + SOURCES + SNMP.cc + Plugin.cc + BIFS + types.bif + events.bif + PAC + snmp.pac + snmp-protocol.pac + snmp-analyzer.pac + ${PROJECT_SOURCE_DIR}/src/analyzer/protocol/asn1/asn1.pac +) diff --git a/src/analyzer/protocol/socks/CMakeLists.txt b/src/analyzer/protocol/socks/CMakeLists.txt index 93e111814a..fa0e6b083d 100644 --- a/src/analyzer/protocol/socks/CMakeLists.txt +++ b/src/analyzer/protocol/socks/CMakeLists.txt @@ -1,10 +1,13 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek SOCKS) -zeek_plugin_cc(SOCKS.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_pac(socks.pac socks-protocol.pac socks-analyzer.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + SOCKS + SOURCES + SOCKS.cc + Plugin.cc + BIFS + events.bif + PAC + socks.pac + socks-protocol.pac + socks-analyzer.pac +) diff --git a/src/analyzer/protocol/ssh/CMakeLists.txt b/src/analyzer/protocol/ssh/CMakeLists.txt index a7cb99b353..6205089530 100644 --- a/src/analyzer/protocol/ssh/CMakeLists.txt +++ b/src/analyzer/protocol/ssh/CMakeLists.txt @@ -1,11 +1,15 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek SSH) - zeek_plugin_cc(SSH.cc Plugin.cc) - zeek_plugin_bif(types.bif) - zeek_plugin_bif(events.bif) - zeek_plugin_pac(ssh.pac ssh-analyzer.pac ssh-protocol.pac consts.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + SSH + SOURCES + SSH.cc + Plugin.cc + BIFS + types.bif + events.bif + PAC + ssh.pac + ssh-analyzer.pac + ssh-protocol.pac + consts.pac +) diff --git a/src/analyzer/protocol/ssl/CMakeLists.txt b/src/analyzer/protocol/ssl/CMakeLists.txt index 9a82ecff8a..3cc3fc5649 100644 --- a/src/analyzer/protocol/ssl/CMakeLists.txt +++ b/src/analyzer/protocol/ssl/CMakeLists.txt @@ -1,20 +1,35 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek SSL) -zeek_plugin_cc(SSL.cc DTLS.cc Plugin.cc) -zeek_plugin_bif(types.bif) -zeek_plugin_bif(events.bif) -zeek_plugin_bif(functions.bif) -zeek_plugin_bif(consts.bif) -zeek_plugin_pac(tls-handshake.pac tls-handshake-protocol.pac tls-handshake-analyzer.pac ssl-defs.pac - proc-certificate.pac - tls-handshake-signed_certificate_timestamp.pac +zeek_add_plugin( + Zeek + SSL + SOURCES + SSL.cc + DTLS.cc + Plugin.cc + BIFS + types.bif + events.bif + functions.bif + consts.bif + PAC + tls-handshake.pac + tls-handshake-protocol.pac + tls-handshake-analyzer.pac + ssl-defs.pac + proc-certificate.pac + tls-handshake-signed_certificate_timestamp.pac + PAC + ssl.pac + ssl-dtls-analyzer.pac + ssl-analyzer.pac + ssl-dtls-protocol.pac + ssl-protocol.pac + ssl-defs.pac + proc-certificate.pac + PAC + dtls.pac + ssl-dtls-analyzer.pac + dtls-analyzer.pac + ssl-dtls-protocol.pac + dtls-protocol.pac + ssl-defs.pac ) -zeek_plugin_pac(ssl.pac ssl-dtls-analyzer.pac ssl-analyzer.pac ssl-dtls-protocol.pac ssl-protocol.pac ssl-defs.pac - proc-certificate.pac -) -zeek_plugin_pac(dtls.pac ssl-dtls-analyzer.pac dtls-analyzer.pac ssl-dtls-protocol.pac dtls-protocol.pac ssl-defs.pac) -zeek_plugin_end() diff --git a/src/analyzer/protocol/syslog/legacy/CMakeLists.txt b/src/analyzer/protocol/syslog/legacy/CMakeLists.txt index 5e1fca87ad..472344a519 100644 --- a/src/analyzer/protocol/syslog/legacy/CMakeLists.txt +++ b/src/analyzer/protocol/syslog/legacy/CMakeLists.txt @@ -1,10 +1,13 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek Syslog) -zeek_plugin_cc(Syslog.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_pac(syslog.pac syslog-analyzer.pac syslog-protocol.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + Syslog + SOURCES + Syslog.cc + Plugin.cc + BIFS + events.bif + PAC + syslog.pac + syslog-analyzer.pac + syslog-protocol.pac +) diff --git a/src/analyzer/protocol/tcp/CMakeLists.txt b/src/analyzer/protocol/tcp/CMakeLists.txt index 885897cd31..613fdc2249 100644 --- a/src/analyzer/protocol/tcp/CMakeLists.txt +++ b/src/analyzer/protocol/tcp/CMakeLists.txt @@ -1,11 +1,14 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek TCP) -zeek_plugin_cc(TCP.cc TCP_Endpoint.cc TCP_Reassembler.cc ContentLine.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_bif(types.bif) -zeek_plugin_bif(functions.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + TCP + SOURCES + TCP.cc + TCP_Endpoint.cc + TCP_Reassembler.cc + ContentLine.cc + Plugin.cc + BIFS + events.bif + types.bif + functions.bif +) diff --git a/src/analyzer/protocol/xmpp/CMakeLists.txt b/src/analyzer/protocol/xmpp/CMakeLists.txt index 5cc55f82a7..aa3b8336a6 100644 --- a/src/analyzer/protocol/xmpp/CMakeLists.txt +++ b/src/analyzer/protocol/xmpp/CMakeLists.txt @@ -1,12 +1,13 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek XMPP) -zeek_plugin_cc(Plugin.cc) -zeek_plugin_cc(XMPP.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_pac(xmpp.pac xmpp-analyzer.pac xmpp-protocol.pac) -zeek_plugin_end() - +zeek_add_plugin( + Zeek + XMPP + SOURCES + Plugin.cc + XMPP.cc + BIFS + events.bif + PAC + xmpp.pac + xmpp-analyzer.pac + xmpp-protocol.pac +) diff --git a/src/analyzer/protocol/zip/CMakeLists.txt b/src/analyzer/protocol/zip/CMakeLists.txt index 579d225e5a..d51057c15d 100644 --- a/src/analyzer/protocol/zip/CMakeLists.txt +++ b/src/analyzer/protocol/zip/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek ZIP) -zeek_plugin_cc(ZIP.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + Zeek + ZIP + SOURCES + ZIP.cc + Plugin.cc +) diff --git a/src/broker/CMakeLists.txt b/src/broker/CMakeLists.txt index 5918902799..e2e54b288d 100644 --- a/src/broker/CMakeLists.txt +++ b/src/broker/CMakeLists.txt @@ -1,20 +1,13 @@ -include(ZeekSubdir) - -include_directories(BEFORE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} +zeek_add_subdir_library( + comm + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} + SOURCES + Data.cc + Manager.cc + Store.cc + BIFS + comm.bif + data.bif + messaging.bif + store.bif ) - -set(comm_SRCS - Data.cc - Manager.cc - Store.cc -) - -bif_target(comm.bif) -bif_target(data.bif) -bif_target(messaging.bif) -bif_target(store.bif) - -bro_add_subdir_library(brokercomm ${comm_SRCS}) -add_dependencies(bro_brokercomm generate_outputs) diff --git a/src/file_analysis/CMakeLists.txt b/src/file_analysis/CMakeLists.txt index 8e8b18f430..80d842e8fc 100644 --- a/src/file_analysis/CMakeLists.txt +++ b/src/file_analysis/CMakeLists.txt @@ -1,23 +1,16 @@ -include(ZeekSubdir) - -include_directories(BEFORE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} +zeek_add_subdir_library( + file_analysis + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} + SOURCES + Manager.cc + File.cc + FileTimer.cc + FileReassembler.cc + Analyzer.cc + AnalyzerSet.cc + Component.cc + BIFS + file_analysis.bif ) add_subdirectory(analyzer) - -set(file_analysis_SRCS - Manager.cc - File.cc - FileTimer.cc - FileReassembler.cc - Analyzer.cc - AnalyzerSet.cc - Component.cc -) - -bif_target(file_analysis.bif) - -bro_add_subdir_library(file_analysis ${file_analysis_SRCS}) -add_dependencies(bro_file_analysis generate_outputs) diff --git a/src/file_analysis/analyzer/data_event/CMakeLists.txt b/src/file_analysis/analyzer/data_event/CMakeLists.txt index df8aada1f4..e8eda489f0 100644 --- a/src/file_analysis/analyzer/data_event/CMakeLists.txt +++ b/src/file_analysis/analyzer/data_event/CMakeLists.txt @@ -1,8 +1,9 @@ -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek FileDataEvent) -zeek_plugin_cc(DataEvent.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + Zeek + FileDataEvent + SOURCES + DataEvent.cc + Plugin.cc + INCLUDE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" +) diff --git a/src/file_analysis/analyzer/entropy/CMakeLists.txt b/src/file_analysis/analyzer/entropy/CMakeLists.txt index e6233a743b..6608822199 100644 --- a/src/file_analysis/analyzer/entropy/CMakeLists.txt +++ b/src/file_analysis/analyzer/entropy/CMakeLists.txt @@ -1,9 +1,9 @@ -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek FileEntropy) -zeek_plugin_cc(Entropy.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + FileEntropy + SOURCES + Entropy.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/file_analysis/analyzer/extract/CMakeLists.txt b/src/file_analysis/analyzer/extract/CMakeLists.txt index f24691ddff..38ce0fd4db 100644 --- a/src/file_analysis/analyzer/extract/CMakeLists.txt +++ b/src/file_analysis/analyzer/extract/CMakeLists.txt @@ -1,10 +1,10 @@ -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek FileExtract) -zeek_plugin_cc(Extract.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_bif(functions.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + FileExtract + SOURCES + Extract.cc + Plugin.cc + BIFS + events.bif + functions.bif +) diff --git a/src/file_analysis/analyzer/hash/CMakeLists.txt b/src/file_analysis/analyzer/hash/CMakeLists.txt index 66d6d7e6e8..fc1fcf50de 100644 --- a/src/file_analysis/analyzer/hash/CMakeLists.txt +++ b/src/file_analysis/analyzer/hash/CMakeLists.txt @@ -1,9 +1,9 @@ -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek FileHash) -zeek_plugin_cc(Hash.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + FileHash + SOURCES + Hash.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/file_analysis/analyzer/pe/CMakeLists.txt b/src/file_analysis/analyzer/pe/CMakeLists.txt index c6439ce54d..dd8000f1eb 100644 --- a/src/file_analysis/analyzer/pe/CMakeLists.txt +++ b/src/file_analysis/analyzer/pe/CMakeLists.txt @@ -1,17 +1,16 @@ -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek PE) -zeek_plugin_cc(PE.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_pac( - pe.pac - pe-analyzer.pac - pe-file-headers.pac - pe-file-idata.pac - pe-file.pac - pe-file-types.pac +zeek_add_plugin( + Zeek + PE + SOURCES + PE.cc + Plugin.cc + BIFS + events.bif + PAC + pe.pac + pe-analyzer.pac + pe-file-headers.pac + pe-file-idata.pac + pe-file.pac + pe-file-types.pac ) -zeek_plugin_end() diff --git a/src/file_analysis/analyzer/x509/CMakeLists.txt b/src/file_analysis/analyzer/x509/CMakeLists.txt index d8ef11fe17..dbd93f0d3a 100644 --- a/src/file_analysis/analyzer/x509/CMakeLists.txt +++ b/src/file_analysis/analyzer/x509/CMakeLists.txt @@ -1,11 +1,17 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek X509) -zeek_plugin_cc(X509Common.cc X509.cc OCSP.cc Plugin.cc) -zeek_plugin_bif(events.bif types.bif functions.bif ocsp_events.bif) -zeek_plugin_pac(x509-extension.pac x509-signed_certificate_timestamp.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + X509 + SOURCES + X509Common.cc + X509.cc + OCSP.cc + Plugin.cc + BIFS + events.bif + types.bif + functions.bif + ocsp_events.bif + PAC + x509-extension.pac + x509-signed_certificate_timestamp.pac +) diff --git a/src/fuzzers/CMakeLists.txt b/src/fuzzers/CMakeLists.txt index cd5d7ea404..a7bef79ecb 100644 --- a/src/fuzzers/CMakeLists.txt +++ b/src/fuzzers/CMakeLists.txt @@ -64,12 +64,7 @@ include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}) add_library(zeek_fuzzer_standalone OBJECT standalone-driver.cc) -add_library(zeek_fuzzer_shared SHARED - $ - ${bro_SUBDIR_LIBS} - ${bro_PLUGIN_LIBS} - FuzzBuffer.cc -) +target_sources(zeek_fuzzer_shared PRIVATE FuzzBuffer.cc) set(zeek_fuzzer_shared_deps) @@ -83,8 +78,7 @@ foreach(_dep ${zeekdeps} ) endif () endforeach () -target_link_libraries(zeek_fuzzer_shared - ${bro_PLUGIN_LINK_LIBS} +target_link_libraries(zeek_fuzzer_shared PUBLIC ${zeek_fuzzer_shared_deps} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) diff --git a/src/input/CMakeLists.txt b/src/input/CMakeLists.txt index faad566e04..45c2c2cf58 100644 --- a/src/input/CMakeLists.txt +++ b/src/input/CMakeLists.txt @@ -1,21 +1,12 @@ - -include(ZeekSubdir) - -include_directories(BEFORE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} +zeek_add_subdir_library( + input + SOURCES + Component.cc + Manager.cc + ReaderBackend.cc + ReaderFrontend.cc + BIFS + input.bif ) add_subdirectory(readers) - -set(input_SRCS - Component.cc - Manager.cc - ReaderBackend.cc - ReaderFrontend.cc -) - -bif_target(input.bif) - -bro_add_subdir_library(input ${input_SRCS}) -add_dependencies(bro_input generate_outputs) diff --git a/src/input/readers/ascii/CMakeLists.txt b/src/input/readers/ascii/CMakeLists.txt index fe5c9f01a4..2a4d81ba2f 100644 --- a/src/input/readers/ascii/CMakeLists.txt +++ b/src/input/readers/ascii/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek AsciiReader) -zeek_plugin_cc(Ascii.cc Plugin.cc) -zeek_plugin_bif(ascii.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + AsciiReader + SOURCES + Ascii.cc + Plugin.cc + BIFS + ascii.bif +) diff --git a/src/input/readers/benchmark/CMakeLists.txt b/src/input/readers/benchmark/CMakeLists.txt index 1595af8f6c..f40091e955 100644 --- a/src/input/readers/benchmark/CMakeLists.txt +++ b/src/input/readers/benchmark/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek BenchmarkReader) -zeek_plugin_cc(Benchmark.cc Plugin.cc) -zeek_plugin_bif(benchmark.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + BenchmarkReader + SOURCES + Benchmark.cc + Plugin.cc + BIFS + benchmark.bif +) diff --git a/src/input/readers/binary/CMakeLists.txt b/src/input/readers/binary/CMakeLists.txt index 32dd2059e0..83ddb18bc6 100644 --- a/src/input/readers/binary/CMakeLists.txt +++ b/src/input/readers/binary/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek BinaryReader) -zeek_plugin_cc(Binary.cc Plugin.cc) -zeek_plugin_bif(binary.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + BinaryReader + SOURCES + Binary.cc + Plugin.cc + BIFS + binary.bif +) diff --git a/src/input/readers/config/CMakeLists.txt b/src/input/readers/config/CMakeLists.txt index 8f3553db2c..dfe3005a23 100644 --- a/src/input/readers/config/CMakeLists.txt +++ b/src/input/readers/config/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek ConfigReader) -zeek_plugin_cc(Config.cc Plugin.cc) -zeek_plugin_bif(config.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + ConfigReader + SOURCES + Config.cc + Plugin.cc + BIFS + config.bif +) diff --git a/src/input/readers/raw/CMakeLists.txt b/src/input/readers/raw/CMakeLists.txt index 2b197d5a4e..6efeb00637 100644 --- a/src/input/readers/raw/CMakeLists.txt +++ b/src/input/readers/raw/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek RawReader) -zeek_plugin_cc(Raw.cc Plugin.cc) -zeek_plugin_bif(raw.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + RawReader + SOURCES + Raw.cc + Plugin.cc + BIFS + raw.bif +) diff --git a/src/input/readers/sqlite/CMakeLists.txt b/src/input/readers/sqlite/CMakeLists.txt index 868a6c704b..7d38b66baa 100644 --- a/src/input/readers/sqlite/CMakeLists.txt +++ b/src/input/readers/sqlite/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek SQLiteReader) -zeek_plugin_cc(SQLite.cc Plugin.cc) -zeek_plugin_bif(sqlite.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + SQLiteReader + SOURCES + SQLite.cc + Plugin.cc + BIFS + sqlite.bif +) diff --git a/src/iosource/CMakeLists.txt b/src/iosource/CMakeLists.txt index 881903d65c..73a433ece4 100644 --- a/src/iosource/CMakeLists.txt +++ b/src/iosource/CMakeLists.txt @@ -1,21 +1,12 @@ - -include(ZeekSubdir) - -include_directories(BEFORE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} +zeek_add_subdir_library( + iosource + SOURCES + BPF_Program.cc + Component.cc + Manager.cc + Packet.cc + PktDumper.cc + PktSrc.cc ) add_subdirectory(pcap) - -set(iosource_SRCS - BPF_Program.cc - Component.cc - Manager.cc - Packet.cc - PktDumper.cc - PktSrc.cc - ) - -bro_add_subdir_library(iosource ${iosource_SRCS}) -add_dependencies(bro_iosource generate_outputs) diff --git a/src/iosource/pcap/CMakeLists.txt b/src/iosource/pcap/CMakeLists.txt index f829a96a19..f3dd6adc2a 100644 --- a/src/iosource/pcap/CMakeLists.txt +++ b/src/iosource/pcap/CMakeLists.txt @@ -1,9 +1,11 @@ +zeek_add_plugin( + Zeek + Pcap + SOURCES + Source.cc + Dumper.cc + Plugin.cc +) -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek Pcap) -zeek_plugin_cc(Source.cc Dumper.cc Plugin.cc) +# Treat BIFs as builtin (alternative mode). bif_target(pcap.bif) -zeek_plugin_end() diff --git a/src/iosource/pcap/pcap.bif b/src/iosource/pcap/pcap.bif index 5be3dc8636..e9ba0cbb5d 100644 --- a/src/iosource/pcap/pcap.bif +++ b/src/iosource/pcap/pcap.bif @@ -10,6 +10,7 @@ const non_fd_timeout: interval; #include "zeek/iosource/BPF_Program.h" #include "zeek/iosource/Manager.h" +#include "zeek/iosource/PktSrc.h" %%} ## Precompiles a PCAP filter and binds it to a given identifier. diff --git a/src/logging/CMakeLists.txt b/src/logging/CMakeLists.txt index 6a24de5149..581ea0013d 100644 --- a/src/logging/CMakeLists.txt +++ b/src/logging/CMakeLists.txt @@ -1,23 +1,12 @@ - -include(ZeekSubdir) - -include_directories(BEFORE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} +zeek_add_subdir_library( + logging + SOURCES + Component.cc + Manager.cc + WriterBackend.cc + WriterFrontend.cc + BIFS + logging.bif ) -include_directories(BEFORE ${CAF_INCLUDE_DIRS}) - add_subdirectory(writers) - -set(logging_SRCS - Component.cc - Manager.cc - WriterBackend.cc - WriterFrontend.cc -) - -bif_target(logging.bif) - -bro_add_subdir_library(logging ${logging_SRCS}) -add_dependencies(bro_logging generate_outputs) diff --git a/src/logging/writers/ascii/CMakeLists.txt b/src/logging/writers/ascii/CMakeLists.txt index 430631f997..940b0ff6b0 100644 --- a/src/logging/writers/ascii/CMakeLists.txt +++ b/src/logging/writers/ascii/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek AsciiWriter) -zeek_plugin_cc(Ascii.cc Plugin.cc) -zeek_plugin_bif(ascii.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + AsciiWriter + SOURCES + Ascii.cc + Plugin.cc + BIFS + ascii.bif +) diff --git a/src/logging/writers/none/CMakeLists.txt b/src/logging/writers/none/CMakeLists.txt index af386e3aee..40415927e1 100644 --- a/src/logging/writers/none/CMakeLists.txt +++ b/src/logging/writers/none/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek NoneWriter) -zeek_plugin_cc(None.cc Plugin.cc) -zeek_plugin_bif(none.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + NoneWriter + SOURCES + None.cc + Plugin.cc + BIFS + none.bif +) diff --git a/src/logging/writers/sqlite/CMakeLists.txt b/src/logging/writers/sqlite/CMakeLists.txt index 41c2f01c9e..7cbda35fc1 100644 --- a/src/logging/writers/sqlite/CMakeLists.txt +++ b/src/logging/writers/sqlite/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek SQLiteWriter) -zeek_plugin_cc(SQLite.cc Plugin.cc) -zeek_plugin_bif(sqlite.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + SQLiteWriter + SOURCES + SQLite.cc + Plugin.cc + BIFS + sqlite.bif +) diff --git a/src/packet_analysis/CMakeLists.txt b/src/packet_analysis/CMakeLists.txt index b59202ae2d..014cbe2755 100644 --- a/src/packet_analysis/CMakeLists.txt +++ b/src/packet_analysis/CMakeLists.txt @@ -1,19 +1,11 @@ - -include(ZeekSubdir) - -include_directories(BEFORE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} +zeek_add_subdir_library( + packet_analysis + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} + SOURCES + Analyzer.cc + Dispatcher.cc + Manager.cc + Component.cc ) add_subdirectory(protocol) - -set(packet_analysis_SRCS - Analyzer.cc - Dispatcher.cc - Manager.cc - Component.cc - ) - -bro_add_subdir_library(packet_analysis ${packet_analysis_SRCS}) -add_dependencies(bro_packet_analysis generate_outputs) diff --git a/src/packet_analysis/protocol/arp/CMakeLists.txt b/src/packet_analysis/protocol/arp/CMakeLists.txt index ad3c7f732f..28d7533782 100644 --- a/src/packet_analysis/protocol/arp/CMakeLists.txt +++ b/src/packet_analysis/protocol/arp/CMakeLists.txt @@ -1,9 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek ARP) -zeek_plugin_cc(ARP.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + ARP + SOURCES + ARP.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/packet_analysis/protocol/ayiya/CMakeLists.txt b/src/packet_analysis/protocol/ayiya/CMakeLists.txt index d0e0d6eb80..32f24f88d3 100644 --- a/src/packet_analysis/protocol/ayiya/CMakeLists.txt +++ b/src/packet_analysis/protocol/ayiya/CMakeLists.txt @@ -1,5 +1,7 @@ -include(ZeekPlugin) - -zeek_plugin_begin(Zeek AYIYA) -zeek_plugin_cc(AYIYA.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + Zeek + AYIYA + SOURCES + AYIYA.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/ethernet/CMakeLists.txt b/src/packet_analysis/protocol/ethernet/CMakeLists.txt index a852c8f3f3..8ac662c3b7 100644 --- a/src/packet_analysis/protocol/ethernet/CMakeLists.txt +++ b/src/packet_analysis/protocol/ethernet/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer Ethernet) -zeek_plugin_cc(Ethernet.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + Ethernet + SOURCES + Ethernet.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/fddi/CMakeLists.txt b/src/packet_analysis/protocol/fddi/CMakeLists.txt index 2e68aa92d9..40d4c00f90 100644 --- a/src/packet_analysis/protocol/fddi/CMakeLists.txt +++ b/src/packet_analysis/protocol/fddi/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer FDDI) -zeek_plugin_cc(FDDI.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + FDDI + SOURCES + FDDI.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/geneve/CMakeLists.txt b/src/packet_analysis/protocol/geneve/CMakeLists.txt index 118289fc07..c71f7c45f3 100644 --- a/src/packet_analysis/protocol/geneve/CMakeLists.txt +++ b/src/packet_analysis/protocol/geneve/CMakeLists.txt @@ -1,6 +1,9 @@ -include(ZeekPlugin) - -zeek_plugin_begin(Zeek Geneve) -zeek_plugin_cc(Geneve.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + Geneve + SOURCES + Geneve.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/packet_analysis/protocol/gre/CMakeLists.txt b/src/packet_analysis/protocol/gre/CMakeLists.txt index 4456675dd7..c9b88e19b5 100644 --- a/src/packet_analysis/protocol/gre/CMakeLists.txt +++ b/src/packet_analysis/protocol/gre/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer GRE) -zeek_plugin_cc(GRE.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + GRE + SOURCES + GRE.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/gtpv1/CMakeLists.txt b/src/packet_analysis/protocol/gtpv1/CMakeLists.txt index 49e23e36e8..63fb5cf5d0 100644 --- a/src/packet_analysis/protocol/gtpv1/CMakeLists.txt +++ b/src/packet_analysis/protocol/gtpv1/CMakeLists.txt @@ -1,11 +1,14 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek GTPv1) -zeek_plugin_cc(GTPv1.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_bif(functions.bif) -zeek_plugin_pac(gtpv1.pac gtpv1-protocol.pac gtpv1-analyzer.pac) -zeek_plugin_end() +zeek_add_plugin( + Zeek + GTPv1 + SOURCES + GTPv1.cc + Plugin.cc + BIFS + events.bif + functions.bif + PAC + gtpv1.pac + gtpv1-protocol.pac + gtpv1-analyzer.pac +) diff --git a/src/packet_analysis/protocol/icmp/CMakeLists.txt b/src/packet_analysis/protocol/icmp/CMakeLists.txt index cf60b3925e..09cefa1b1b 100644 --- a/src/packet_analysis/protocol/icmp/CMakeLists.txt +++ b/src/packet_analysis/protocol/icmp/CMakeLists.txt @@ -1,9 +1,10 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek ICMP) -zeek_plugin_cc(ICMP.cc ICMPSessionAdapter.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + ICMP + SOURCES + ICMP.cc + ICMPSessionAdapter.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/packet_analysis/protocol/ieee802_11/CMakeLists.txt b/src/packet_analysis/protocol/ieee802_11/CMakeLists.txt index bd6c43c6ea..b246a23d74 100644 --- a/src/packet_analysis/protocol/ieee802_11/CMakeLists.txt +++ b/src/packet_analysis/protocol/ieee802_11/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer IEEE802_11) -zeek_plugin_cc(IEEE802_11.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + IEEE802_11 + SOURCES + IEEE802_11.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/ieee802_11_radio/CMakeLists.txt b/src/packet_analysis/protocol/ieee802_11_radio/CMakeLists.txt index e063cbecca..2a8b31f1c5 100644 --- a/src/packet_analysis/protocol/ieee802_11_radio/CMakeLists.txt +++ b/src/packet_analysis/protocol/ieee802_11_radio/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer IEEE802_11_Radio) -zeek_plugin_cc(IEEE802_11_Radio.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + IEEE802_11_Radio + SOURCES + IEEE802_11_Radio.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/ip/CMakeLists.txt b/src/packet_analysis/protocol/ip/CMakeLists.txt index fb851f552e..59a26a6d55 100644 --- a/src/packet_analysis/protocol/ip/CMakeLists.txt +++ b/src/packet_analysis/protocol/ip/CMakeLists.txt @@ -1,8 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer IP) -zeek_plugin_cc(IP.cc IPBasedAnalyzer.cc SessionAdapter.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + IP + SOURCES + IP.cc + IPBasedAnalyzer.cc + SessionAdapter.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/iptunnel/CMakeLists.txt b/src/packet_analysis/protocol/iptunnel/CMakeLists.txt index 3f79212fc0..6518d38758 100644 --- a/src/packet_analysis/protocol/iptunnel/CMakeLists.txt +++ b/src/packet_analysis/protocol/iptunnel/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer IPTunnel) -zeek_plugin_cc(IPTunnel.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + IPTunnel + SOURCES + IPTunnel.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/linux_sll/CMakeLists.txt b/src/packet_analysis/protocol/linux_sll/CMakeLists.txt index 8e00b95609..3d517c53cd 100644 --- a/src/packet_analysis/protocol/linux_sll/CMakeLists.txt +++ b/src/packet_analysis/protocol/linux_sll/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer LinuxSLL) -zeek_plugin_cc(LinuxSLL.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + LinuxSLL + SOURCES + LinuxSLL.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/linux_sll2/CMakeLists.txt b/src/packet_analysis/protocol/linux_sll2/CMakeLists.txt index 75bc2cb0b6..63a94ca844 100644 --- a/src/packet_analysis/protocol/linux_sll2/CMakeLists.txt +++ b/src/packet_analysis/protocol/linux_sll2/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer LinuxSLL2) -zeek_plugin_cc(LinuxSLL2.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + LinuxSLL2 + SOURCES + LinuxSLL2.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/mpls/CMakeLists.txt b/src/packet_analysis/protocol/mpls/CMakeLists.txt index a72da68f3f..3e40d0fe16 100644 --- a/src/packet_analysis/protocol/mpls/CMakeLists.txt +++ b/src/packet_analysis/protocol/mpls/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer MPLS) -zeek_plugin_cc(MPLS.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + MPLS + SOURCES + MPLS.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/nflog/CMakeLists.txt b/src/packet_analysis/protocol/nflog/CMakeLists.txt index ada26faa3c..53239f2b6c 100644 --- a/src/packet_analysis/protocol/nflog/CMakeLists.txt +++ b/src/packet_analysis/protocol/nflog/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer NFLog) -zeek_plugin_cc(NFLog.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + NFLog + SOURCES + NFLog.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/null/CMakeLists.txt b/src/packet_analysis/protocol/null/CMakeLists.txt index 960c1dd031..dd0da51371 100644 --- a/src/packet_analysis/protocol/null/CMakeLists.txt +++ b/src/packet_analysis/protocol/null/CMakeLists.txt @@ -1,7 +1,7 @@ -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer Null) -zeek_plugin_cc(Null.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + Null + SOURCES + Null.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/ppp_serial/CMakeLists.txt b/src/packet_analysis/protocol/ppp_serial/CMakeLists.txt index 25917e191b..c6aa6f8f26 100644 --- a/src/packet_analysis/protocol/ppp_serial/CMakeLists.txt +++ b/src/packet_analysis/protocol/ppp_serial/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer PPPSerial) -zeek_plugin_cc(PPPSerial.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + PPPSerial + SOURCES + PPPSerial.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/pppoe/CMakeLists.txt b/src/packet_analysis/protocol/pppoe/CMakeLists.txt index 460f43856c..1173703493 100644 --- a/src/packet_analysis/protocol/pppoe/CMakeLists.txt +++ b/src/packet_analysis/protocol/pppoe/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer PPPoE) -zeek_plugin_cc(PPPoE.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + PPPoE + SOURCES + PPPoE.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/root/CMakeLists.txt b/src/packet_analysis/protocol/root/CMakeLists.txt index 3ea75189f3..c127ad458f 100644 --- a/src/packet_analysis/protocol/root/CMakeLists.txt +++ b/src/packet_analysis/protocol/root/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer Root) -zeek_plugin_cc(Root.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + Root + SOURCES + Root.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/skip/CMakeLists.txt b/src/packet_analysis/protocol/skip/CMakeLists.txt index 982cf42edd..85cede467f 100644 --- a/src/packet_analysis/protocol/skip/CMakeLists.txt +++ b/src/packet_analysis/protocol/skip/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer Skip) -zeek_plugin_cc(Skip.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + Skip + SOURCES + Skip.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/tcp/CMakeLists.txt b/src/packet_analysis/protocol/tcp/CMakeLists.txt index d9077fa5ef..6e9646a8bd 100644 --- a/src/packet_analysis/protocol/tcp/CMakeLists.txt +++ b/src/packet_analysis/protocol/tcp/CMakeLists.txt @@ -1,8 +1,9 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer TCP_PKT) -zeek_plugin_cc(TCP.cc TCPSessionAdapter.cc Plugin.cc Stats.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + TCP_PKT + SOURCES + TCP.cc + TCPSessionAdapter.cc + Plugin.cc + Stats.cc +) diff --git a/src/packet_analysis/protocol/teredo/CMakeLists.txt b/src/packet_analysis/protocol/teredo/CMakeLists.txt index 949d4beaf7..028864160e 100644 --- a/src/packet_analysis/protocol/teredo/CMakeLists.txt +++ b/src/packet_analysis/protocol/teredo/CMakeLists.txt @@ -1,7 +1,10 @@ -include(ZeekPlugin) - -zeek_plugin_begin(Zeek Teredo) -zeek_plugin_cc(Teredo.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_bif(functions.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + Teredo + SOURCES + Teredo.cc + Plugin.cc + BIFS + events.bif + functions.bif +) diff --git a/src/packet_analysis/protocol/udp/CMakeLists.txt b/src/packet_analysis/protocol/udp/CMakeLists.txt index 94952c0256..99a892a89c 100644 --- a/src/packet_analysis/protocol/udp/CMakeLists.txt +++ b/src/packet_analysis/protocol/udp/CMakeLists.txt @@ -1,9 +1,10 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(Zeek UDP) -zeek_plugin_cc(UDP.cc UDPSessionAdapter.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + UDP + SOURCES + UDP.cc + UDPSessionAdapter.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/packet_analysis/protocol/vlan/CMakeLists.txt b/src/packet_analysis/protocol/vlan/CMakeLists.txt index 8f1c86ae55..ed37c128c4 100644 --- a/src/packet_analysis/protocol/vlan/CMakeLists.txt +++ b/src/packet_analysis/protocol/vlan/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer VLAN) -zeek_plugin_cc(VLAN.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + VLAN + SOURCES + VLAN.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/vntag/CMakeLists.txt b/src/packet_analysis/protocol/vntag/CMakeLists.txt index 2fe273c239..313d5b67bf 100644 --- a/src/packet_analysis/protocol/vntag/CMakeLists.txt +++ b/src/packet_analysis/protocol/vntag/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer VNTag) -zeek_plugin_cc(VNTag.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + PacketAnalyzer + VNTag + SOURCES + VNTag.cc + Plugin.cc +) diff --git a/src/packet_analysis/protocol/vxlan/CMakeLists.txt b/src/packet_analysis/protocol/vxlan/CMakeLists.txt index 695048f77e..81623727bb 100644 --- a/src/packet_analysis/protocol/vxlan/CMakeLists.txt +++ b/src/packet_analysis/protocol/vxlan/CMakeLists.txt @@ -1,6 +1,9 @@ -include(ZeekPlugin) - -zeek_plugin_begin(Zeek VXLAN) -zeek_plugin_cc(VXLAN.cc Plugin.cc) -zeek_plugin_bif(events.bif) -zeek_plugin_end() +zeek_add_plugin( + Zeek + VXLAN + SOURCES + VXLAN.cc + Plugin.cc + BIFS + events.bif +) diff --git a/src/packet_analysis/protocol/wrapper/CMakeLists.txt b/src/packet_analysis/protocol/wrapper/CMakeLists.txt index 76b59fc30a..6c37e2e35b 100644 --- a/src/packet_analysis/protocol/wrapper/CMakeLists.txt +++ b/src/packet_analysis/protocol/wrapper/CMakeLists.txt @@ -1,8 +1,7 @@ - -include(ZeekPlugin) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - -zeek_plugin_begin(PacketAnalyzer Wrapper) -zeek_plugin_cc(Wrapper.cc Plugin.cc) -zeek_plugin_end() +zeek_add_plugin( + Zeek + Wrapper + SOURCES + Wrapper.cc + Plugin.cc +) diff --git a/src/probabilistic/CMakeLists.txt b/src/probabilistic/CMakeLists.txt index 976932c3fb..f8f948aea3 100644 --- a/src/probabilistic/CMakeLists.txt +++ b/src/probabilistic/CMakeLists.txt @@ -1,22 +1,14 @@ - -include(ZeekSubdir) - -include_directories(BEFORE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} +zeek_add_subdir_library( + probabilistic + SOURCES + BitVector.cc + BloomFilter.cc + CardinalityCounter.cc + CounterVector.cc + Hasher.cc + Topk.cc + BIFS + bloom-filter.bif + cardinality-counter.bif + top-k.bif ) - -set(probabilistic_SRCS - BitVector.cc - BloomFilter.cc - CardinalityCounter.cc - CounterVector.cc - Hasher.cc - Topk.cc) - -bif_target(bloom-filter.bif) -bif_target(cardinality-counter.bif) -bif_target(top-k.bif) -bro_add_subdir_library(probabilistic ${probabilistic_SRCS}) - -add_dependencies(bro_probabilistic generate_outputs) diff --git a/src/session/CMakeLists.txt b/src/session/CMakeLists.txt index c6f0ba93dc..752db51cbb 100644 --- a/src/session/CMakeLists.txt +++ b/src/session/CMakeLists.txt @@ -1,16 +1,7 @@ - -include(ZeekSubdir) - -include_directories(BEFORE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} +zeek_add_subdir_library( + session + SOURCES + Session.cc + Key.cc + Manager.cc ) - -set(session_SRCS - Session.cc - Key.cc - Manager.cc -) - -bro_add_subdir_library(session ${session_SRCS}) -add_dependencies(bro_session generate_outputs) diff --git a/src/telemetry/CMakeLists.txt b/src/telemetry/CMakeLists.txt index 129f49effb..b93bf72a1b 100644 --- a/src/telemetry/CMakeLists.txt +++ b/src/telemetry/CMakeLists.txt @@ -1,16 +1,7 @@ -include(ZeekSubdir) - -include_directories(BEFORE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} +zeek_add_subdir_library( + telemetry + SOURCES + Manager.cc + BIFS + telemetry.bif ) - -set(telemetry_SRCS - Manager.cc -) - -bif_target(telemetry.bif) - -bro_add_subdir_library(telemetry ${telemetry_SRCS}) -add_dependencies(bro_telemetry generate_outputs) - diff --git a/src/threading/formatters/Ascii.cc b/src/threading/formatters/Ascii.cc index 4f6f95704a..306432854f 100644 --- a/src/threading/formatters/Ascii.cc +++ b/src/threading/formatters/Ascii.cc @@ -1,6 +1,6 @@ // See the file "COPYING" in the main distribution directory for copyright. -#include "threading/formatters/Ascii.h" +#include "zeek/threading/formatters/Ascii.h" #include "zeek/zeek-config.h" diff --git a/src/zeekygen/CMakeLists.txt b/src/zeekygen/CMakeLists.txt index 79abc56f94..eee80e8a65 100644 --- a/src/zeekygen/CMakeLists.txt +++ b/src/zeekygen/CMakeLists.txt @@ -1,25 +1,16 @@ -# See the file "COPYING" in the main distribution directory for copyright. - -include(ZeekSubdir) - -include_directories(BEFORE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} -) - -set(zeekygen_SRCS - Manager.cc - Info.h - PackageInfo.cc - ScriptInfo.cc - IdentifierInfo.cc - Target.cc - Configuration.cc - ReStructuredTextTable.cc - utils.cc +zeek_add_subdir_library( + zeekygen + SOURCES + Manager.cc + Info.h + PackageInfo.cc + ScriptInfo.cc + IdentifierInfo.cc + Target.cc + Configuration.cc + ReStructuredTextTable.cc + utils.cc ) +# Treat BIFs as builtin (alternative mode). bif_target(zeekygen.bif) -bro_add_subdir_library(zeekygen ${zeekygen_SRCS}) - -add_dependencies(bro_zeekygen generate_outputs) diff --git a/testing/btest/plugins/doctest-disabled.zeek b/testing/btest/plugins/doctest-disabled.zeek deleted file mode 100644 index 780f280e3b..0000000000 --- a/testing/btest/plugins/doctest-disabled.zeek +++ /dev/null @@ -1,12 +0,0 @@ -# This requires Zeek with unit test support. The following errors if disabled. -# @TEST-REQUIRES: zeek --test -h >/dev/null - -# @TEST-EXEC: ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Demo Doctest -# @TEST-EXEC: cp -r %DIR/doctest-plugin/* . - -# Build the plugin without unit-test support. -# @TEST-EXEC: ./configure --disable-cpp-tests --zeek-dist=${DIST} && make -# -# List the plugin's test names -- there shouldn't be any. -# @TEST-EXEC: ZEEK_PLUGIN_ACTIVATE="Demo::Doctest" ZEEK_PLUGIN_PATH=`pwd` zeek --test -ltc | grep doctest-plugin >testnames || true -# @TEST-EXEC: btest-diff testnames