if(WIN32)
	if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([0-9]+)")
		if(${CMAKE_MATCH_1} GREATER 10)
			option(XP_TOOLCHAIN "Build with XP toolchain (Windows XP support)" ON)
			
			if(XP_TOOLCHAIN)
				if(${CMAKE_MATCH_1} EQUAL 11)
					# VS 11 (2012)
					set(VS_TOOLSET "v110_xp")
				elseif(${CMAKE_MATCH_1} EQUAL 12)
					# VS 12 (2013)
					set(VS_TOOLSET "v120_xp")
				elseif(${CMAKE_MATCH_1} EQUAL 14)
					# VS 14 (2015)
					set(VS_TOOLSET "v140_xp")
				elseif(${CMAKE_MATCH_1} EQUAL 15)
					# VS 15 (2017)
					set(VS_TOOLSET "v141_xp")
				else()
					message(FATAL_ERROR "Your Visual Studio version does not support XP toolchain (or support unknown). Try building without XP_SUPPORT.")
				endif()
				
				set(CMAKE_GENERATOR_TOOLSET ${VS_TOOLSET})
				set(CMAKE_VS_PLATFORM_TOOLSET ${VS_TOOLSET})
				add_compile_definitions(XP_TOOLCHAIN)
			endif()
		endif()
	endif()
endif()
