set(@PLUGIN_NAME_US@_HEADERS
    "@PLUGIN_NAME@-parser.h"
    "${CMAKE_CURRENT_BINARY_DIR}/@PLUGIN_NAME@-grammar.h"
)

set(@PLUGIN_NAME_US@_SOURCES
    "@PLUGIN_NAME@-plugin.c"
    "@PLUGIN_NAME@-parser.c"
    "${CMAKE_CURRENT_BINARY_DIR}/@PLUGIN_NAME@-grammar.c"
)

generate_y_from_ym(modules/@PLUGIN_NAME@/@PLUGIN_NAME@-grammar)

bison_target(@PLUGIN_NAME@Grammar
    ${CMAKE_CURRENT_BINARY_DIR}/@PLUGIN_NAME@-grammar.y
    ${CMAKE_CURRENT_BINARY_DIR}/@PLUGIN_NAME@-grammar.c
COMPILE_FLAGS ${BISON_FLAGS})

module_switch(ENABLE_@PLUGIN_NAME_US@ "Enable @PLUGIN_NAME@")
if (ENABLE_@PLUGIN_NAME_US@)
  add_library(@PLUGIN_NAME_US@ SHARED ${@PLUGIN_NAME@_SOURCES})
  target_include_directories(@PLUGIN_NAME_US@
    PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
    PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
  )
  target_link_libraries(@PLUGIN_NAME_US@ PRIVATE syslog-ng)

  install(TARGETS @PLUGIN_NAME_US@
  LIBRARY DESTINATION lib/syslog-ng/
  COMPONENT @PLUGIN_NAME_US@)
endif()
