CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(WaterBreakout)


# This cmake file is intended to be used on windows.
# Specify paths to all libraries in the Environment Variable CMAKE_PREFIX_PATH
# standard paths are ignored to avoid finding the wrong version of libs.
# e.g.:
#	CMAKE_PREFIX_PATH=
#	C:\Libs\boost_1_67_0;
#	C:\Libs\FreeImage-3.17.0-VS2015-master;
#	C:\Libs\glfw-3.2.1\bin;
#	C:\Libs\freetype-2.9\bin

SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")

SET(Boost_USE_STATIC_LIBS   ON)
SET(Boost_USE_MULTITHREADED ON)
find_package(Boost  REQUIRED)
find_package(OpenGL REQUIRED)
find_package(FreeImage REQUIRED)
find_package(GLFW3 REQUIRED)

# FreeType
find_path(FREETYPE_INCLUDE_DIR REQUIRED ft2build.h
	PATH_SUFFIXES bin/include/freetype2
	NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)

find_library(FREETYPE_LIBRARY_RELEASE REQUIRED freetype.lib
	PATH_SUFFIXES bin/lib
	NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
find_library(FREETYPE_LIBRARY_DEBUG REQUIRED freetypeD.lib
	PATH_SUFFIXES bin/lib
	NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
	
SET(FREETYPE_LIBRARIES "optimized;${FREETYPE_LIBRARY_RELEASE};;debug;${FREETYPE_LIBRARY_DEBUG};")





### Source Files ####
SET(ENGINE_HEADERS
    Camera.hpp
	Vector3d.hpp
	Helper.hpp
	ResourcesManager.hpp
	Text.hpp
	Shader.hpp
	FramebufferObject.hpp
	StaticModel.hpp
	Material.hpp
	MaterialLib.hpp
	Exception.hpp
	CollisionModel.hpp
	DynamicCubeMap.hpp
	ConfigFile.hpp
	gl_compat_3_3.h
	gl.hpp
	Sound.hpp
	Input.hpp
)
SET(ENGINE_SOURCES
	Camera.cpp
	Helper.cpp
	ResourcesManager.cpp
	Text.cpp
	Shader.cpp
	FramebufferObject.cpp
	StaticModel.cpp
	Material.cpp
	MaterialLib.cpp
	Exception.cpp
	CollisionModel.cpp
	DynamicCubeMap.cpp
	ConfigFile.cpp
	gl_compat_3_3.c
	Sound.cpp
	Input.cpp
)


SET(GAME_HEADERS
	LevelManager.hpp
	Game.hpp
	EntityManager.hpp
	InputStruct.hpp
	ParticleSystem.hpp
	Global.hpp
	Water.hpp
)
SET(GAME_SOURCES
	Game.cpp
	EntityManager.cpp
	LevelManager.cpp
	ParticleSystem.cpp
	Water.cpp
	main.cpp
)
	
SET(ENTITIES_HEADERS
	Entity.hpp
	MoveableEntity.hpp
	Paddle.hpp
	Ball.hpp
	LevelLimit.hpp
	LooseZone.hpp
	Block.hpp
	NormalBlock.hpp
	WallBlock.hpp
	ExplosionBlock.hpp
	LauncherBlock.hpp
	Extra.hpp
)
SET(ENTITIES_SOURCES
	Entity.cpp
	MoveableEntity.cpp
	LooseZone.cpp
	NormalBlock.cpp
	Block.cpp
	LauncherBlock.cpp
	ExplosionBlock.cpp
	WallBlock.cpp
	Paddle.cpp
	Ball.cpp
	LevelLimit.cpp
	Extra.cpp
)


SET( FREETYPE_GL_SRC FreeTypeGl/freetype-gl.h
                     FreeTypeGl/vec234.h
                     FreeTypeGl/opengl.h
                     FreeTypeGl/markup.h
                     FreeTypeGl/mat4.c             FreeTypeGl/mat4.h
                     FreeTypeGl/texture-atlas.c    FreeTypeGl/texture-atlas.h
                     FreeTypeGl/texture-font.c     FreeTypeGl/texture-font.h
                     FreeTypeGl/vertex-buffer.c    FreeTypeGl/vertex-buffer.h
                     FreeTypeGl/vertex-attribute.c FreeTypeGl/vertex-attribute.h
                     FreeTypeGl/font-manager.c     FreeTypeGl/font-manager.h
                     FreeTypeGl/text-buffer.c      FreeTypeGl/text-buffer.h
                     FreeTypeGl/shader.c           FreeTypeGl/shader.h
                     FreeTypeGl/vector.c           FreeTypeGl/vector.h
                     FreeTypeGl/platform.c         FreeTypeGl/platform.h)

file(GLOB SOLOUD_SRC
	"SoLoud/include/*.h"
	"SoLoud/src/core/*.cpp"
	"SoLoud/src/audiosource/wav/*.h"
	"SoLoud/src/audiosource/wav/*.cpp"
	"SoLoud/src/audiosource/wav/*.c"
	"SoLoud/src/audiosource/speech/*.h"
	"SoLoud/src/audiosource/speech/*.cpp"
	"SoLoud/src/audiosource/speech/*.c"
	
	"SoLoud/src/backend/xaudio2/*.cpp"
	
	"SoLoud/src/backend/miniaudio/*.h"
	"SoLoud/src/backend/miniaudio/*.cpp"
)
add_definitions(-DWITH_XAUDIO2 -DWITH_MINIAUDIO)



### Setup Filters ###
SOURCE_GROUP("Engine"	FILES ${ENGINE_HEADERS} ${ENGINE_SOURCES})
SOURCE_GROUP("Game"		FILES ${GAME_HEADERS} ${GAME_SOURCES})
SOURCE_GROUP("Entities"	FILES ${ENTITIES_HEADERS} ${ENTITIES_SOURCES})
SOURCE_GROUP("FreeType GL"	FILES ${FREETYPE_GL_SRC})
SOURCE_GROUP("SoLoud"	FILES ${SOLOUD_SRC})
	

INCLUDE_DIRECTORIES(
	${Boost_INCLUDE_DIRS}
	${FREEIMAGE_INCLUDE_DIR}
	${GLFW_INCLUDE_DIR}
	${FREETYPE_INCLUDE_DIR}
	SoLoud/include
)
LINK_DIRECTORIES(
	${Boost_LIBRARY_DIRS}
)
	
SET(HEADERS ${MAIN_HEADERS} ${ENGINE_HEADERS} ${GAME_HEADERS} ${ENTITIES_HEADERS} )
SET(SOURCES ${MAIN_SOURCES} ${ENGINE_SOURCES} ${GAME_SOURCES} ${ENTITIES_SOURCES} )
ADD_EXECUTABLE(WaterBreakout ${HEADERS} ${SOURCES} ${FREETYPE_GL_SRC} ${SOLOUD_SRC})

target_compile_features(WaterBreakout PUBLIC cxx_std_17)
SET_PROPERTY(TARGET WaterBreakout PROPERTY DEBUG_POSTFIX "D")

TARGET_LINK_LIBRARIES(WaterBreakout
	${Boost_LIBRARIES}
	${GLFW_LIBRARIES}
	${OPENGL_LIBRARIES}
	${FREEIMAGE_LIBRARIES}
	${FREETYPE_LIBRARIES}
)