option(TURBINE_GBA_EVENT_LOOP_TIMER_BASED "Run event loop on time instead of vsync" OFF)
set(TURBINE_GBA_TIMER_BITS "32" CACHE STRING "Bits for system time (16, 32, 64)")

add_library(Turbine-GBA OBJECT)
target_sources(
	Turbine-GBA PRIVATE
		context.cpp
		clipboard.cpp
		irq.arm.cpp
		turbine.arm.cpp
		turbine.cpp
)

target_compile_definitions(
	Turbine-GBA PRIVATE
		TURBINE_GBA_EVENT_LOOP_TIMER_BASED=$<IF:$<BOOL:${TURBINE_GBA_EVENT_LOOP_TIMER_BASED}>,true,false>
		TURBINE_GBA_TIMER_BITS=${TURBINE_GBA_TIMER_BITS}
)

if(TURBINE_BUILD_TYPE STREQUAL "GBA")
	enable_language(ASM)
	set_source_files_properties(turbine.arm.cpp irq.arm.cpp PROPERTIES COMPILE_FLAGS -marm)
	target_sources(
		Turbine-GBA PRIVATE
			irq.s
	)
	target_link_libraries(Turbine PUBLIC Turbine-GBA)
else()
	target_sources(
		Turbine-GBA PRIVATE
			irqstub.cpp
	)
endif()

target_include_directories(
	Turbine-GBA PUBLIC
		../../include
)

target_link_libraries(
	Turbine-GBA PUBLIC
		TeaGBA
		Keel
)
