function(configuration_project)
	foreach(USING ${USE_DEFINITION})
		add_definitions(-D${USING})
	endforeach()

	if (MSVC)
		add_definitions(-D _CRT_SECURE_NO_WARNINGS)
		add_definitions(/sdl /EHsc /Od /RTC1 /GS)
		add_definitions(/MTd /Zi)
	endif()

	if (USE_CURL)
		add_definitions(-D BUILDING_LIBCURL)
	    add_definitions(-D CURL_STATICLIB)
	endif()

	if (USE_OPENSSL)
		add_definitions(-D USE_SSLEAY)
	endif()

	if(UNIX)
	    #add_definitions(-fpermissive -std=c++11)
	endif()
endfunction()


function(configuration_initialize_engine_paths)
	set(BLOOD_ROOT ${CMAKE_HOME_DIRECTORY})
	set(BLOOD_INTERMEDIATE ${BLOOD_ROOT}/assemble/build/intermediate/)
	set(PLATFROM_NAME ${CMAKE_SYSTEM_NAME})

	set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BLOOD_ROOT}/assemble/build/lib/${PLATFORM_NAME})
	set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BLOOD_ROOT}/assemble/build/lib/${PLATFORM_NAME})
	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BLOOD_ROOT}/assemble/build/bin/${PLATFORM_NAME})

	set(BLOOD_ROOT ${BLOOD_ROOT} PARENT_SCOPE)
	set(BLOOD_INTERMEDIATE ${BLOOD_INTERMEDIATE} PARENT_SCOPE)
	set(PLATFROM_NAME ${PLATFROM_NAME} PARENT_SCOPE)
	set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} PARENT_SCOPE)
	set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} PARENT_SCOPE)
	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} PARENT_SCOPE)
	
	#set(CURL_INCLUDE_DIR ${BLOOD_ROOT}/extern/curl/include/ PARENT_SCOPE)
endfunction()

function(configuration_linking_flags)
	if (CMAKE_CONFIGURATION_TYPES)
	    set(CMAKE_CONFIGURATION_TYPES "DEBUG;RELEASE;" PARENT_SCOPE)
	    set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "" FORCE)
	endif()

	if (UNIX  OR MINGW)
		set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} -fpermissive -std=c++11 -O2 -fPIC" PARENT_SCOPE)
		set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -lm  " PARENT_SCOPE)
		set(CMAKE_C++_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}" PARENT_SCOPE) 
		set(CMAKE_C++_CREATE_STATIC_LIBRARY TRUE PARENT_SCOPE)	
	endif()

	if (MSVC)
		if (STORE)
			set(CMAKE_CXX_FLAGS_DEBUG   "${CMAKE_CXX_FLAGS_DEBUG} /MDd /ZW /Ob0 /Od /EHsc /RTC1 /D_DEBUG" PARENT_SCOPE)
	    	set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD /O2 /Ob2 /D NDEBUG" PARENT_SCOPE)
		else()
			set(CMAKE_CXX_FLAGS_DEBUG   "${CMAKE_CXX_FLAGS_DEBUG} /MTd /Zi /Ob0 /Od /EHsc /RTC1 /D_DEBUG" PARENT_SCOPE)
	    	set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT /O2 /Ob2 /D NDEBUG" PARENT_SCOPE)	
		endif()
	endif()
endfunction()

function(configuration_project_types)
	if (COMMAND cmake_policy)
		CMAKE_POLICY(SET CMP0003 NEW)
	endif(COMMAND cmake_policy)

	if (ADDRESS_MODEL_64)
	    if (CMAKE_SIZEOF_VOID_P EQUAL 4)
	        set(MACHINE_TARGET x86 PARENT_SCOPE)
	        set(x86 1 PARENT_SCOPE)
	    else()
	        set(MACHINE_TARGET x64 PARENT_SCOPE)
	        set(x64 1 PARENT_SCOPE)
	    endif()    
	endif()

	if (STORE)
		set(APP_MANIFEST_NAME Package.appxmanifest PARENT_SCOPE)
		set(CMAKE_SYSTEM_NAME WindowsStore CACHE STRING "" FORCE)
		set(CMAKE_SYSTEM_VERSION 8.1  CACHE STRING "" FORCE)
		SET(CMAKE_VS_TARGET_PLATFORM 8.1 PARENT_SCOPE)
		set(CMAKE_VS_PLATFORMS Win32;x64;ARM PARENT_SCOPE)
		set(PLATFROM STORE PARENT_SCOPE)
		set_property(GLOBAL PROPERTY USE_FOLDERS ON PARENT_SCOPE)
		set(EXE_NAME   ${PRODUCT} PARENT_SCOPE)
		set(SHORT_NAME ${PRODUCT} PARENT_SCOPE)
	endif()

	if (WIN32)
	    set(BLOOD_PLATFORM ${BLOOD_PLATFORM} WIN32)
	endif()
	if (MINGW)
	    set(BLOOD_PLATFORM ${BLOOD_PLATFORM} MINGW)
	endif()
	if (SYGWIN)
	    set(BLOOD_PLATFORM ${BLOOD_PLATFORM} SYGWIN)
	endif()
	if (MSVC)
	    set(BLOOD_PLATFORM ${BLOOD_PLATFORM} MSVS)
	    if (STORE)
	    	set(BLOOD_STORE ${BLOOD_PLATFROM} STORE)
	    endif()
	endif()
	if (UNIX)
	    set(BLOOD_PLATFORM ${BLOOD_PLATFORM} UNIX)
	endif()
	foreach(PLATFORM ${BLOOD_PLATFORM})
		add_definitions(-D${PLATFORM})	
	endforeach()
endfunction()
