# build packet_injector
add_executable(packet_injector packet_inject_main.cpp packet_inject_plugin.cpp)
target_link_libraries(packet_injector "-rdynamic")
target_link_libraries(packet_injector stellar_core)

# build libpacket_inject_plugin.so
add_library(packet_inject_plugin SHARED packet_inject_plugin.cpp)
target_include_directories(packet_inject_plugin PUBLIC ${CMAKE_SOURCE_DIR}/include/)
set_target_properties(packet_inject_plugin PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_LIST_DIR}/version.map")

# build gtest
function(packet_inject_add_case EXEC_NAME)
    add_executable(${EXEC_NAME} ${EXEC_NAME}.cpp packet_inject_main.cpp packet_inject_plugin.cpp packet_inject_test.cpp)
    target_link_libraries(${EXEC_NAME} "-rdynamic")
    target_link_libraries(${EXEC_NAME} stellar_core gtest)
    gtest_discover_tests(${EXEC_NAME})
endfunction()

include(GoogleTest)
packet_inject_add_case(gtest_inject_tcp_rst_after_recv_syn_ack)
packet_inject_add_case(gtest_inject_tcp_rst_after_recv_sub_ack)
packet_inject_add_case(gtest_inject_tcp_rst_after_recv_c2s_first_payload)
packet_inject_add_case(gtest_inject_tcp_rst_after_recv_s2c_first_payload)
packet_inject_add_case(gtest_inject_tcp_payload_after_recv_c2s_first_payload)
packet_inject_add_case(gtest_inject_tcp_payload_after_recv_s2c_first_payload)
packet_inject_add_case(gtest_inject_tcp_payload_fin_rst_after_recv_c2s_first_payload)

file(COPY ./conf/ DESTINATION ./conf/)
file(COPY ./pcap/ DESTINATION ./pcap/)
file(COPY ./plugin/ DESTINATION ./plugin/)