if(NOT NOSTALGIA_BUILD_TYPE STREQUAL "GBA")
	set(
		NOSTALGIA_CORE_IMPL_SRC
			glfw/clipboard.cpp
			glfw/core.cpp
			glfw/gfx.cpp
			userland/gfx.cpp
			userland/gfx_opengl.cpp
			userland/media.cpp
	)
	set(
		NOSTALGIA_CORE_IMPL_LIBS
			glad
			glfw
			imgui
			OxEvent
			NostalgiaGlUtils
	)
else()
	enable_language(C ASM)
	set_source_files_properties(core.arm.cpp irq.arm.cpp PROPERTIES COMPILE_FLAGS -marm)
	set(
		NOSTALGIA_CORE_IMPL_SRC
			gba/bios.s
			gba/core.arm.cpp
			gba/core.cpp
			gba/gfx.cpp
			gba/irq.arm.cpp
			gba/irq.s
			gba/media.cpp
			gba/panic.cpp
	)
	set(
		NOSTALGIA_CORE_IMPL_LIBS
			GbaStartup
			OxFS
			OxStd
	)
endif()

add_library(
	NostalgiaCore-Common OBJECT
		gfx.cpp
		media.cpp
		typeconv.cpp
		typestore.cpp
)

add_library(
	NostalgiaCore
		${NOSTALGIA_CORE_IMPL_SRC}
)

add_library(
	NostalgiaCore-Headless
		headless/core.cpp
		headless/gfx.cpp
		headless/media.cpp
)

if(NOT MSVC)
	target_compile_options(NostalgiaCore-Common PUBLIC -Wsign-conversion)
endif()

target_link_libraries(
	NostalgiaCore-Common PUBLIC
		OxClaw
		OxFS
)

target_link_libraries(
	NostalgiaCore PUBLIC
		NostalgiaCore-Common
		${NOSTALGIA_CORE_IMPL_LIBS}
)

target_link_libraries(
	NostalgiaCore-Headless PUBLIC
		NostalgiaCore-Common
)

if(NOSTALGIA_BUILD_STUDIO)
	add_subdirectory(studio)
endif()

install(
	FILES
		assetmanager.hpp
		clipboard.hpp
		color.hpp
		config.hpp
		consts.hpp
		context.hpp
		core.hpp
		event.hpp
		gfx.hpp
		input.hpp
		media.hpp
		typeconv.hpp
		typestore.hpp
	DESTINATION
		include/nostalgia/core
)

install(
	TARGETS
		NostalgiaCore
		NostalgiaCore-Headless
	DESTINATION
		LIBRARY DESTINATION lib/nostalgia
		ARCHIVE DESTINATION lib/nostalgia
)
