project(editScene)
set(CMAKE_CXX_STANDARD 17)

find_package(OGRE REQUIRED COMPONENTS Bites Overlay CONFIG)
find_package(flecs REQUIRED CONFIG)
find_package(nlohmann_json REQUIRED)
find_package(SDL2 REQUIRED)

# Collect all source files
set(EDITSCENE_SOURCES
	main.cpp
	EditorApp.cpp
	systems/EditorUISystem.cpp
	systems/SceneSerializer.cpp
	ui/TransformEditor.cpp
	ui/RenderableEditor.cpp
	camera/EditorCamera.cpp
	gizmo/Gizmo.cpp
)

set(EDITSCENE_HEADERS
	EditorApp.hpp
	components/Transform.hpp
	components/Renderable.hpp
	components/EntityName.hpp
	components/Relationship.hpp
	systems/EditorUISystem.hpp
	systems/SceneSerializer.hpp
	ui/ComponentEditor.hpp
	ui/ComponentRegistry.hpp
	ui/TransformEditor.hpp
	ui/RenderableEditor.hpp
	camera/EditorCamera.hpp
	gizmo/Gizmo.hpp
)

add_executable(editSceneEditor ${EDITSCENE_SOURCES} ${EDITSCENE_HEADERS})

target_link_libraries(editSceneEditor
	OgreMain
	OgreBites
	OgreOverlay
	flecs::flecs_static
	nlohmann_json::nlohmann_json
)

target_include_directories(editSceneEditor PRIVATE
	${CMAKE_CURRENT_SOURCE_DIR}
)

# Copy local resources (materials, etc.)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/resources")
	file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/resources"
		DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
endif()

# Copy resources from main build
add_custom_command(TARGET editSceneEditor POST_BUILD
	COMMAND ${CMAKE_COMMAND} -E copy_directory
	"${CMAKE_BINARY_DIR}/resources"
	"${CMAKE_CURRENT_BINARY_DIR}/resources"
	COMMAND ${CMAKE_COMMAND} -E copy
	"${CMAKE_CURRENT_SOURCE_DIR}/resources.cfg"
	"${CMAKE_CURRENT_BINARY_DIR}/resources.cfg"
	COMMENT "Copying resources to editSceneEditor build directory"
)
