add_library(bongostreamio SHARED
	streamio.c
	search.c
	bongostream.c)

target_link_libraries(bongostreamio PRIVATE
	bongoutil
	GLib2::GLib2
)

install(TARGETS bongostreamio DESTINATION ${LIB_INSTALL_DIR})

if(BUILD_TESTING)
	add_executable(streamio-search-test tests/search-test.c)
	add_executable(streamio-codec-boundary-test tests/codec-boundary-test.c)
	if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
		target_link_options(streamio-search-test PRIVATE "LINKER:--no-as-needed")
		target_link_options(streamio-codec-boundary-test PRIVATE "LINKER:--no-as-needed")
	endif()
	target_link_libraries(streamio-search-test PRIVATE
		bongostreamio
		bongoxpl
		bongoconnio
		bongoutil
		bongojson
		bongomsgapi
		GnuTLS::GnuTLS
		Threads::Threads)
	target_link_libraries(streamio-codec-boundary-test PRIVATE
		bongostreamio
		bongoxpl
		bongoconnio
		bongoutil
		bongojson
		bongomsgapi
		GnuTLS::GnuTLS
		Threads::Threads)
	add_test(NAME streamio-search COMMAND streamio-search-test)
	add_test(NAME streamio-codec-boundaries COMMAND streamio-codec-boundary-test)
endif()
