cmake_minimum_required(VERSION 3.0)
project(DarkRP2D)
set (CMAKE_CXX_STANDARD 11)
include(ExternalProject)

MESSAGE( STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR} )
MESSAGE( STATUS "DarkRP2D_SOURCE_DIR: " ${DarkRP2D_SOURCE_DIR} )

set(DarkRP2D_EXTERNAL_DIR ${DarkRP2D_SOURCE_DIR}/external)
set(SDL2_DIR ${DarkRP2D_EXTERNAL_DIR}/SDL2-2.0.8)
set(GLEW_DIR ${DarkRP2D_EXTERNAL_DIR}/glew-2.1.0)
set(SDL2_Image_DIR ${DarkRP2D_EXTERNAL_DIR}/SDL2_image-2.0.3)
set(FREETYPE_DIR ${DarkRP2D_EXTERNAL_DIR}/freetype-2.9)
set(GLM_DIR ${DarkRP2D_EXTERNAL_DIR}/glm-0.9.9-a2)

#Libs
find_package(SDL2 REQUIRED CONFIG)
include_directories(${SDL2_INCLUDE_DIRS})

find_package(SDL2_Image REQUIRED CONFIG)
include_directories(${SDL2_IMAGE_INCLUDE_DIRS})

find_package(GLEW REQUIRED CONFIG)
include_directories(${GLEW_INCLUDE_DIRS})

find_package(FREETYPE REQUIRED CONFIG)
include_directories(${FREETYPE_INCLUDE_DIRS})

find_package(GLM REQUIRED CONFIG)
include_directories(${GLM_INCLUDE_DIRS})

find_package(OPENGL REQUIRED)

MESSAGE( STATUS "OpenGL Lib: " ${OPENGL_gl_LIBRARY} )
MESSAGE( STATUS "SDL2 Lib: " ${SDL2_LIBRARIES}  )
MESSAGE( STATUS "SDL2_IMG Lib: " ${SDL2_IMAGE_LIBRARIES}  )
MESSAGE( STATUS "Glew Lib: " ${GLEW_LIBRARIES}  )
MESSAGE( STATUS "Freetype lib: " ${FREETYPE_LIBRARIES}  )

file(GLOB_RECURSE DarkRP2D_SOURCE_FILES ${DarkRP2D_SOURCE_DIR}/src/*.cpp)
add_executable(DarkRP2D ${DarkRP2D_SOURCE_FILES})

target_link_libraries(DarkRP2D	${SDL2_LIBRARIES} 
					${SDL2_IMAGE_LIBRARIES} 
					${GLEW_LIBRARIES} 
					${FREETYPE_LIBRARIES}
					${OPENGL_gl_LIBRARY})

add_custom_target(CopyBinaries
	COMMAND ${CMAKE_COMMAND} -E copy ${SDL2_DLL} ${CMAKE_BINARY_DIR}
	COMMAND ${CMAKE_COMMAND} -E copy ${SDL2_IMAGE_DLL} ${CMAKE_BINARY_DIR}
	COMMAND ${CMAKE_COMMAND} -E copy ${FREETYPE_DLL} ${CMAKE_BINARY_DIR}
	COMMAND ${CMAKE_COMMAND} -E copy ${GLEW_DLL} ${CMAKE_BINARY_DIR}
)

add_dependencies(DarkRP2D CopyBinaries)