#StrictCompile()

add_library(bongomsgapi SHARED
	msgaddr.c
	msgapi.c
	msgauth.c
	msgcollector.c
	msgdate.c
	msghttp.c
	sqldb.c
	../connio/nmap.c
	../util/bongoagent.c
	../util/config-integer.c
)

target_link_libraries(bongomsgapi PRIVATE
	bongoxpl
	bongocal
	bongojson
	bongoutil
	bongoconnio
	SQLite3::SQLite3
	LibIcal::ical
	CURL::libcurl
	GLib2::GLib2
	Threads::Threads
)

install(TARGETS bongomsgapi DESTINATION ${LIB_INSTALL_DIR})

if(BUILD_TESTING)
	add_executable(msgapi-sqldb-transaction-test
		tests/sqldb-transaction-test.c)
	if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
		target_link_options(msgapi-sqldb-transaction-test PRIVATE
			"LINKER:--no-as-needed")
	endif()
	target_link_libraries(msgapi-sqldb-transaction-test PRIVATE
		bongomsgapi
		bongocal
		bongojson
		bongoutil
		bongoxpl
		SQLite3::SQLite3
		Threads::Threads)
	add_test(NAME msgapi-sqldb-transactions
		COMMAND msgapi-sqldb-transaction-test)
	set_tests_properties(msgapi-sqldb-transactions PROPERTIES TIMEOUT 30)

	add_executable(msgapi-time64-test tests/msgdate-time64-test.c)
	target_link_libraries(msgapi-time64-test PRIVATE bongomsgapi)
	add_test(NAME msgapi-time64 COMMAND msgapi-time64-test)

	add_executable(msgapi-http-address-test tests/msghttp-address-test.c)
	target_link_libraries(msgapi-http-address-test PRIVATE bongomsgapi)
	add_test(NAME msgapi-http-address COMMAND msgapi-http-address-test)
endif()

add_subdirectory(auth-backends)
