set(TARGETNAME edr_scripts_test_sudo)

find_package(Boost COMPONENTS unit_test_framework REQUIRED)

file(GLOB SOURCE_FILES *.cpp)

add_executable(${TARGETNAME} ${SOURCE_FILES})

if(DEFINED LINUX)
     #TODO: remove below line disable-new-dtags once we recompile dependent packages
     # with runpath enable
    SET(DISABLE_NEW_DTAGS "-Wl,--disable-new-dtags")
    SET(RPATH_LIB_LINK_FLAGS -Wl,-rpath,"${CMAKE_BINARY_DIR}/external_libs")
    SET(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${DISABLE_NEW_DTAGS} ${RPATH_LIB_LINK_FLAGS}")
endif()

add_rpath_for_testing("${TARGETNAME}" "${CMAKE_CURRENT_BINARY_DIR}")


target_compile_options(${TARGETNAME} PRIVATE
    -DUNIT_TESTING)

target_compile_definitions(${TARGETNAME} PRIVATE
    BOOST_TEST_DYN_LINK)

target_link_libraries(${TARGETNAME} PRIVATE
    Boost::unit_test_framework
    test_utils_platform
    Utils)


if(DEFINED LINUX)
    # Add copy of setup_iptable_rules script to directory of this test - required for UTs of setup_iptable_rules.sh
    # clear directory before copying scrips to have only updated scripts
    file(REMOVE_RECURSE "./edr_scripts")
    file(GLOB EDR_SCRIPTS "../setup_iptable_rules.sh")
    file(COPY ${EDR_SCRIPTS} DESTINATION "./edr_scripts")
endif()


add_test(${TARGETNAME} ${TARGETNAME})