Clean up ZEEK_CONFIG_SKIP_VERSION_H issues

This commit is contained in:
Dominik Charousset 2023-05-08 18:05:56 +02:00
parent 49b01c3867
commit 986834dce7
2 changed files with 17 additions and 4 deletions

View file

@ -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 $<BUILD_INTERFACE:zeek_internal>)
add_clang_tidy_files(${FN_ARGS_SOURCES})

View file

@ -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