diff --git a/CMakeLists.txt b/CMakeLists.txt index f2d1cd17a1..3e631aa201 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,8 @@ option(ENABLE_DEBUG "Build Zeek with additional debugging support." ${ENABLE_DEB option(ENABLE_JEMALLOC "Link against jemalloc." OFF) option(ENABLE_PERFTOOLS "Build with support for Google perftools." OFF) option(ENABLE_ZEEK_UNIT_TESTS "Build the C++ unit tests." ON) +option(ENABLE_IWYU "Enable include-what-you-use for the main Zeek target." OFF) +option(ENABLE_CLANG_TIDY "Enable clang-tidy for the main Zeek target." OFF) option(INSTALL_AUX_TOOLS "Install additional tools from auxil." ${ZEEK_INSTALL_TOOLS_DEFAULT}) option(INSTALL_BTEST "Install btest alongside Zeek." ${ZEEK_INSTALL_TOOLS_DEFAULT}) option(INSTALL_BTEST_PCAPS "Install pcap files for testing." ${ZEEK_INSTALL_TOOLS_DEFAULT}) @@ -1446,56 +1448,59 @@ endif () message( "\n====================| Zeek Build Summary |====================" "\n" - "\nBuild type: ${CMAKE_BUILD_TYPE}" - "\nBuild dir: ${PROJECT_BINARY_DIR}" + "\nBuild type: ${CMAKE_BUILD_TYPE}" + "\nBuild dir: ${PROJECT_BINARY_DIR}" "\n" - "\nInstall prefix: ${CMAKE_INSTALL_PREFIX}" - "\nConfig file dir: ${ZEEK_ETC_INSTALL_DIR}" - "\nLog dir: ${ZEEK_LOG_DIR}" - "\nPlugin dir: ${ZEEK_PLUGIN_DIR}" - "\nPython module dir: ${PY_MOD_INSTALL_DIR}" - "\nScript dir: ${ZEEK_SCRIPT_INSTALL_PATH}" - "\nSpool dir: ${ZEEK_SPOOL_DIR}" - "\nState dir: ${ZEEK_STATE_DIR}" - "\nSpicy modules dir: ${ZEEK_SPICY_MODULE_PATH}" + "\nInstall prefix: ${CMAKE_INSTALL_PREFIX}" + "\nConfig file dir: ${ZEEK_ETC_INSTALL_DIR}" + "\nLog dir: ${ZEEK_LOG_DIR}" + "\nPlugin dir: ${ZEEK_PLUGIN_DIR}" + "\nPython module dir: ${PY_MOD_INSTALL_DIR}" + "\nScript dir: ${ZEEK_SCRIPT_INSTALL_PATH}" + "\nSpool dir: ${ZEEK_SPOOL_DIR}" + "\nState dir: ${ZEEK_STATE_DIR}" + "\nSpicy modules dir: ${ZEEK_SPICY_MODULE_PATH}" "\n" - "\nDebug mode: ${ENABLE_DEBUG}" - "\nUnit tests: ${ENABLE_ZEEK_UNIT_TESTS}" - "\nBuiltin Plugins: ${ZEEK_BUILTIN_PLUGINS}" + "\nDebug mode: ${ENABLE_DEBUG}" + "\nUnit tests: ${ENABLE_ZEEK_UNIT_TESTS}" + "\nBuiltin Plugins: ${ZEEK_BUILTIN_PLUGINS}" "\n" - "\nCC: ${CMAKE_C_COMPILER}" - "\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}" - "\nCXX: ${CMAKE_CXX_COMPILER}" - "\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}" - "\nCPP: ${CMAKE_CXX_COMPILER}" + "\nCC: ${CMAKE_C_COMPILER}" + "\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}" + "\nCXX: ${CMAKE_CXX_COMPILER}" + "\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}" + "\nCPP: ${CMAKE_CXX_COMPILER}" "\n" - "\nAF_PACKET: ${ZEEK_HAVE_AF_PACKET}" - "\nAux. Tools: ${INSTALL_AUX_TOOLS}" - "\nBifCL: ${_bifcl_exe_path}" - "\nBinPAC: ${_binpac_exe_path}" - "\nBTest: ${INSTALL_BTEST}" - "\nBTest tooling: ${_install_btest_tools_msg}" - "\nGen-ZAM: ${_gen_zam_exe_path}" - "\nJavaScript: ${ZEEK_HAVE_JAVASCRIPT}" - "\nSpicy: ${_spicy}" - "\nSpicy analyzers: ${USE_SPICY_ANALYZERS}" - "\nzeek-client: ${INSTALL_ZEEK_CLIENT}" - "\nZeekControl: ${INSTALL_ZEEKCTL}" - "\nzkg: ${INSTALL_ZKG}" + "\nAF_PACKET: ${ZEEK_HAVE_AF_PACKET}" + "\nAux. Tools: ${INSTALL_AUX_TOOLS}" + "\nBifCL: ${_bifcl_exe_path}" + "\nBinPAC: ${_binpac_exe_path}" + "\nBTest: ${INSTALL_BTEST}" + "\nBTest tooling: ${_install_btest_tools_msg}" + "\nGen-ZAM: ${_gen_zam_exe_path}" + "\nJavaScript: ${ZEEK_HAVE_JAVASCRIPT}" + "\nSpicy: ${_spicy}" + "\nSpicy analyzers: ${USE_SPICY_ANALYZERS}" + "\nzeek-client: ${INSTALL_ZEEK_CLIENT}" + "\nZeekControl: ${INSTALL_ZEEKCTL}" + "\nzkg: ${INSTALL_ZKG}" "\n" - "\nlibmaxminddb: ${USE_GEOIP}" - "\nKerberos: ${USE_KRB5}" - "\ngperftools found: ${HAVE_PERFTOOLS}" - "\n - tcmalloc: ${USE_PERFTOOLS_TCMALLOC}" - "\n - debugging: ${USE_PERFTOOLS_DEBUG}" - "\njemalloc: ${ENABLE_JEMALLOC}" + "\nlibmaxminddb: ${USE_GEOIP}" + "\nKerberos: ${USE_KRB5}" + "\ngperftools found: ${HAVE_PERFTOOLS}" + "\n - tcmalloc: ${USE_PERFTOOLS_TCMALLOC}" + "\n - debugging: ${USE_PERFTOOLS_DEBUG}" + "\njemalloc: ${ENABLE_JEMALLOC}" "\n" "\nCluster backends:" - "\n - Broker: ON" - "\n - ZeroMQ: ${ENABLE_CLUSTER_BACKEND_ZEROMQ}" + "\n - Broker: ON" + "\n - ZeroMQ: ${ENABLE_CLUSTER_BACKEND_ZEROMQ}" "\n" - "\nFuzz Targets: ${ZEEK_ENABLE_FUZZERS}" - "\nFuzz Engine: ${ZEEK_FUZZING_ENGINE}" + "\nFuzz Targets: ${ZEEK_ENABLE_FUZZERS}" + "\nFuzz Engine: ${ZEEK_FUZZING_ENGINE}" + "\n" + "\nInclude What You Use: ${ENABLE_IWYU}" + "\nClang-Tidy: ${ENABLE_CLANG_TIDY}" "${_analyzer_warning}" "\n" "\n================================================================\n") diff --git a/configure b/configure index 707d6474ac..726dac3c5e 100755 --- a/configure +++ b/configure @@ -70,6 +70,10 @@ Usage: $0 [OPTION]... [VAR=VALUE]... --enable-werror build with -Werror --enable-ZAM-profiling build with ZAM profiling enabled (--enable-debug implies this) --enable-spicy-ssl build with spicy SSL/TLS analyzer (conflicts with --disable-spicy) + --enable-iwyu build with include-what-you-use enabled for the main Zeek target. + Requires include-what-you-use binary to be in the PATH. + --enable-clang-tidy build with clang-tidy enabled for the main Zeek target. + Requires clang-tidy binary to be in the PATH. --disable-af-packet don't include native AF_PACKET support (Linux only) --disable-auxtools don't build or install auxiliary tools --disable-broker-tests don't try to build Broker unit tests @@ -315,6 +319,12 @@ while [ $# -ne 0 ]; do --enable-spicy-ssl) append_cache_entry ENABLE_SPICY_SSL BOOL true ;; + --enable-iwyu) + append_cache_entry ENABLE_IWYU BOOL true + ;; + --enable-clang-tidy) + append_cache_entry ENABLE_CLANG_TIDY BOOL true + ;; --disable-af-packet) append_cache_entry DISABLE_AF_PACKET BOOL true ;; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 50bc006f26..4c4621cb53 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -564,6 +564,24 @@ target_compile_definitions(zeek_objs PRIVATE ZEEK_CONFIG_SKIP_VERSION_H) add_dependencies(zeek_objs zeek_autogen_files) zeek_target_link_libraries(zeek_objs) +if (ENABLE_IWYU) + find_program(IWYU_PATH NAMES include-what-you-use iwyu) + if (NOT IWYU_PATH) + message(FATAL_ERROR "Could not find the program include-what-you-use") + endif () + + set_target_properties(zeek_objs PROPERTIES CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH}) +endif () + +if (ENABLE_CLANG_TIDY) + find_program(CLANG_TIDY_PATH NAMES clang-tidy) + if (NOT CLANG_TIDY_PATH) + message(FATAL_ERROR "Could not find the program clang-tidy") + endif () + + set_target_properties(zeek_objs PROPERTIES CXX_CLANG_TIDY ${CLANG_TIDY_PATH}) +endif () + if (HAVE_SPICY) target_link_libraries(zeek_objs PRIVATE hilti spicy) prefer_configured_spicy_include_dirs(zeek_objs)