set (SRC
	Camera.cpp
	Device.cpp
	EventBuffer.cpp
	Filesystem.cpp
	Font.cpp
	Image.cpp
	MaterialResource.cpp
	ResourceManager.cpp
	Skybox.cpp
	Terrain.cpp
	World.cpp

	TextureResource.cpp
	TextResource.cpp
	ScriptResource.cpp
	ArchiveResourceArchive.cpp
	FileResourceArchive.cpp

	FPSSystem.cpp
	JSONParser.cpp
)

set (HEADERS
	Camera.h
	Config.h
	Crown.h
	Device.h
	EventBuffer.h
	Filesystem.h
	Font.h
	Glyph.h
	Image.h
	MaterialResource.h
	Resource.h
	ResourceManager.h
	ResourceArchive.h
	Skybox.h
	Terrain.h
	World.h

	TextureResource.h
	TextResource.h
	ScriptResource.h
	ArchiveResourceArchive.h
	FileResourceArchive.h

	FPSSystem.h
	JSONParser.h
)

set (CORE_SRC
	core/Log.cpp
)

set (CORE_HEADERS
	core/Types.h
	core/Args.h
	core/Log.h
)

set (BV_SRC
	core/bv/Circle.cpp
	core/bv/Frustum.cpp
	core/bv/Rect.cpp
)

set (BV_HEADERS
	core/bv/Box.h
	core/bv/Circle.h
	core/bv/Frustum.h
	core/bv/Rect.h
	core/bv/Sphere.h
)

set (CONTAINERS_SRC
	core/containers/Generic.cpp
)

set (CONTAINERS_HEADERS
	core/containers/Queue.h
	core/containers/Dictionary.h
	core/containers/Generic.h
	core/containers/List.h
	core/containers/RBTree.h
)

set (MATH_SRC
	core/math/Color4.cpp
	core/math/Mat3.cpp
	core/math/Mat4.cpp
	core/math/MathUtils.cpp
	core/math/Plane.cpp
	core/math/Point2.cpp
	core/math/Quat.cpp
	core/math/Shape.cpp
	core/math/Vec2.cpp
	core/math/Vec3.cpp
	core/math/Vec4.cpp
)

set (MATH_HEADERS
	core/math/Color4.h
	core/math/Interpolation.h
	core/math/Intersection.h
	core/math/Mat3.h
	core/math/Mat4.h
	core/math/MathUtils.h
	core/math/Plane.h
	core/math/Point2.h
	core/math/Quat.h
	core/math/Random.h
	core/math/Ray.h
	core/math/Shape.h
	core/math/Triangle.h
	core/math/Vec2.h
	core/math/Vec3.h
	core/math/Vec4.h
)

set (STREAMS_SRC
	core/streams/FileStream.cpp
	core/streams/MemoryStream.cpp
	core/streams/Stream.cpp
	
	core/streams/BinaryReader.cpp
	core/streams/BinaryWriter.cpp
	core/streams/TextReader.cpp
	core/streams/TextWriter.cpp
)

set (STREAMS_HEADERS
	core/streams/FileStream.h
	core/streams/MemoryStream.h
	core/streams/NullStream.h
	core/streams/Stream.h

	core/streams/BinaryReader.h
	core/streams/BinaryWriter.h
	core/streams/TextReader.h
	core/streams/TextWriter.h
)

set (STRINGS_SRC
)

set (STRINGS_HEADERS
	core/strings/Path.h
	core/strings/String.h
	core/strings/Hash.h
)

set (MEM_SRC
	core/mem/MallocAllocator.cpp
	core/mem/ProxyAllocator.cpp
)

set (MEM_HEADERS
	core/mem/Memory.h
	core/mem/Allocator.h
	core/mem/MallocAllocator.h
	core/mem/ProxyAllocator.h
)

set (COMPRESSORS_SRC
	core/compressors/ZipCompressor.cpp
)

set (COMPRESSORS_HEADERS
	core/compressors/Compressor.h
	core/compressors/ZipCompressor.h
)

set (THREADS_HEADERS
	core/threads/Thread.h
	core/threads/Mutex.h
	core/threads/Cond.h
)

set (THREADS_SRC
)

set (SETTINGS_SRC
	core/settings/IntSetting.cpp
	core/settings/FloatSetting.cpp
)

set (SETTINGS_HEADERS
	core/settings/IntSetting.h
	core/settings/FloatSetting.h
)

set (INPUT_SRC
	input/EventDispatcher.cpp
	input/InputManager.cpp
)

set (INPUT_HEADERS
	input/EventDispatcher.h
	input/InputManager.h
	input/Keyboard.h
	input/KeyCode.h
	input/Mouse.h
	input/Touch.h
)

set (RENDERERS_SRC
	renderers/DebugRenderer.cpp
	renderers/Pixel.cpp
)

set (RENDERERS_HEADERS
	renderers/Renderer.h
	renderers/IndexBuffer.h
	renderers/VertexBuffer.h
	renderers/OcclusionQuery.h
	renderers/Material.h
	renderers/Texture.h
	renderers/DebugRenderer.h
	renderers/Pixel.h
)

set (OS_HEADERS
	os/OS.h
)

set (OS_SRC
	os/OS.cpp
)

set (NETWORK_SRC
	network/BitMessage.cpp
	network/AsyncConnection.cpp
	network/PacketQueue.h
)

set (NETWORK_HEADERS
	network/BitMessage.h
	network/AsyncConnection.h
	network/PacketQueue.h
)

set (CROWN_SOURCES
	${SRC}
	${CORE_SRC}
	${BV_SRC}
	${CONTAINERS_SRC}
	${MATH_SRC}
	${STREAMS_SRC}
	${MEM_SRC}
	${COMPRESSORS_SRC}
	${THREADS_SRC}
	${SETTINGS_SRC}

	${INPUT_SRC}

	${RENDERERS_SRC}

	${NETWORK_SRC}

	${OS_SRC}
)

set (CROWN_HEADERS
	${HEADERS}

	${CORE_HEADERS}
	${BV_HEADERS}
	${CONTAINERS_HEADERS}
	${MATH_HEADERS}
	${STREAMS_HEADERS}
	${MEM_HEADERS}
	${COMPRESSORS_HEADERS}
	${THREADS_HEADERS}
	${SETTINGS_HEADERS}

	${INPUT_HEADERS}

	${RENDERERS_HEADERS}

	${NETWORK_HEADERS}

	${OS_HEADERS}
)

link_libraries(rt z)
add_library(crown SHARED ${CROWN_SOURCES} ${CROWN_HEADERS})

if (CROWN_BUILD_OPENGL)
	target_link_libraries(crown crown-gl)
endif (CROWN_BUILD_OPENGL)

if (CROWN_BUILD_OPENGLES)
	target_link_libraries(crown crown-gles)
endif (CROWN_BUILD_OPENGLES)

if (LINUX)
	target_link_libraries(crown crown-linux-support)
endif (LINUX)

if (WINDOWS)
	target_link_libraries(crown crown-win)
endif (WINDOWS)

configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/Config.h)

install (TARGETS crown DESTINATION lib/${CMAKE_PROJECT_NAME})
install (FILES ${HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME})

install (FILES ${CORE_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core)
install (FILES ${BV_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/bv)
install (FILES ${CONTAINERS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/containers)
install (FILES ${MATH_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/math)
install (FILES ${STREAMS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/streams)
install (FILES ${MEM_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/mem)
install (FILES ${COMPRESSORS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/compressors)
install (FILES ${THREADS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/threads)
install (FILES ${SETTINGS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core/settings)

install (FILES ${INPUT_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/input)

install (FILES ${RENDERERS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/renderers)

install (FILES ${NETWORK_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/network)

install (FILES ${OS_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/os)

