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})
@ -1496,6 +1498,9 @@ message(
"\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)