Add ability to enable iwyu and clang-tidy at configure time

This commit is contained in:
Tim Wojtulewicz 2025-03-03 19:49:16 -07:00
parent c2a7da0044
commit c1dd1e991e
3 changed files with 75 additions and 42 deletions

View file

@ -43,6 +43,8 @@ option(ENABLE_DEBUG "Build Zeek with additional debugging support." ${ENABLE_DEB
option(ENABLE_JEMALLOC "Link against jemalloc." OFF) option(ENABLE_JEMALLOC "Link against jemalloc." OFF)
option(ENABLE_PERFTOOLS "Build with support for Google perftools." OFF) option(ENABLE_PERFTOOLS "Build with support for Google perftools." OFF)
option(ENABLE_ZEEK_UNIT_TESTS "Build the C++ unit tests." ON) 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_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 "Install btest alongside Zeek." ${ZEEK_INSTALL_TOOLS_DEFAULT})
option(INSTALL_BTEST_PCAPS "Install pcap files for testing." ${ZEEK_INSTALL_TOOLS_DEFAULT}) option(INSTALL_BTEST_PCAPS "Install pcap files for testing." ${ZEEK_INSTALL_TOOLS_DEFAULT})
@ -1446,56 +1448,59 @@ endif ()
message( message(
"\n====================| Zeek Build Summary |====================" "\n====================| Zeek Build Summary |===================="
"\n" "\n"
"\nBuild type: ${CMAKE_BUILD_TYPE}" "\nBuild type: ${CMAKE_BUILD_TYPE}"
"\nBuild dir: ${PROJECT_BINARY_DIR}" "\nBuild dir: ${PROJECT_BINARY_DIR}"
"\n" "\n"
"\nInstall prefix: ${CMAKE_INSTALL_PREFIX}" "\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
"\nConfig file dir: ${ZEEK_ETC_INSTALL_DIR}" "\nConfig file dir: ${ZEEK_ETC_INSTALL_DIR}"
"\nLog dir: ${ZEEK_LOG_DIR}" "\nLog dir: ${ZEEK_LOG_DIR}"
"\nPlugin dir: ${ZEEK_PLUGIN_DIR}" "\nPlugin dir: ${ZEEK_PLUGIN_DIR}"
"\nPython module dir: ${PY_MOD_INSTALL_DIR}" "\nPython module dir: ${PY_MOD_INSTALL_DIR}"
"\nScript dir: ${ZEEK_SCRIPT_INSTALL_PATH}" "\nScript dir: ${ZEEK_SCRIPT_INSTALL_PATH}"
"\nSpool dir: ${ZEEK_SPOOL_DIR}" "\nSpool dir: ${ZEEK_SPOOL_DIR}"
"\nState dir: ${ZEEK_STATE_DIR}" "\nState dir: ${ZEEK_STATE_DIR}"
"\nSpicy modules dir: ${ZEEK_SPICY_MODULE_PATH}" "\nSpicy modules dir: ${ZEEK_SPICY_MODULE_PATH}"
"\n" "\n"
"\nDebug mode: ${ENABLE_DEBUG}" "\nDebug mode: ${ENABLE_DEBUG}"
"\nUnit tests: ${ENABLE_ZEEK_UNIT_TESTS}" "\nUnit tests: ${ENABLE_ZEEK_UNIT_TESTS}"
"\nBuiltin Plugins: ${ZEEK_BUILTIN_PLUGINS}" "\nBuiltin Plugins: ${ZEEK_BUILTIN_PLUGINS}"
"\n" "\n"
"\nCC: ${CMAKE_C_COMPILER}" "\nCC: ${CMAKE_C_COMPILER}"
"\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}" "\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}"
"\nCXX: ${CMAKE_CXX_COMPILER}" "\nCXX: ${CMAKE_CXX_COMPILER}"
"\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}" "\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}"
"\nCPP: ${CMAKE_CXX_COMPILER}" "\nCPP: ${CMAKE_CXX_COMPILER}"
"\n" "\n"
"\nAF_PACKET: ${ZEEK_HAVE_AF_PACKET}" "\nAF_PACKET: ${ZEEK_HAVE_AF_PACKET}"
"\nAux. Tools: ${INSTALL_AUX_TOOLS}" "\nAux. Tools: ${INSTALL_AUX_TOOLS}"
"\nBifCL: ${_bifcl_exe_path}" "\nBifCL: ${_bifcl_exe_path}"
"\nBinPAC: ${_binpac_exe_path}" "\nBinPAC: ${_binpac_exe_path}"
"\nBTest: ${INSTALL_BTEST}" "\nBTest: ${INSTALL_BTEST}"
"\nBTest tooling: ${_install_btest_tools_msg}" "\nBTest tooling: ${_install_btest_tools_msg}"
"\nGen-ZAM: ${_gen_zam_exe_path}" "\nGen-ZAM: ${_gen_zam_exe_path}"
"\nJavaScript: ${ZEEK_HAVE_JAVASCRIPT}" "\nJavaScript: ${ZEEK_HAVE_JAVASCRIPT}"
"\nSpicy: ${_spicy}" "\nSpicy: ${_spicy}"
"\nSpicy analyzers: ${USE_SPICY_ANALYZERS}" "\nSpicy analyzers: ${USE_SPICY_ANALYZERS}"
"\nzeek-client: ${INSTALL_ZEEK_CLIENT}" "\nzeek-client: ${INSTALL_ZEEK_CLIENT}"
"\nZeekControl: ${INSTALL_ZEEKCTL}" "\nZeekControl: ${INSTALL_ZEEKCTL}"
"\nzkg: ${INSTALL_ZKG}" "\nzkg: ${INSTALL_ZKG}"
"\n" "\n"
"\nlibmaxminddb: ${USE_GEOIP}" "\nlibmaxminddb: ${USE_GEOIP}"
"\nKerberos: ${USE_KRB5}" "\nKerberos: ${USE_KRB5}"
"\ngperftools found: ${HAVE_PERFTOOLS}" "\ngperftools found: ${HAVE_PERFTOOLS}"
"\n - tcmalloc: ${USE_PERFTOOLS_TCMALLOC}" "\n - tcmalloc: ${USE_PERFTOOLS_TCMALLOC}"
"\n - debugging: ${USE_PERFTOOLS_DEBUG}" "\n - debugging: ${USE_PERFTOOLS_DEBUG}"
"\njemalloc: ${ENABLE_JEMALLOC}" "\njemalloc: ${ENABLE_JEMALLOC}"
"\n" "\n"
"\nCluster backends:" "\nCluster backends:"
"\n - Broker: ON" "\n - Broker: ON"
"\n - ZeroMQ: ${ENABLE_CLUSTER_BACKEND_ZEROMQ}" "\n - ZeroMQ: ${ENABLE_CLUSTER_BACKEND_ZEROMQ}"
"\n" "\n"
"\nFuzz Targets: ${ZEEK_ENABLE_FUZZERS}" "\nFuzz Targets: ${ZEEK_ENABLE_FUZZERS}"
"\nFuzz Engine: ${ZEEK_FUZZING_ENGINE}" "\nFuzz Engine: ${ZEEK_FUZZING_ENGINE}"
"\n"
"\nInclude What You Use: ${ENABLE_IWYU}"
"\nClang-Tidy: ${ENABLE_CLANG_TIDY}"
"${_analyzer_warning}" "${_analyzer_warning}"
"\n" "\n"
"\n================================================================\n") "\n================================================================\n")

10
configure vendored
View file

@ -70,6 +70,10 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--enable-werror build with -Werror --enable-werror build with -Werror
--enable-ZAM-profiling build with ZAM profiling enabled (--enable-debug implies this) --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-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-af-packet don't include native AF_PACKET support (Linux only)
--disable-auxtools don't build or install auxiliary tools --disable-auxtools don't build or install auxiliary tools
--disable-broker-tests don't try to build Broker unit tests --disable-broker-tests don't try to build Broker unit tests
@ -315,6 +319,12 @@ while [ $# -ne 0 ]; do
--enable-spicy-ssl) --enable-spicy-ssl)
append_cache_entry ENABLE_SPICY_SSL BOOL true 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) --disable-af-packet)
append_cache_entry DISABLE_AF_PACKET BOOL true append_cache_entry DISABLE_AF_PACKET BOOL true
;; ;;

View file

@ -564,6 +564,24 @@ target_compile_definitions(zeek_objs PRIVATE ZEEK_CONFIG_SKIP_VERSION_H)
add_dependencies(zeek_objs zeek_autogen_files) add_dependencies(zeek_objs zeek_autogen_files)
zeek_target_link_libraries(zeek_objs) 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) if (HAVE_SPICY)
target_link_libraries(zeek_objs PRIVATE hilti spicy) target_link_libraries(zeek_objs PRIVATE hilti spicy)
prefer_configured_spicy_include_dirs(zeek_objs) prefer_configured_spicy_include_dirs(zeek_objs)