cmake_minimum_required(VERSION 3.8)

# This module is shared; use include blocker.
if( _COMPILER_ )
	return()
endif()
set(_COMPILER_ 1)

# Initialize MSVC version
if( "${CMAKE_GENERATOR}" MATCHES "Visual Studio" AND NOT MSVC_VERSION )
	set(MSVC10)
	set(MSVC11)
	set(MSVC12)
	set(MSVC14)
	set(MSVC 1)
	set(MSVC_IDE 1)
	if( "${CMAKE_GENERATOR}" MATCHES "Visual Studio 10 2010" )
		set(MSVC10 1)
		set(MSVC_VERSION 1600)
	elseif( "${CMAKE_GENERATOR}" MATCHES "Visual Studio 11 2012" )
		set(MSVC11 1)
		set(MSVC_VERSION 1700)
	elseif( "${CMAKE_GENERATOR}" MATCHES "Visual Studio 12 2013" )
		set(MSVC12 1)
		set(MSVC_VERSION 1800)
	elseif( "${CMAKE_GENERATOR}" MATCHES "Visual Studio 14 2015" )
		set(MSVC14 1)
		set(MSVC_VERSION 1900)
	elseif( "${CMAKE_GENERATOR}" MATCHES "Visual Studio 15 2017" )
		set(MSVC15 1)
		set(MSVC_VERSION 1910)
	else()
		message(FATAL_ERROR "Unsupported Visual Studio version!")
	endif()
endif()

# Initialize compiler variables
if( "${CMAKE_GENERATOR}" MATCHES "Visual Studio" )
	if( MSVC_VERSION EQUAL 1600 )
		set(DEVENV_NAME "vs2010")
		set(COMPILER_NAME "vc10")
	elseif( MSVC_VERSION EQUAL 1700 )
		set(DEVENV_NAME "vs2012")
		set(COMPILER_NAME "vc11")
	elseif( MSVC_VERSION EQUAL 1800 )
		set(DEVENV_NAME "vs2013")
		set(COMPILER_NAME "vc12")
	elseif( MSVC_VERSION EQUAL 1900 )
		set(DEVENV_NAME "vs2015")
		set(COMPILER_NAME "vc14")
	elseif( MSVC_VERSION EQUAL 1910 )
		set(DEVENV_NAME "vs2017")
		set(COMPILER_NAME "vc14")
	else()
		message(FATAL_ERROR "Missing Visual Studio version defines!")
	endif()
elseif( "${CMAKE_GENERATOR}" MATCHES "Xcode" )
	set(DEVENV_NAME "xcode")
	set(COMPILER_NAME "clang")
elseif( "${CMAKE_GENERATOR}" MATCHES "Makefile" )
	set(DEVENV_NAME)
	set(COMPILER_NAME)
endif()
