set(_internal_sources
	"${CMAKE_CURRENT_SOURCE_DIR}/../common/src/Common.cpp"
	src/InternalStore.cpp)

add_library(EchoionUrlShortenerInternalPlugin MODULE
	${_internal_sources}
	src/Plugin.cpp)
target_include_directories(EchoionUrlShortenerInternalPlugin PRIVATE
	"${CMAKE_CURRENT_SOURCE_DIR}/include"
	"${CMAKE_CURRENT_SOURCE_DIR}/../common/include")
target_compile_features(EchoionUrlShortenerInternalPlugin PRIVATE cxx_std_26)
target_link_libraries(EchoionUrlShortenerInternalPlugin PRIVATE
	Echoion::ApiPlugin
	Echoion::ApiConfig
	Void::ShortUrl
	Void::Data
	Void::Net
	Void::Text
	Void::Sqlite
	Void::Crypto
	OpenSSL::Crypto)
set_target_properties(EchoionUrlShortenerInternalPlugin PROPERTIES
	PREFIX ""
	OUTPUT_NAME "url-shortener-internal"
	LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins"
	RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins"
	BUILD_RPATH_USE_ORIGIN ON
	INSTALL_RPATH ""
	INSTALL_RPATH_USE_LINK_PATH FALSE)

if(MSVC)
	target_compile_options(EchoionUrlShortenerInternalPlugin PRIVATE /W4 /WX-)
else()
	target_compile_options(EchoionUrlShortenerInternalPlugin PRIVATE
		-Wall -Wextra -Wpedantic)
endif()

install(TARGETS EchoionUrlShortenerInternalPlugin
	LIBRARY DESTINATION
		"${CMAKE_INSTALL_DATADIR}/echoion/bootstrap-plugins/url-shortener-internal/${ECHOION_URL_SHORTENER_INTERNAL_VERSION}"
		COMPONENT Runtime
	RUNTIME DESTINATION
		"${CMAKE_INSTALL_DATADIR}/echoion/bootstrap-plugins/url-shortener-internal/${ECHOION_URL_SHORTENER_INTERNAL_VERSION}"
		COMPONENT Runtime)

if(BUILD_TESTS)
	add_executable(echoion_url_shortener_internal_tests
		${_internal_sources}
		tests/InternalStoreTests.cpp)
	target_include_directories(echoion_url_shortener_internal_tests PRIVATE
		"${CMAKE_CURRENT_SOURCE_DIR}/include"
		"${CMAKE_CURRENT_SOURCE_DIR}/../common/include")
	target_compile_features(echoion_url_shortener_internal_tests PRIVATE
		cxx_std_26)
	target_link_libraries(echoion_url_shortener_internal_tests PRIVATE
		Void::Data Void::Net Void::Text Void::Sqlite Void::Crypto
		OpenSSL::Crypto Threads::Threads)
	add_test(NAME echoion_url_shortener_internal_tests
		COMMAND echoion_url_shortener_internal_tests)
	set_tests_properties(echoion_url_shortener_internal_tests PROPERTIES
		TIMEOUT 20)
endif()
