# build libpacket_inject.so
add_library(packet_inject SHARED packet_inject.cpp)
target_link_libraries(packet_inject toml)
target_include_directories(packet_inject PUBLIC ${CMAKE_SOURCE_DIR}/include/)
set_target_properties(packet_inject 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)
    target_include_directories(${EXEC_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include/)
    target_link_libraries(${EXEC_NAME} PRIVATE "-rdynamic")
    target_link_libraries(${EXEC_NAME} PRIVATE stellar_devel 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/)