cmake_minimum_required (VERSION 2.8)

if (NOT WIN32)
	message (FATAL_ERROR "Only Win32 supported")
endif()

set (CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Reset the configurations to what we need" FORCE)
	
project (Common)

if (NOT MSVC)
	message (FATAL_ERROR "Only Microsoft Visual Studio supported")
endif()

set (BOOST_INCLUDE_DIR "" CACHE PATH "Boost include folder")
if (NOT EXISTS ${BOOST_INCLUDE_DIR})
	message (SEND_ERROR "${BOOST_INCLUDE_DIR} doesn't exist")
endif()

if (CMAKE_CL_64)
	set (PLATFORM_NAME "x64")
else()
	set (PLATFORM_NAME "Win32")
endif()

file (GLOB SRCS src/*.cpp)

# Right now msvc its the only platform supported 
# but I want to be explicit here just in case
# in the future I want to support another compiler
if (MSVC)
 
	file (GLOB HDRS include/*.h)
	set (SRCS ${SRCS} ${HDRS})
		
	string (REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})

	if (CMAKE_CL_64)
		set (CMAKE_CXX_FLAGS_DEBUG "/Zi /nologo /W4 /WX /Od -D_DEBUG -DUNICODE -D_UNICODE -DWIN32 -D_LIB /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:queue")
		set (CMAKE_CXX_FLAGS_RELEASE "/Zi /nologo /W4 /WX /O2 /Oi /Ot /GL -DNDEBUG -DUNICODE -D_UNICODE -DWIN32 -D_LIB /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:queue")
	else()
		set (CMAKE_CXX_FLAGS_DEBUG "/ZI /nologo /W4 /WX /Od /Oy- -D_DEBUG -DUNICODE -D_UNICODE -DWIN32 -D_LIB /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze- /errorReport:queue")
		set (CMAKE_CXX_FLAGS_RELEASE "/Zi /nologo /W4 /WX /O2 /Oi /Ot /Oy- /GL -DNDEBUG -DUNICODE -D_UNICODE -DWIN32 -D_LIB /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Gd /analyze- /errorReport:queue")
	endif()
	
endif()

# Setting include directories
include_directories ("include" ${BOOST_INCLUDE_DIR})

# Building libraries
add_library (Common STATIC ${SRCS})
target_link_libraries (Common)