zeek/src/plugins.cc.in
Robin Sommer 8e7ef001b3 A work-around for supporting plugins compiled as *.a.
This is for older CMakes which don't understand object libraries yet.
We auto-generate a file at the top-level that references all the
global plugin objects. Once they are referenced, the linker includes
them into the final executable and their ctors run to register them
with the plugin manager.

By default this is on. Once we can require more recent CMakes, we can
turn it off (and remove) in src/CMakeLists.txt.
2013-06-02 19:36:25 -07:00

22 lines
624 B
C++

// A work-around the problem that for static libraries unused globals
// aren't linked into the final binary. CMake automatically inserts
// code here to reference the globals that initializes each of the
// statically compiled plugins.
//
// Note: This won't be necessary anymore once we can assume CMake >2.8.8
// as a required depencendy. If so, switch bro_HAVE_OBJECT_LIBRARIES
// in src/CMakeLists.txt to TRUE and remove this.
#include <stdlib.h>
${__BRO_DECL_PLUGINS}
size_t __make_sure_to_use_plugin_globals()
{
// This function is never actually called.
size_t i = 0;
${__BRO_USE_PLUGINS}
return i;
}