diff --git a/CMakeLists.txt b/CMakeLists.txt index 43952dc00d..a84c1eb7fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,6 +192,9 @@ set_target_properties(zeek_internal PROPERTIES EXPORT_NAME Internal) install(TARGETS zeek_internal EXPORT ZeekTargets) target_compile_features(zeek_internal INTERFACE ${ZEEK_CXX_STD}) +# Skip "link-time version check" in Plugin.h for plugins that we bake in. +target_compile_definitions(zeek_internal INTERFACE ZEEK_PLUGIN_SKIP_VERSION_CHECK) + # Target for bundling the creation of auto-generated files. add_custom_target(zeek_autogen_files) @@ -242,6 +245,13 @@ if ( ZEEK_ENABLE_FUZZERS ) set(zeek_fuzzer_shared_access PUBLIC) endif () +# Set ZEEK_CONFIG_SKIP_VERSION_H for our main in-source targets. +foreach (name zeek_exe zeek_lib zeek_fuzzer_shared) + if (TARGET ${name}) + target_compile_definitions(${name} PRIVATE ZEEK_CONFIG_SKIP_VERSION_H) + endif () +endforeach() + # 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) @@ -343,6 +353,7 @@ function(zeek_add_subdir_library name) # Create target and add the sources. set(target_name "zeek_${name}_obj") add_library(${target_name} OBJECT ${FN_ARGS_SOURCES}) + target_compile_definitions(${target_name} PRIVATE ZEEK_CONFIG_SKIP_VERSION_H) add_dependencies(${target_name} zeek_autogen_files) target_link_libraries(${target_name} PRIVATE $) add_clang_tidy_files(${FN_ARGS_SOURCES}) diff --git a/src/plugin/Plugin.h b/src/plugin/Plugin.h index 85b00e8060..5a4656c87c 100644 --- a/src/plugin/Plugin.h +++ b/src/plugin/Plugin.h @@ -130,10 +130,12 @@ public: #endif inline Configuration() __attribute__((always_inline)) { -// Only bake in a ZEEK_PLUGIN_ZEEK_VERSION reference into external -// plugins. The internal ones are in the same binary so the runtime -// link check shouldn't be needed and we can avoid ccache busting. -#if defined(ZEEK_PLUGIN_INTERNAL_BUILD) && ! ZEEK_PLUGIN_INTERNAL_BUILD +// Only bake in a ZEEK_PLUGIN_ZEEK_VERSION reference into external plugins. The +// internal ones are in the same binary so the runtime link check shouldn't be +// needed and we can avoid ccache busting. The define gets set in the +// CMakeLists.txt file for the Zeek::Internal target, which only exists when +// building Zeek itself. +#ifndef ZEEK_PLUGIN_SKIP_VERSION_CHECK bro_version = ZEEK_PLUGIN_ZEEK_VERSION; zeek_version = ZEEK_PLUGIN_ZEEK_VERSION; #endif