<commit_before>cmake_minimum_required(VERSION 2.8)

# detect architecture
if (CROWN_ARCH MATCHES "x86")
	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/x86)
endif (CROWN_ARCH MATCHES "x86")

if (CROWN_ARCH MATCHES "x86_64")
	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/x86_64)
endif (CROWN_ARCH MATCHES "x86_64")

if (CROWN_ARCH MATCHES "win32")
	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/win32)
endif (CROWN_ARCH MATCHES "win32")

if (CROWN_ARCH MATCHES "win64")
	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/win64)
endif (CROWN_ARCH MATCHES "win64")

if (CROWN_ARCH MATCHES "ARMv7")
	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/ARMv7)
endif (CROWN_ARCH MATCHES "ARMv7")

# architecture dependent includes
set (CROWN_THIRD_INCLUDES
	${CROWN_THIRD}/luajit/include/luajit-2.0
	${CROWN_THIRD}/glew-1.9.0/include
	${CROWN_THIRD}/zlib/include
	${CROWN_THIRD}/oggvorbis/include
	${CROWN_THIRD}/openAL/include
	${CROWN_THIRD}/physx/include
	${CROWN_THIRD}/physx/include/common
	${CROWN_THIRD}/physx/include/characterkinematic
	${CROWN_THIRD}/physx/include/cloth
	${CROWN_THIRD}/physx/include/common
	${CROWN_THIRD}/physx/include/cooking
	${CROWN_THIRD}/physx/include/extensions
	${CROWN_THIRD}/physx/include/foundation
	${CROWN_THIRD}/physx/include/geometry
	${CROWN_THIRD}/physx/include/particles
	${CROWN_THIRD}/physx/include/physxprofilesdk
	${CROWN_THIRD}/physx/include/physxvisualdebuggersdk
	${CROWN_THIRD}/physx/include/pvd
	${CROWN_THIRD}/physx/include/pxtask
	${CROWN_THIRD}/physx/include/RepX
	${CROWN_THIRD}/physx/include/RepXUpgrader
	${CROWN_THIRD}/physx/include/vehicle
)

# architecture dependent libraries
set (CROWN_THIRD_LIBS
	${CROWN_THIRD}/luajit/lib
	${CROWN_THIRD}/glew-1.9.0/lib
	${CROWN_THIRD}/zlib/lib
	${CROWN_THIRD}/oggvorbis/lib
	${CROWN_THIRD}/openAL/lib
	${CROWN_THIRD}/physx/lib
)

add_subdirectory(${CROWN_THIRD})

# platform independent includes
set (CROWN_INCLUDES
	${CMAKE_SOURCE_DIR}/engine
	${CMAKE_SOURCE_DIR}/engine/core
	${CMAKE_SOURCE_DIR}/engine/core/bv
	${CMAKE_SOURCE_DIR}/engine/core/containers
	${CMAKE_SOURCE_DIR}/engine/core/math
	${CMAKE_SOURCE_DIR}/engine/core/mem
	${CMAKE_SOURCE_DIR}/engine/core/compressors
	${CMAKE_SOURCE_DIR}/engine/core/filesystem
	${CMAKE_SOURCE_DIR}/engine/core/json
	${CMAKE_SOURCE_DIR}/engine/core/strings
	${CMAKE_SOURCE_DIR}/engine/core/settings
	${CMAKE_SOURCE_DIR}/engine/os
	${CMAKE_SOURCE_DIR}/engine/input
	${CMAKE_SOURCE_DIR}/engine/renderers
	${CMAKE_SOURCE_DIR}/engine/resource
	${CMAKE_SOURCE_DIR}/engine/rpc
	${CMAKE_SOURCE_DIR}/engine/network
	${CMAKE_SOURCE_DIR}/engine/lua
	${CMAKE_SOURCE_DIR}/engine/audio
	${CMAKE_SOURCE_DIR}/engine/compilers
	${CMAKE_SOURCE_DIR}/engine/compilers/lua
	${CMAKE_SOURCE_DIR}/engine/compilers/texture
	${CMAKE_SOURCE_DIR}/engine/compilers/sound
	${CMAKE_SOURCE_DIR}/engine/compilers/mesh
	${CMAKE_SOURCE_DIR}/engine/compilers/package
	${CMAKE_SOURCE_DIR}/engine/compilers/unit
	${CMAKE_SOURCE_DIR}/engine/compilers/sprite
)

set (SRC
	Camera.cpp
	Device.cpp
	World.cpp
	Unit.cpp
	SceneGraph.cpp
	SceneGraphManager.cpp
	RenderWorld.cpp
	Mesh.cpp
	Sprite.cpp
)

set (HEADERS
	Camera.h
	Config.h
	Crown.h
	Device.h
	World.h
	Unit.h
	SceneGraph.h
	SceneGraphManager.h
	RenderWorld.h
	Mesh.h
	Sprite.h
	SpriteAnimator.h
)

set (CORE_SRC
	core/Log.cpp
	core/Args.cpp
)

set (CORE_HEADERS
	core/Assert.h
	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
)

set (CONTAINERS_HEADERS
	core/containers/Queue.h
	core/containers/PriorityQueue.h
	core/containers/Map.h
	core/containers/List.h
	core/containers/Vector.h
	core/containers/RBTree.h
	core/containers/IdTable.h
	core/containers/IdArray.h
	core/containers/EventStream.h
)

set (MATH_SRC
	core/math/Color4.cpp
	core/math/Matrix3x3.cpp
	core/math/Matrix4x4.cpp
	core/math/Plane.cpp
	core/math/Quaternion.cpp
	core/math/Vector2.cpp
	core/math/Vector3.cpp
	core/math/Vector4.cpp
)

set (MATH_HEADERS
	core/math/Color4.h
	core/math/Interpolation.h
	core/math/Intersection.h
	core/math/Matrix3x3.h
	core/math/Matrix4x4.h
	core/math/MathUtils.h
	core/math/Plane.h
	core/math/Quaternion.h
	core/math/Random.h
	core/math/Ray.h
	core/math/Triangle.h
	core/math/Vector2.h
	core/math/Vector3.h
	core/math/Vector4.h
)

set (FILESYSTEM_SRC
	core/filesystem/File.cpp
	core/filesystem/DiskFile.cpp
	core/filesystem/DiskFilesystem.cpp
)

set (FILESYSTEM_HEADERS
	core/filesystem/File.h
	core/filesystem/NullFile.h
	core/filesystem/DiskFile.h
	core/filesystem/BinaryReader.h
	core/filesystem/BinaryWriter.h
	core/filesystem/TextReader.h
	core/filesystem/TextWriter.h
	core/filesystem/Filesystem.h
	core/filesystem/DiskFilesystem.h
)

set (JSON_SRC
	core/json/JSON.cpp
	core/json/JSONParser.cpp
)

set (JSON_HEADERS
	core/json/JSON.h
	core/json/JSONParser.h
)

set (STRINGS_SRC
)

set (STRINGS_HEADERS
	core/strings/Path.h
	core/strings/StringUtils.h
	core/strings/StringStream.h
	core/strings/Hash.h
	core/strings/DynamicString.h
)

set (MEM_SRC
	core/mem/Memory.cpp
	core/mem/HeapAllocator.cpp
	core/mem/LinearAllocator.cpp
	core/mem/StackAllocator.cpp
	core/mem/ProxyAllocator.cpp
	core/mem/PoolAllocator.cpp
)

set (MEM_HEADERS
	core/mem/Memory.h
	core/mem/Allocator.h
	core/mem/HeapAllocator.h
	core/mem/TempAllocator.h
	core/mem/LinearAllocator.h
	core/mem/StackAllocator.h
	core/mem/ProxyAllocator.h
	core/mem/PoolAllocator.h
)

set (COMPRESSORS_SRC
	core/compressors/ZipCompressor.cpp
)

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

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

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

set (INPUT_SRC
)

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

set (NETWORK_SRC
	network/BitMessage.cpp
)

set (NETWORK_HEADERS
	network/BitMessage.h
)

set (RENDERERS_SRC
)

set (RENDERERS_HEADERS
	renderers/Renderer.h
	renderers/RenderContext.h
	renderers/PixelFormat.h
	renderers/VertexFormat.h
)

set (RESOURCE_SRC
	resource/ResourceLoader.cpp
	resource/ResourceManager.cpp
	resource/ResourceRegistry.cpp
)

if (CROWN_DEBUG OR CROWN_DEVELOPMENT)
	list (APPEND RESOURCE_SRC resource/FileBundle.cpp)
elseif (CROWN_RELEASE)
	list (APPEND RESOURCE_SRC resource/ArchiveBundle.cpp)
else ()
	message (FATAL_ERROR "Oops, you should not be here")
endif (CROWN_DEBUG OR CROWN_DEVELOPMENT)

set (RESOURCE_HEADERS
	resource/Resource.h
	resource/ResourceFormat.h
	resource/ResourceLoader.h
	resource/ResourceManager.h
	resource/ResourceRegistry.h
	resource/Bundle.h
	resource/LuaResource.h
	resource/TextureResource.h
	resource/MeshResource.h
	resource/FontResource.h
	resource/SoundResource.h
	resource/MaterialResource.h
	resource/PackageResource.h
	resource/UnitResource.h
	resource/ResourcePackage.h
	resource/SpriteResource.h
)

set (RPC_SRC
	rpc/RPCHandler.cpp
	rpc/RPCServer.cpp
)

set (RPC_HEADERS
	rpc/RPCServer.h
	rpc/RPCHandler.h
)

set (OS_SRC
)

set (OS_HEADERS
	os/OS.h
	os/OsEventQueue.h
	os/NetAddress.h
	os/OsTypes.h
	os/ScopedMutex.h
)

set (LUA_SRC
	lua/LuaStack.cpp
	lua/LuaEnvironment.cpp
	lua/LuaIntSetting.cpp
	lua/LuaFloatSetting.cpp
	lua/LuaStringSetting.cpp
	lua/LuaVector2.cpp
	lua/LuaVector3.cpp
	lua/LuaMatrix4x4.cpp
	lua/LuaQuaternion.cpp
	lua/LuaMath.cpp
	lua/LuaMouse.cpp
	lua/LuaKeyboard.cpp
	lua/LuaAccelerometer.cpp
	lua/LuaDevice.cpp
	lua/LuaWindow.cpp
	lua/LuaResourcePackage.cpp
	lua/LuaWorld.cpp
	lua/LuaUnit.cpp
	lua/LuaCamera.cpp
	lua/LuaMesh.cpp
	lua/LuaSprite.cpp
)

set (LUA_HEADERS
	lua/LuaStack.h
	lua/LuaEnvironment.h
)

set (AUDIO_SRC)

set (AUDIO_HEADERS
	audio/SoundRenderer.h
	audio/OggDecoder.h
)

set (COMPILER_SRC
	compilers/Compiler.cpp
	compilers/BundleCompiler.cpp
	compilers/mesh/MeshCompiler.cpp
	compilers/lua/LuaCompiler.cpp
	compilers/texture/TextureCompiler.cpp
	compilers/sound/SoundCompiler.cpp
	compilers/package/PackageCompiler.cpp
	compilers/unit/UnitCompiler.cpp
	compilers/sprite/SpriteCompiler.cpp
)

set (COMPILER_HEADER
	compilers/Compiler.h
	compilers/BundleCompiler.h
	compilers/mesh/MeshCompiler.h
	compilers/lua/LuaCompiler.h
	compilers/texture/TextureCompiler.h
	compilers/sound/SoundCompiler.h
	compilers/package/PackageCompiler.h
	compilers/unit/UnitCompiler.h
	compilers/sprite/SpriteCompiler.h
)

set (CROWN_LIBRARIES)

# Platform specific stuff
if (LINUX)
	list (APPEND CROWN_INCLUDES
		${CMAKE_SOURCE_DIR}/engine/os/linux
		${CMAKE_SOURCE_DIR}/engine/renderers/gl/glx
		${CMAKE_SOURCE_DIR}/engine/renderers/al
	)

	list (APPEND OS_HEADERS
		os/linux/OsWindow.h
		os/linux/OsFile.h
		os/linux/OsThread.h
		os/linux/Mutex.h
		os/linux/Cond.h
		os/posix/Semaphore.h
	)

	list (APPEND OS_SRC
		os/linux/LinuxOS.cpp
		os/linux/OsWindow.cpp
		os/posix/OsFile.cpp
	)

	list (APPEND RENDERERS_SRC
		renderers/gl/GLRenderer.cpp
		renderers/gl/glx/GLContext.cpp
	)

	list (APPEND RENDERERS_HEADERS
		renderers/gl/GLRenderer.h
		renderers/gl/glx/GLContext.h
	)

	list (APPEND AUDIO_SRC
		audio/al/ALRenderer.cpp
	)

	list (APPEND AUDIO_HEADERS
		audio/al/ALRenderer.h
	)

	list (APPEND CROWN_LIBRARIES
		rt
		z
		X11
		Xrandr
		pthread
		dl
		GLEW
		GL
		openal
		vorbisfile
		luajit-5.1

		PhysX3
		SimulationController
		LowLevel
		LowLevelCloth
		PxTask
		PhysXProfileSDK
		PhysX3Extensions
		SceneQuery
		PhysX3Common
		PhysX3CharacterKinematic
		PhysX3Vehicle
		PhysX3Cooking
		PvdRuntime
		RepX3
	)

	set (COMPILER_FLAGS
		-pipe
		-std=c++03
		-ansi
		#-pedantic-errors
		-Wall
		-Wextra
		#-Werror
		-Wno-long-long
		-Wno-variadic-macros
		-Wno-unknown-pragmas
		-Wno-unused-parameter
		-Wno-unused-local-typedefs
		-fPIC
		#-fvisibility=hidden
	)

	if (CROWN_DEBUG)
		list (APPEND COMPILER_FLAGS -g -pg -D_DEBUG)
	elseif (CROWN_DEVELOPMENT)
		list (APPEND COMPILER_FLAGS -O2 -DNDEBUG)
	elseif (CROWN_RELEASE)
		list (APPEND COMPILER_FLAGS
			-DNDEBUG
			-O2
			-Wno-unused-variable
			-Wno-unused-parameter
			-Wno-maybe-uninitialized
			-Wno-unused-but-set-variable
			-Wno-unused-function
		)
	else ()
		message (FATAL_ERROR "Oops, you should not be here")
	endif (CROWN_DEBUG)

	set (CROWN_MAIN_SRC os/linux/main.cpp)
endif (LINUX)

if (WINDOWS)
	list (APPEND CROWN_INCLUDES
		${CMAKE_SOURCE_DIR}/engine/os/win
		${CMAKE_SOURCE_DIR}/engine/renderers/gl/wgl
	)

	list (APPEND OS_HEADERS
		os/win/OsFile.h
		os/win/OsThread.h
		os/win/OsSocket.h
		os/win/OsWindow.h
		os/win/Mutex.h
		os/win/Cond.h
		os/win/Semaphore.h
		os/win/AtomicInt.h
		os/win/inttypes.h
	)

	list (APPEND OS_SRC
		os/win/WinOS.cpp
		os/win/OsFile.cpp
		os/win/OsWindow.cpp
	)

	list (APPEND RENDERERS_SRC
		renderers/gl/GLRenderer.cpp
		renderers/gl/wgl/GLContext.cpp
	)

	list (APPEND RENDERERS_HEADERS
		renderers/gl/GLRenderer.h
		renderers/gl/wgl/GLContext.h
		renderers/gl/wgl/wglext.h
	)

	list (APPEND AUDIO_SRC
		audio/al/ALRenderer.cpp
	)

	list (APPEND AUDIO_HEADERS
		audio/al/ALRenderer.h
	)

	list (APPEND CROWN_LIBRARIES
		zlib
		OpenGL32
		glew32
		lua51
		OpenAL32
		libvorbis
		libvorbisfile
	)

	set (COMPILER_FLAGS
	)

	set (CROWN_MAIN_SRC os/win/main.cpp)
endif(WINDOWS)

set (CROWN_SOURCES
	${SRC}
	${CORE_SRC}
	${BV_SRC}
	${CONTAINERS_SRC}
	${MATH_SRC}
	${FILESYSTEM_SRC}
	${JSON_SRC}
	${MEM_SRC}
	${COMPRESSORS_SRC}
	${SETTINGS_SRC}
	${INPUT_SRC}
	${RENDERERS_SRC}
	${RESOURCE_SRC}
	${RPC_SRC}
#	${NETWORK_SRC}
	${OS_SRC}
	${LUA_SRC}
	${AUDIO_SRC}
	${COMPILER_SRC}
)

set (CROWN_HEADERS
	${HEADERS}
	${CORE_HEADERS}
	${BV_HEADERS}
	${CONTAINERS_HEADERS}
	${MATH_HEADERS}
	${FILESYSTEM_HEADERS}
	${JSON_HEADERS}
	${MEM_HEADERS}
	${COMPRESSORS_HEADERS}
	${SETTINGS_HEADERS}
	${INPUT_HEADERS}
	${RENDERERS_HEADERS}
	${RESOURCE_HEADERS}
	${RPC_HEADERS}
#	${NETWORK_HEADERS}
	${OS_HEADERS}
	${LUA_HEADERS}
	${AUDIO_HEADERS}
	${COMPILER_HEADERS}
)

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

include_directories(${CROWN_INCLUDES} ${CROWN_THIRD_INCLUDES})
link_directories(${CROWN_THIRD_LIBS})
link_libraries(${CROWN_LIBRARIES})

add_definitions(${COMPILER_FLAGS})

add_library(crown SHARED ${CROWN_SOURCES} ${CROWN_HEADERS})

set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:$ORIGIN")
add_executable(${CROWN_EXECUTABLE_NAME} ${CROWN_MAIN_SRC})
target_link_libraries(${CROWN_EXECUTABLE_NAME} crown)

if (CROWN_BUILD_TESTS)
	add_subdirectory(tests)
endif (CROWN_BUILD_TESTS)


install (TARGETS crown DESTINATION bin)
install (TARGETS ${CROWN_EXECUTABLE_NAME} DESTINATION bin)

install (TARGETS crown DESTINATION test)

#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)<commit_msg>update cmake file, TODO: fix errors and test<commit_after>cmake_minimum_required(VERSION 2.8)

# detect architecture
if (CROWN_ARCH MATCHES "x86")
	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/x86)
endif (CROWN_ARCH MATCHES "x86")

if (CROWN_ARCH MATCHES "x86_64")
	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/x86_64)
endif (CROWN_ARCH MATCHES "x86_64")

if (CROWN_ARCH MATCHES "win32")
	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/win32)
endif (CROWN_ARCH MATCHES "win32")

if (CROWN_ARCH MATCHES "win64")
	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/win64)
endif (CROWN_ARCH MATCHES "win64")

if (CROWN_ARCH MATCHES "ARMv7")
	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/ARMv7)
endif (CROWN_ARCH MATCHES "ARMv7")

# architecture dependent includes
set (CROWN_THIRD_INCLUDES
	${CROWN_THIRD}/luajit/include/luajit-2.0
	${CROWN_THIRD}/glew-1.9.0/include
	${CROWN_THIRD}/zlib/include
	${CROWN_THIRD}/oggvorbis/include
	${CROWN_THIRD}/openAL/include
	${CROWN_THIRD}/physx/include
	${CROWN_THIRD}/physx/include/common
	${CROWN_THIRD}/physx/include/characterkinematic
	${CROWN_THIRD}/physx/include/cloth
	${CROWN_THIRD}/physx/include/common
	${CROWN_THIRD}/physx/include/cooking
	${CROWN_THIRD}/physx/include/extensions
	${CROWN_THIRD}/physx/include/foundation
	${CROWN_THIRD}/physx/include/geometry
	${CROWN_THIRD}/physx/include/particles
	${CROWN_THIRD}/physx/include/physxprofilesdk
	${CROWN_THIRD}/physx/include/physxvisualdebuggersdk
	${CROWN_THIRD}/physx/include/pvd
	${CROWN_THIRD}/physx/include/pxtask
	${CROWN_THIRD}/physx/include/RepX
	${CROWN_THIRD}/physx/include/RepXUpgrader
	${CROWN_THIRD}/physx/include/vehicle
)

# architecture dependent libraries
set (CROWN_THIRD_LIBS
	${CROWN_THIRD}/luajit/lib
	${CROWN_THIRD}/glew-1.9.0/lib
	${CROWN_THIRD}/zlib/lib
	${CROWN_THIRD}/oggvorbis/lib
	${CROWN_THIRD}/openAL/lib
	${CROWN_THIRD}/physx/lib
)

add_subdirectory(${CROWN_THIRD})

# platform independent includes
set (CROWN_INCLUDES
	${CMAKE_SOURCE_DIR}/engine
	${CMAKE_SOURCE_DIR}/engine/core
	${CMAKE_SOURCE_DIR}/engine/core/bv
	${CMAKE_SOURCE_DIR}/engine/core/containers
	${CMAKE_SOURCE_DIR}/engine/core/math
	${CMAKE_SOURCE_DIR}/engine/core/mem
	${CMAKE_SOURCE_DIR}/engine/core/compressors
	${CMAKE_SOURCE_DIR}/engine/core/filesystem
	${CMAKE_SOURCE_DIR}/engine/core/json
	${CMAKE_SOURCE_DIR}/engine/core/strings
	${CMAKE_SOURCE_DIR}/engine/core/settings
	${CMAKE_SOURCE_DIR}/engine/os
	${CMAKE_SOURCE_DIR}/engine/input
	${CMAKE_SOURCE_DIR}/engine/renderers
	${CMAKE_SOURCE_DIR}/engine/resource
	${CMAKE_SOURCE_DIR}/engine/rpc
	${CMAKE_SOURCE_DIR}/engine/network
	${CMAKE_SOURCE_DIR}/engine/lua
	${CMAKE_SOURCE_DIR}/engine/audio
	${CMAKE_SOURCE_DIR}/engine/compilers
	${CMAKE_SOURCE_DIR}/engine/compilers/lua
	${CMAKE_SOURCE_DIR}/engine/compilers/texture
	${CMAKE_SOURCE_DIR}/engine/compilers/sound
	${CMAKE_SOURCE_DIR}/engine/compilers/mesh
	${CMAKE_SOURCE_DIR}/engine/compilers/package
	${CMAKE_SOURCE_DIR}/engine/compilers/unit
	${CMAKE_SOURCE_DIR}/engine/compilers/sprite
	${CMAKE_SOURCE_DIR}/engine/physics
)

set (SRC
	Camera.cpp
	Device.cpp
	World.cpp
	Unit.cpp
	SceneGraph.cpp
	SceneGraphManager.cpp
	RenderWorld.cpp
	Mesh.cpp
	Sprite.cpp
)

set (HEADERS
	Camera.h
	Config.h
	Crown.h
	Device.h
	World.h
	Unit.h
	SceneGraph.h
	SceneGraphManager.h
	RenderWorld.h
	Mesh.h
	Sprite.h
	SpriteAnimator.h
)

set (CORE_SRC
	core/Log.cpp
	core/Args.cpp
)

set (CORE_HEADERS
	core/Assert.h
	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
)

set (CONTAINERS_HEADERS
	core/containers/Queue.h
	core/containers/PriorityQueue.h
	core/containers/Map.h
	core/containers/List.h
	core/containers/Vector.h
	core/containers/RBTree.h
	core/containers/IdTable.h
	core/containers/IdArray.h
	core/containers/EventStream.h
)

set (MATH_SRC
	core/math/Color4.cpp
	core/math/Matrix3x3.cpp
	core/math/Matrix4x4.cpp
	core/math/Plane.cpp
	core/math/Quaternion.cpp
	core/math/Vector2.cpp
	core/math/Vector3.cpp
	core/math/Vector4.cpp
)

set (MATH_HEADERS
	core/math/Color4.h
	core/math/Interpolation.h
	core/math/Intersection.h
	core/math/Matrix3x3.h
	core/math/Matrix4x4.h
	core/math/MathUtils.h
	core/math/Plane.h
	core/math/Quaternion.h
	core/math/Random.h
	core/math/Ray.h
	core/math/Triangle.h
	core/math/Vector2.h
	core/math/Vector3.h
	core/math/Vector4.h
)

set (FILESYSTEM_SRC
	core/filesystem/File.cpp
	core/filesystem/DiskFile.cpp
	core/filesystem/DiskFilesystem.cpp
)

set (FILESYSTEM_HEADERS
	core/filesystem/File.h
	core/filesystem/NullFile.h
	core/filesystem/DiskFile.h
	core/filesystem/BinaryReader.h
	core/filesystem/BinaryWriter.h
	core/filesystem/TextReader.h
	core/filesystem/TextWriter.h
	core/filesystem/Filesystem.h
	core/filesystem/DiskFilesystem.h
)

set (JSON_SRC
	core/json/JSON.cpp
	core/json/JSONParser.cpp
)

set (JSON_HEADERS
	core/json/JSON.h
	core/json/JSONParser.h
)

set (STRINGS_SRC
)

set (STRINGS_HEADERS
	core/strings/Path.h
	core/strings/StringUtils.h
	core/strings/StringStream.h
	core/strings/Hash.h
	core/strings/DynamicString.h
)

set (MEM_SRC
	core/mem/Memory.cpp
	core/mem/HeapAllocator.cpp
	core/mem/LinearAllocator.cpp
	core/mem/StackAllocator.cpp
	core/mem/ProxyAllocator.cpp
	core/mem/PoolAllocator.cpp
)

set (MEM_HEADERS
	core/mem/Memory.h
	core/mem/Allocator.h
	core/mem/HeapAllocator.h
	core/mem/TempAllocator.h
	core/mem/LinearAllocator.h
	core/mem/StackAllocator.h
	core/mem/ProxyAllocator.h
	core/mem/PoolAllocator.h
)

set (COMPRESSORS_SRC
	core/compressors/ZipCompressor.cpp
)

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

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

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

set (INPUT_SRC
)

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

set (NETWORK_SRC
	network/BitMessage.cpp
)

set (NETWORK_HEADERS
	network/BitMessage.h
)

set (RENDERERS_SRC
)

set (RENDERERS_HEADERS
	renderers/Renderer.h
	renderers/RenderContext.h
	renderers/PixelFormat.h
	renderers/VertexFormat.h
)

set (RESOURCE_SRC
	resource/ResourceLoader.cpp
	resource/ResourceManager.cpp
	resource/ResourceRegistry.cpp
)

if (CROWN_DEBUG OR CROWN_DEVELOPMENT)
	list (APPEND RESOURCE_SRC resource/FileBundle.cpp)
elseif (CROWN_RELEASE)
	list (APPEND RESOURCE_SRC resource/ArchiveBundle.cpp)
else ()
	message (FATAL_ERROR "Oops, you should not be here")
endif (CROWN_DEBUG OR CROWN_DEVELOPMENT)

set (RESOURCE_HEADERS
	resource/Resource.h
	resource/ResourceFormat.h
	resource/ResourceLoader.h
	resource/ResourceManager.h
	resource/ResourceRegistry.h
	resource/Bundle.h
	resource/LuaResource.h
	resource/TextureResource.h
	resource/MeshResource.h
	resource/FontResource.h
	resource/SoundResource.h
	resource/MaterialResource.h
	resource/PackageResource.h
	resource/UnitResource.h
	resource/ResourcePackage.h
	resource/SpriteResource.h
)

set (RPC_SRC
	rpc/RPCHandler.cpp
	rpc/RPCServer.cpp
)

set (RPC_HEADERS
	rpc/RPCServer.h
	rpc/RPCHandler.h
)

set (OS_SRC
)

set (OS_HEADERS
	os/OS.h
	os/OsEventQueue.h
	os/NetAddress.h
	os/OsTypes.h
	os/ScopedMutex.h
)

set (LUA_SRC
	lua/LuaStack.cpp
	lua/LuaEnvironment.cpp
	lua/LuaIntSetting.cpp
	lua/LuaFloatSetting.cpp
	lua/LuaStringSetting.cpp
	lua/LuaVector2.cpp
	lua/LuaVector3.cpp
	lua/LuaMatrix4x4.cpp
	lua/LuaQuaternion.cpp
	lua/LuaMath.cpp
	lua/LuaMouse.cpp
	lua/LuaKeyboard.cpp
	lua/LuaAccelerometer.cpp
	lua/LuaDevice.cpp
	lua/LuaWindow.cpp
	lua/LuaResourcePackage.cpp
	lua/LuaWorld.cpp
	lua/LuaUnit.cpp
	lua/LuaCamera.cpp
	lua/LuaMesh.cpp
	lua/LuaSprite.cpp
)

set (LUA_HEADERS
	lua/LuaStack.h
	lua/LuaEnvironment.h
)

set (AUDIO_SRC)

set (AUDIO_HEADERS
	audio/SoundRenderer.h
	audio/OggDecoder.h
)

set (PHYSICS_SRC
	physics/PhysicsWorld.cpp
	physics/PhysicsGraphManager.cpp
	physics/PhysicsGraph.cpp
	physics/Actor.cpp
)

set (PHYSICS_HEADERS
	physics/PhysicsTypes.h
	physics/Physics.h
	physics/PhysicsWorld.h
	physics/PhysicsGraphManager.h
	physics/PhysicsGraph.h
	physics/Actor.h
)

set (COMPILER_SRC
	compilers/Compiler.cpp
	compilers/BundleCompiler.cpp
	compilers/mesh/MeshCompiler.cpp
	compilers/lua/LuaCompiler.cpp
	compilers/texture/TextureCompiler.cpp
	compilers/sound/SoundCompiler.cpp
	compilers/package/PackageCompiler.cpp
	compilers/unit/UnitCompiler.cpp
	compilers/sprite/SpriteCompiler.cpp
)

set (COMPILER_HEADER
	compilers/Compiler.h
	compilers/BundleCompiler.h
	compilers/mesh/MeshCompiler.h
	compilers/lua/LuaCompiler.h
	compilers/texture/TextureCompiler.h
	compilers/sound/SoundCompiler.h
	compilers/package/PackageCompiler.h
	compilers/unit/UnitCompiler.h
	compilers/sprite/SpriteCompiler.h
)

set (CROWN_LIBRARIES)

# Platform specific stuff
if (LINUX)
	list (APPEND CROWN_INCLUDES
		${CMAKE_SOURCE_DIR}/engine/os/linux
		${CMAKE_SOURCE_DIR}/engine/renderers/gl/glx
		${CMAKE_SOURCE_DIR}/engine/renderers/al
	)

	list (APPEND OS_HEADERS
		os/linux/OsWindow.h
		os/linux/OsFile.h
		os/linux/OsThread.h
		os/linux/Mutex.h
		os/linux/Cond.h
		os/posix/Semaphore.h
	)

	list (APPEND OS_SRC
		os/linux/LinuxOS.cpp
		os/linux/OsWindow.cpp
		os/posix/OsFile.cpp
	)

	list (APPEND RENDERERS_SRC
		renderers/gl/GLRenderer.cpp
		renderers/gl/glx/GLContext.cpp
	)

	list (APPEND RENDERERS_HEADERS
		renderers/gl/GLRenderer.h
		renderers/gl/glx/GLContext.h
	)

	list (APPEND AUDIO_SRC
		audio/al/ALRenderer.cpp
	)

	list (APPEND AUDIO_HEADERS
		audio/al/ALRenderer.h
	)

	list (APPEND CROWN_LIBRARIES
		rt
		z
		X11
		Xrandr
		pthread
		dl
		GLEW
		GL
		openal
		vorbisfile
		luajit-5.1

		PhysX3
		SimulationController
		LowLevel
		LowLevelCloth
		PxTask
		PhysXProfileSDK
		PhysX3Extensions
		SceneQuery
		PhysX3Common
		PhysX3CharacterKinematic
		PhysX3Vehicle
		PhysX3Cooking
		PvdRuntime
		RepX3
	)

	set (COMPILER_FLAGS
		-pipe
		-std=c++03
		-ansi
		#-pedantic-errors
		-Wall
		-Wextra
		#-Werror
		-Wno-long-long
		-Wno-variadic-macros
		-Wno-unknown-pragmas
		-Wno-unused-parameter
		-Wno-unused-local-typedefs
		-fPIC
		#-fvisibility=hidden
	)

	if (CROWN_DEBUG)
		list (APPEND COMPILER_FLAGS -g -pg -D_DEBUG)
	elseif (CROWN_DEVELOPMENT)
		list (APPEND COMPILER_FLAGS -O2 -DNDEBUG)
	elseif (CROWN_RELEASE)
		list (APPEND COMPILER_FLAGS
			-DNDEBUG
			-O2
			-Wno-unused-variable
			-Wno-unused-parameter
			-Wno-maybe-uninitialized
			-Wno-unused-but-set-variable
			-Wno-unused-function
		)
	else ()
		message (FATAL_ERROR "Oops, you should not be here")
	endif (CROWN_DEBUG)

	set (CROWN_MAIN_SRC os/linux/main.cpp)
endif (LINUX)

if (WINDOWS)
	list (APPEND CROWN_INCLUDES
		${CMAKE_SOURCE_DIR}/engine/os/win
		${CMAKE_SOURCE_DIR}/engine/renderers/gl/wgl
	)

	list (APPEND OS_HEADERS
		os/win/OsFile.h
		os/win/OsThread.h
		os/win/OsSocket.h
		os/win/OsWindow.h
		os/win/Mutex.h
		os/win/Cond.h
		os/win/Semaphore.h
		os/win/AtomicInt.h
		os/win/inttypes.h
	)

	list (APPEND OS_SRC
		os/win/WinOS.cpp
		os/win/OsFile.cpp
		os/win/OsWindow.cpp
	)

	list (APPEND RENDERERS_SRC
		renderers/gl/GLRenderer.cpp
		renderers/gl/wgl/GLContext.cpp
	)

	list (APPEND RENDERERS_HEADERS
		renderers/gl/GLRenderer.h
		renderers/gl/wgl/GLContext.h
		renderers/gl/wgl/wglext.h
	)

	list (APPEND AUDIO_SRC
		audio/al/ALRenderer.cpp
	)

	list (APPEND AUDIO_HEADERS
		audio/al/ALRenderer.h
	)

	list (APPEND CROWN_LIBRARIES
		zlib
		OpenGL32
		glew32
		lua51
		OpenAL32
		libvorbis
		libvorbisfile
	)

	set (COMPILER_FLAGS
	)

	set (CROWN_MAIN_SRC os/win/main.cpp)
endif(WINDOWS)

set (CROWN_SOURCES
	${SRC}
	${CORE_SRC}
	${BV_SRC}
	${CONTAINERS_SRC}
	${MATH_SRC}
	${FILESYSTEM_SRC}
	${JSON_SRC}
	${MEM_SRC}
	${COMPRESSORS_SRC}
	${SETTINGS_SRC}
	${INPUT_SRC}
	${RENDERERS_SRC}
	${RESOURCE_SRC}
	${RPC_SRC}
	${OS_SRC}
	${LUA_SRC}
	${AUDIO_SRC}
	${PHYSICS_SRC}
	${COMPILER_SRC}
)

set (CROWN_HEADERS
	${HEADERS}
	${CORE_HEADERS}
	${BV_HEADERS}
	${CONTAINERS_HEADERS}
	${MATH_HEADERS}
	${FILESYSTEM_HEADERS}
	${JSON_HEADERS}
	${MEM_HEADERS}
	${COMPRESSORS_HEADERS}
	${SETTINGS_HEADERS}
	${INPUT_HEADERS}
	${RENDERERS_HEADERS}
	${RESOURCE_HEADERS}
	${RPC_HEADERS}
	${OS_HEADERS}
	${LUA_HEADERS}
	${AUDIO_HEADERS}
	${PHYSICS_HEADERS}
	${COMPILER_HEADERS}
)

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

include_directories(${CROWN_INCLUDES} ${CROWN_THIRD_INCLUDES})
link_directories(${CROWN_THIRD_LIBS})
link_libraries(${CROWN_LIBRARIES})

add_definitions(${COMPILER_FLAGS})

add_library(crown SHARED ${CROWN_SOURCES} ${CROWN_HEADERS})

set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:$ORIGIN")
add_executable(${CROWN_EXECUTABLE_NAME} ${CROWN_MAIN_SRC})
target_link_libraries(${CROWN_EXECUTABLE_NAME} crown)

if (CROWN_BUILD_TESTS)
	add_subdirectory(tests)
endif (CROWN_BUILD_TESTS)


install (TARGETS crown DESTINATION bin)
install (TARGETS ${CROWN_EXECUTABLE_NAME} DESTINATION bin)

install (TARGETS crown DESTINATION test)

#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)
{'fraction_non_alphanumeric': 0.11467574181706944, 'fraction_numerical': 0.006576934842459468, 'mean_word_length': 4.788623284639221, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4187676', 'n_tokens_mistral': 11694, 'n_tokens_neox': 11003, 'n_words': 1453}