StrictCompile()

add_library(bongotlsrpt SHARED tlsrpt.c)
target_link_libraries(bongotlsrpt PUBLIC
    bongojson
    bongoutil
    SQLite3::SQLite3
    GLib2::GLib2)
install(TARGETS bongotlsrpt DESTINATION ${LIB_INSTALL_DIR})

if(BUILD_TESTING)
    function(tlsrpt_test_dependencies target)
        if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
            target_link_options(${target} PRIVATE "LINKER:--no-as-needed")
        endif()
        target_link_libraries(${target} PRIVATE
            bongotlsrpt bongomsgapi bongocal bongojson bongoutil bongoxpl
            Threads::Threads)
    endfunction()

    add_executable(tlsrpt-policy-test tests/policy-test.c)
    tlsrpt_test_dependencies(tlsrpt-policy-test)
    add_test(NAME tlsrpt-policy COMMAND tlsrpt-policy-test)

    add_executable(tlsrpt-store-test tests/store-test.c)
    tlsrpt_test_dependencies(tlsrpt-store-test)
    add_test(NAME tlsrpt-store COMMAND tlsrpt-store-test)
endif()
