# Variables to determine:
# * INFO_C_READEBLE_COMPILER_NAME
# * INFO_C_READEBLE_FULL_COMPILER_NAME
# * INFO_CXX_READEBLE_COMPILER_NAME
# * INFO_CXX_READEBLE_FULL_COMPILER_NAME
# * INFO_COMPILER_SUITE_NAME
# * INFO_COMPILER_FULL_SUITE_NAME
# * INFO_C_COMPILER_VERSION
# * INFO_CXX_COMPILER_VERSION
# * INFO_COMPILER_SUITE_VERSION
# * INFO_OS_TARGET_NAME
# * INFO_OS_TARGET_ARCH
# * INFO_ENDIANNESS

cmake_minimum_required(VERSION 2.8.4)
include(TestBigEndian)

set(INFO_OS_TARGET_NAME ${CMAKE_SYSTEM_NAME})
set(INFO_OS_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})

if(WIN32)
	# CMAKE_C_COMPILER_ID and CMAKE_CXX_COMPILER_ID determination fails if we are using Visual Studio CMake Generator
	if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
		get_filename_component(TEMP_C_COMPILER_NAME "${CMAKE_C_COMPILER}" NAME_WE)
		get_filename_component(TEMP_CXX_COMPILER_NAME "${CMAKE_CXX_COMPILER}" NAME_WE)

		string(TOLOWER ${TEMP_C_COMPILER_NAME} TEMP_C_COMPILER_NAME)
		string(TOLOWER ${TEMP_CXX_COMPILER_NAME} TEMP_CXX_COMPILER_NAME)

		if(${TEMP_C_COMPILER_NAME} STREQUAL "cl")
			set(CMAKE_C_COMPILER_ID "MSVC")
		elseif(${TEMP_C_COMPILER_NAME} STREQUAL "icl")
			set(CMAKE_C_COMPILER_ID "Intel")
		elseif(${TEMP_C_COMPILER_NAME} STREQUAL "clang")
			set(CMAKE_C_COMPILER_ID "Clang")
		elseif(${TEMP_C_COMPILER_NAME} STREQUAL "pgcc")
			set(CMAKE_C_COMPILER_ID "PGI")
		endif()

		if(${TEMP_CXX_COMPILER_NAME} STREQUAL "cl")
			set(CMAKE_CXX_COMPILER_ID "MSVC")
		elseif(${TEMP_CXX_COMPILER_NAME} STREQUAL "icl")
			set(CMAKE_CXX_COMPILER_ID "Intel")
		elseif(${TEMP_CXX_COMPILER_NAME} STREQUAL "clang++")
			set(CMAKE_CXX_COMPILER_ID "Clang")
		elseif(${TEMP_CXX_COMPILER_NAME} STREQUAL "pgcpp")
			set(CMAKE_CXX_COMPILER_ID "PGI")
		endif()
	endif()

	# Variables for plain C
	if(${CMAKE_C_COMPILER_ID} STREQUAL "MSVC")
		set(INFO_C_READEBLE_COMPILER_NAME "vc")
		set(INFO_C_READEBLE_FULL_COMPILER_NAME "Microsoft Visual C++")
		if(${MSVC_VERSION} EQUAL 1200)
			set(INFO_C_COMPILER_VERSION "6.0")
		elseif(${MSVC_VERSION} EQUAL 1300)
			set(INFO_C_COMPILER_VERSION "7.0")
		elseif(${MSVC_VERSION} EQUAL 1310)
			set(INFO_C_COMPILER_VERSION "7.1")
		elseif(${MSVC_VERSION} EQUAL 1400)
			set(INFO_C_COMPILER_VERSION "8.0")
		elseif(${MSVC_VERSION} EQUAL 1500)
			set(INFO_C_COMPILER_VERSION "9.0")
		elseif(${MSVC_VERSION} EQUAL 1600)
			set(INFO_C_COMPILER_VERSION "10.0")
		elseif(${MSVC_VERSION} EQUAL 1700)
			set(INFO_C_COMPILER_VERSION "11.0")
		elseif(${MSVC_VERSION} EQUAL 1800)
			set(INFO_C_COMPILER_VERSION "12.0")
		endif()
	elseif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
		get_filename_component(TEMP_C_COMPILER_NAME "${CMAKE_C_COMPILER}" NAME_WE)
		string(TOLOWER ${TEMP_C_COMPILER_NAME} TEMP_C_COMPILER_NAME)

		if(${TEMP_C_COMPILER_NAME} STREQUAL "llvm-gcc")
			set(INFO_C_READEBLE_COMPILER_NAME "llvm-gcc")
			set(INFO_C_READEBLE_FULL_COMPILER_NAME "LLVM GNU Compiler Collection")
		elseif(MINGW)
			set(INFO_C_READEBLE_COMPILER_NAME "mingw-gcc")
			set(INFO_C_READEBLE_FULL_COMPILER_NAME "MinGW GNU Compiler Collection")
		else()
			# not MinGW and LLVM-GCC but GNU on Windows (Cygwin is not determined as Windows, see below)
			set(INFO_C_READEBLE_COMPILER_NAME "unknown-gnu")
			set(INFO_C_READEBLE_FULL_COMPILER_NAME "Unknown GNU Compiler Collection")
		endif()
		execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_C_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
	elseif(${CMAKE_C_COMPILER_ID} STREQUAL "Intel")
		set(INFO_C_READEBLE_COMPILER_NAME "icc")
		set(INFO_C_READEBLE_FULL_COMPILER_NAME "Intel C++ Compiler")
		execute_process(COMMAND ${CMAKE_C_COMPILER} OUTPUT_QUIET ERROR_VARIABLE INTEL_COMPILER_USAGE_STRING ERROR_STRIP_TRAILING_WHITESPACE)
		if("${INTEL_COMPILER_USAGE_STRING}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_C_COMPILER_VERSION "${INTEL_COMPILER_USAGE_STRING}")
		endif()
	elseif(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
		set(INFO_C_READEBLE_COMPILER_NAME "clang")
		set(INFO_C_READEBLE_FULL_COMPILER_NAME "Clang")
		execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_C_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
	elseif(${CMAKE_C_COMPILER_ID} STREQUAL "Borland")
		set(INFO_C_READEBLE_COMPILER_NAME "bcc")
		set(INFO_C_READEBLE_FULL_COMPILER_NAME "Borland C++")
		execute_process(COMMAND ${CMAKE_C_COMPILER} ERROR_QUIET OUTPUT_VARIABLE BORLAND_COMPILER_USAGE_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
		if("${BORLAND_COMPILER_USAGE_STRING}" MATCHES "([0-9])+.([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+.([0-9])+" INFO_C_COMPILER_VERSION "${BORLAND_COMPILER_USAGE_STRING}")
		endif()
	elseif(${CMAKE_C_COMPILER_ID} STREQUAL "PGI")
		set(INFO_C_READEBLE_COMPILER_NAME "pgi")
		set(INFO_C_READEBLE_FULL_COMPILER_NAME "The Portland Group, Inc.")
		execute_process(COMMAND ${CMAKE_C_COMPILER} --version ERROR_QUIET OUTPUT_VARIABLE PGI_COMPILER_VERSION_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
		if("${PGI_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_C_COMPILER_VERSION "${PGI_COMPILER_VERSION_OUTPUT}")
		endif()
	else()
		string(TOLOWER "${CMAKE_C_COMPILER_ID}" INFO_C_READEBLE_COMPILER_NAME)
		set(INFO_C_READEBLE_FULL_COMPILER_NAME "${CMAKE_C_COMPILER_ID}")
		# other - version info like in vc?
		execute_process(COMMAND ${CMAKE_C_COMPILER} OUTPUT_QUIET ERROR_VARIABLE UNKNOWN_COMPILER_USAGE_STRING ERROR_STRIP_TRAILING_WHITESPACE)
		if("${UNKNOWN_COMPILER_USAGE_STRING}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_C_COMPILER_VERSION "${UNKNOWN_COMPILER_USAGE_STRING}")
		endif()
		if("${INFO_C_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in bcc?
			execute_process(COMMAND ${CMAKE_C_COMPILER} ERROR_QUIET OUTPUT_VARIABLE UNKNOWN_COMPILER_USAGE_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
			if("${UNKNOWN_COMPILER_USAGE_STRING}" MATCHES "([0-9])+.([0-9])+")
				string(REGEX MATCH "([0-9])+.([0-9])+" INFO_C_COMPILER_VERSION "${UNKNOWN_COMPILER_USAGE_STRING}")
			endif()
		endif()
		if("${INFO_C_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in gcc?
			execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_C_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
		endif()
		if("${INFO_C_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in pgi?
			execute_process(COMMAND ${CMAKE_C_COMPILER} --version ERROR_QUIET OUTPUT_VARIABLE UNKNOWN_COMPILER_VERSION_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
			if("${UNKNOWN_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
				string(REGEX MATCH "([0-9])+.([0-9])+" INFO_C_COMPILER_VERSION "${UNKNOWN_COMPILER_VERSION_OUTPUT}")
			endif()
		endif()
		if("${INFO_C_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in sunpro?
			execute_process(COMMAND ${CMAKE_C_COMPILER} -V OUTPUT_QUIET ERROR_VARIABLE UNKNOWN_COMPILER_VERSION_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE)
			if("${UNKNOWN_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
				string(REGEX MATCH "([0-9])+.([0-9])+" INFO_C_COMPILER_VERSION "${UNKNOWN_COMPILER_VERSION_OUTPUT}")
			endif()
		endif()
	endif()

	# Variables for C++
	if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
		set(INFO_CXX_READEBLE_COMPILER_NAME "vc")
		set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "Microsoft Visual C++")
		if(${MSVC_VERSION} EQUAL 1200)
			set(INFO_CXX_COMPILER_VERSION "6.0")
		elseif(${MSVC_VERSION} EQUAL 1300)
			set(INFO_CXX_COMPILER_VERSION "7.0")
		elseif(${MSVC_VERSION} EQUAL 1310)
			set(INFO_CXX_COMPILER_VERSION "7.1")
		elseif(${MSVC_VERSION} EQUAL 1400)
			set(INFO_CXX_COMPILER_VERSION "8.0")
		elseif(${MSVC_VERSION} EQUAL 1500)
			set(INFO_CXX_COMPILER_VERSION "9.0")
		elseif(${MSVC_VERSION} EQUAL 1600)
			set(INFO_CXX_COMPILER_VERSION "10.0")
		elseif(${MSVC_VERSION} EQUAL 1700)
			set(INFO_CXX_COMPILER_VERSION "11.0")
		elseif(${MSVC_VERSION} EQUAL 1800)
			set(INFO_CXX_COMPILER_VERSION "12.0")
		endif()
	elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
		get_filename_component(TEMP_CXX_COMPILER_NAME "${CMAKE_CXX_COMPILER}" NAME_WE)
		string(TOLOWER ${TEMP_CXX_COMPILER_NAME} TEMP_CXX_COMPILER_NAME)

		if(${TEMP_CXX_COMPILER_NAME} STREQUAL "llvm-g++")
			set(INFO_CXX_READEBLE_COMPILER_NAME "llvm-gcc")
			set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "LLVM GNU Compiler Collection")
		elseif(MINGW)
			set(INFO_CXX_READEBLE_COMPILER_NAME "mingw-gcc")
			set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "MinGW GNU Compiler Collection")
		else()
			# not MinGW and LLVM-GCC but GNU on Windows (Cygwin is not determined as Windows, see below)
			set(INFO_CXX_READEBLE_COMPILER_NAME "unknown-gnu")
			set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "Unknown GNU Compiler Collection")
		endif()
		execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_CXX_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
	elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
		set(INFO_CXX_READEBLE_COMPILER_NAME "icc")
		set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "Intel C++ Compiler")
		execute_process(COMMAND ${CMAKE_CXX_COMPILER} OUTPUT_QUIET ERROR_VARIABLE INTEL_COMPILER_USAGE_STRING ERROR_STRIP_TRAILING_WHITESPACE)
		if("${INTEL_COMPILER_USAGE_STRING}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_CXX_COMPILER_VERSION "${INTEL_COMPILER_USAGE_STRING}")
		endif()
	elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
		set(INFO_CXX_READEBLE_COMPILER_NAME "clang")
		set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "Clang")
		execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_CXX_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
	elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Borland")
		set(INFO_CXX_READEBLE_COMPILER_NAME "bcc")
		set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "Borland C++")
		execute_process(COMMAND ${CMAKE_CXX_COMPILER} ERROR_QUIET OUTPUT_VARIABLE BORLAND_COMPILER_USAGE_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
		if("${BORLAND_COMPILER_USAGE_STRING}" MATCHES "([0-9])+.([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+.([0-9])+" INFO_CXX_COMPILER_VERSION "${BORLAND_COMPILER_USAGE_STRING}")
		endif()
	elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "PGI")
		set(INFO_CXX_READEBLE_COMPILER_NAME "pgi")
		set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "The Portland Group, Inc.")
		execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version ERROR_QUIET OUTPUT_VARIABLE PGI_COMPILER_VERSION_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
		if("${PGI_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_CXX_COMPILER_VERSION "${PGI_COMPILER_VERSION_OUTPUT}")
		endif()
	else()
		string(TOLOWER "${CMAKE_CXX_COMPILER_ID}" INFO_CXX_READEBLE_COMPILER_NAME)
		set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "${CMAKE_CXX_COMPILER_ID}")
		# other - version info like in vc?
		execute_process(COMMAND ${CMAKE_CXX_COMPILER} OUTPUT_QUIET ERROR_VARIABLE UNKNOWN_COMPILER_USAGE_STRING ERROR_STRIP_TRAILING_WHITESPACE)
		if("${UNKNOWN_COMPILER_USAGE_STRING}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_CXX_COMPILER_VERSION "${UNKNOWN_COMPILER_USAGE_STRING}")
		endif()
		if("${INFO_CXX_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in bcc?
			execute_process(COMMAND ${CMAKE_CXX_COMPILER} ERROR_QUIET OUTPUT_VARIABLE UNKNOWN_COMPILER_USAGE_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
			if("${UNKNOWN_COMPILER_USAGE_STRING}" MATCHES "([0-9])+.([0-9])+")
				string(REGEX MATCH "([0-9])+.([0-9])+" INFO_CXX_COMPILER_VERSION "${UNKNOWN_COMPILER_USAGE_STRING}")
			endif()
		endif()
		if("${INFO_CXX_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in gcc?
			execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_CXX_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
		endif()
		if("${INFO_CXX_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in pgi?
			execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version ERROR_QUIET OUTPUT_VARIABLE UNKNOWN_COMPILER_VERSION_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
			if("${UNKNOWN_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
				string(REGEX MATCH "([0-9])+.([0-9])+" INFO_CXX_COMPILER_VERSION "${UNKNOWN_COMPILER_VERSION_OUTPUT}")
			endif()
		endif()
		if("${INFO_CXX_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in sunpro?
			execute_process(COMMAND ${CMAKE_CXX_COMPILER} -V OUTPUT_QUIET ERROR_VARIABLE UNKNOWN_COMPILER_VERSION_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE)
			if("${UNKNOWN_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
				string(REGEX MATCH "([0-9])+.([0-9])+" INFO_CXX_COMPILER_VERSION "${UNKNOWN_COMPILER_VERSION_OUTPUT}")
			endif()
		endif()
	endif()
elseif(UNIX)
	# Variables for plain C
	if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
		get_filename_component(TEMP_C_COMPILER_NAME "${CMAKE_C_COMPILER}" NAME_WE)
		string(TOLOWER ${TEMP_C_COMPILER_NAME} TEMP_C_COMPILER_NAME)

		if(${TEMP_C_COMPILER_NAME} STREQUAL "llvm-gcc")
			set(INFO_C_READEBLE_COMPILER_NAME "llvm-gcc")
			set(INFO_C_READEBLE_FULL_COMPILER_NAME "LLVM GNU Compiler Collection")
		elseif(MINGW)
			set(INFO_C_READEBLE_COMPILER_NAME "mingw-gcc")
			set(INFO_C_READEBLE_FULL_COMPILER_NAME "MinGW GNU Compiler Collection")

			# Windows cross-compilation
			set(INFO_OS_TARGET_NAME "Windows")
			set(CMAKE_SYSTEM_NAME "Windows")
			set(CMAKE_SYSTEM_PROCESSOR "x86")
		else()
			set(INFO_C_READEBLE_COMPILER_NAME "gcc")
			set(INFO_C_READEBLE_FULL_COMPILER_NAME "GNU Compiler Collection")
		endif()
		execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_C_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
	elseif(${CMAKE_C_COMPILER_ID} STREQUAL "Intel")
		set(INFO_C_READEBLE_COMPILER_NAME "icc")
		set(INFO_C_READEBLE_FULL_COMPILER_NAME "Intel C++ Compiler")
		execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_C_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
	elseif(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
		set(INFO_C_READEBLE_COMPILER_NAME "clang")
		set(INFO_C_READEBLE_FULL_COMPILER_NAME "Clang")
		execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_C_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
	elseif(${CMAKE_C_COMPILER_ID} STREQUAL "PathScale")
		set(INFO_C_READEBLE_COMPILER_NAME "ekopath")
		set(INFO_C_READEBLE_FULL_COMPILER_NAME "PathScale EKOPath Compiler Suite")
		execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_C_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
	elseif(${CMAKE_C_COMPILER_ID} STREQUAL "PGI")
		set(INFO_C_READEBLE_COMPILER_NAME "pgi")
		set(INFO_C_READEBLE_FULL_COMPILER_NAME "The Portland Group, Inc.")
		execute_process(COMMAND ${CMAKE_C_COMPILER} --version ERROR_QUIET OUTPUT_VARIABLE PGI_COMPILER_VERSION_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
		if("${PGI_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_C_COMPILER_VERSION "${PGI_COMPILER_VERSION_OUTPUT}")
		endif()
	elseif(${CMAKE_C_COMPILER_ID} STREQUAL "SunPro")
		set(INFO_C_READEBLE_COMPILER_NAME "sunpro")
		set(INFO_C_READEBLE_FULL_COMPILER_NAME "Oracle Solaris Studio")
		execute_process(COMMAND ${CMAKE_C_COMPILER} -V OUTPUT_QUIET ERROR_VARIABLE SUNPRO_COMPILER_VERSION_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE)
		if("${SUNPRO_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_C_COMPILER_VERSION "${SUNPRO_COMPILER_VERSION_OUTPUT}")
		endif()
	else()
		string(TOLOWER "${CMAKE_C_COMPILER_ID}" INFO_C_READEBLE_COMPILER_NAME)
		set(INFO_C_READEBLE_FULL_COMPILER_NAME "${CMAKE_C_COMPILER_ID}")
		# other - version info like in vc?
		execute_process(COMMAND ${CMAKE_C_COMPILER} OUTPUT_QUIET ERROR_VARIABLE UNKNOWN_COMPILER_USAGE_STRING ERROR_STRIP_TRAILING_WHITESPACE)
		if("${UNKNOWN_COMPILER_USAGE_STRING}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_C_COMPILER_VERSION "${UNKNOWN_COMPILER_USAGE_STRING}")
		endif()
		if("${INFO_C_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in bcc?
			execute_process(COMMAND ${CMAKE_C_COMPILER} ERROR_QUIET OUTPUT_VARIABLE UNKNOWN_COMPILER_USAGE_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
			if("${UNKNOWN_COMPILER_USAGE_STRING}" MATCHES "([0-9])+.([0-9])+")
				string(REGEX MATCH "([0-9])+.([0-9])+" INFO_C_COMPILER_VERSION "${UNKNOWN_COMPILER_USAGE_STRING}")
			endif()
		endif()
		if("${INFO_C_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in gcc?
			execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_C_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
		endif()
		if("${INFO_C_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in pgi?
			execute_process(COMMAND ${CMAKE_C_COMPILER} --version ERROR_QUIET OUTPUT_VARIABLE UNKNOWN_COMPILER_VERSION_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
			if("${UNKNOWN_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
				string(REGEX MATCH "([0-9])+.([0-9])+" INFO_C_COMPILER_VERSION "${UNKNOWN_COMPILER_VERSION_OUTPUT}")
			endif()
		endif()
		if("${INFO_C_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in sunpro?
			execute_process(COMMAND ${CMAKE_C_COMPILER} -V OUTPUT_QUIET ERROR_VARIABLE UNKNOWN_COMPILER_VERSION_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE)
			if("${UNKNOWN_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
				string(REGEX MATCH "([0-9])+.([0-9])+" INFO_C_COMPILER_VERSION "${UNKNOWN_COMPILER_VERSION_OUTPUT}")
			endif()
		endif()
	endif()

	# Variables for C++
	if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
		get_filename_component(TEMP_CXX_COMPILER_NAME "${CMAKE_CXX_COMPILER}" NAME_WE)
		string(TOLOWER ${TEMP_CXX_COMPILER_NAME} TEMP_CXX_COMPILER_NAME)

		if(${TEMP_CXX_COMPILER_NAME} STREQUAL "llvm-g++")
			set(INFO_CXX_READEBLE_COMPILER_NAME "llvm-gcc")
			set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "LLVM GNU Compiler Collection")
		elseif(MINGW)
			set(INFO_CXX_READEBLE_COMPILER_NAME "mingw-gcc")
			set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "MinGW GNU Compiler Collection")

			# Windows cross-compilation
			set(INFO_OS_TARGET_NAME "Windows")
			set(CMAKE_SYSTEM_NAME "Windows")
			set(CMAKE_SYSTEM_PROCESSOR "x86")
		else()
			set(INFO_CXX_READEBLE_COMPILER_NAME "gcc")
			set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "GNU Compiler Collection")
		endif()
		execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_CXX_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
	elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
		set(INFO_CXX_READEBLE_COMPILER_NAME "icc")
		set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "Intel C++ Compiler")
		execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_CXX_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
	elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
		set(INFO_CXX_READEBLE_COMPILER_NAME "clang")
		set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "Clang")
		execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_CXX_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
	elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "PathScale")
		set(INFO_CXX_READEBLE_COMPILER_NAME "ekopath")
		set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "PathScale EKOPath Compiler Suite")
		execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_CXX_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
	elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "PGI")
		set(INFO_CXX_READEBLE_COMPILER_NAME "pgi")
		set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "The Portland Group, Inc.")
		execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version ERROR_QUIET OUTPUT_VARIABLE PGI_COMPILER_VERSION_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
		if("${PGI_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_CXX_COMPILER_VERSION "${PGI_COMPILER_VERSION_OUTPUT}")
		endif()
	elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "SunPro")
		set(INFO_CXX_READEBLE_COMPILER_NAME "sunpro")
		set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "Oracle Solaris Studio")
		execute_process(COMMAND ${CMAKE_CXX_COMPILER} -V OUTPUT_QUIET ERROR_VARIABLE SUNPRO_COMPILER_VERSION_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE)
		if("${SUNPRO_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_CXX_COMPILER_VERSION "${SUNPRO_COMPILER_VERSION_OUTPUT}")
		endif()
	else()
		string(TOLOWER "${CMAKE_CXX_COMPILER_ID}" INFO_CXX_READEBLE_COMPILER_NAME)
		set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "${CMAKE_CXX_COMPILER_ID}")
		# other - version info like in vc?
		execute_process(COMMAND ${CMAKE_CXX_COMPILER} OUTPUT_QUIET ERROR_VARIABLE UNKNOWN_COMPILER_USAGE_STRING ERROR_STRIP_TRAILING_WHITESPACE)
		if("${UNKNOWN_COMPILER_USAGE_STRING}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_CXX_COMPILER_VERSION "${UNKNOWN_COMPILER_USAGE_STRING}")
		endif()
		if("${INFO_CXX_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in bcc?
			execute_process(COMMAND ${CMAKE_CXX_COMPILER} ERROR_QUIET OUTPUT_VARIABLE UNKNOWN_COMPILER_USAGE_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
			if("${UNKNOWN_COMPILER_USAGE_STRING}" MATCHES "([0-9])+.([0-9])+")
				string(REGEX MATCH "([0-9])+.([0-9])+" INFO_CXX_COMPILER_VERSION "${UNKNOWN_COMPILER_USAGE_STRING}")
			endif()
		endif()
		if("${INFO_CXX_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in gcc?
			execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion ERROR_QUIET OUTPUT_VARIABLE INFO_CXX_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
		endif()
		if("${INFO_CXX_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in pgi?
			execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version ERROR_QUIET OUTPUT_VARIABLE UNKNOWN_COMPILER_VERSION_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
			if("${UNKNOWN_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
				string(REGEX MATCH "([0-9])+.([0-9])+" INFO_CXX_COMPILER_VERSION "${UNKNOWN_COMPILER_VERSION_OUTPUT}")
			endif()
		endif()
		if("${INFO_CXX_COMPILER_VERSION}" STREQUAL "")
			# other - version info like in sunpro?
			execute_process(COMMAND ${CMAKE_CXX_COMPILER} -V OUTPUT_QUIET ERROR_VARIABLE UNKNOWN_COMPILER_VERSION_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE)
			if("${UNKNOWN_COMPILER_VERSION_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
				string(REGEX MATCH "([0-9])+.([0-9])+" INFO_CXX_COMPILER_VERSION "${UNKNOWN_COMPILER_VERSION_OUTPUT}")
			endif()
		endif()

	endif()
endif()

if(${INFO_OS_TARGET_NAME} STREQUAL "CYGWIN")
	set(INFO_C_READEBLE_COMPILER_NAME "cygwin-${INFO_C_READEBLE_COMPILER_NAME}")
	set(INFO_C_READEBLE_FULL_COMPILER_NAME "Cygwin ${INFO_C_READEBLE_FULL_COMPILER_NAME}")
	set(INFO_CXX_READEBLE_COMPILER_NAME "cygwin-${INFO_CXX_READEBLE_COMPILER_NAME}")
	set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "Cygwin ${INFO_CXX_READEBLE_FULL_COMPILER_NAME}")

	# Windows/Cygwin cross-compilation
	set(INFO_OS_TARGET_NAME "Cygwin")
endif()

# Corrections to x86 target
if(INFO_OS_TARGET_ARCH MATCHES "i[2-6]86|x86|i86pc|x86_64|amd64")
	if(CMAKE_SIZEOF_VOID_P MATCHES "4")
		set(INFO_OS_TARGET_ARCH "x86")
	elseif(CMAKE_SIZEOF_VOID_P MATCHES "8")
		set(INFO_OS_TARGET_ARCH "x86_64")
	endif()
endif()

# Corrections to PowerPC target
if(INFO_OS_TARGET_ARCH STREQUAL "powerpc")
	if(CMAKE_SIZEOF_VOID_P MATCHES "4")
		set(INFO_OS_TARGET_ARCH "ppc")
	elseif(CMAKE_SIZEOF_VOID_P MATCHES "8")
		set(INFO_OS_TARGET_ARCH "ppc64")
	endif()
endif()

# Workarounds in case of unsuccessful determination the name of compiler
if("${INFO_C_READEBLE_COMPILER_NAME}" STREQUAL "")
	set(INFO_C_READEBLE_COMPILER_NAME "custom-unknown")
	set(INFO_C_READEBLE_FULL_COMPILER_NAME "Custom or Unknown C/C++ compiler")
endif()

if("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "")
	message(STATUS "INFO_CXX_READEBLE_COMPILER_NAME: ${INFO_CXX_READEBLE_COMPILER_NAME}")
	set(INFO_CXX_READEBLE_COMPILER_NAME "custom-unknown")
	set(INFO_CXX_READEBLE_FULL_COMPILER_NAME "Custom or Unknown C/C++ compiler")
endif()

# Workarounds in case of unsuccessful determination the version of compiler
if("${INFO_C_COMPILER_VERSION}" STREQUAL "")
	set(INFO_C_COMPILER_VERSION "0.0.0")
endif()

if("${INFO_CXX_COMPILER_VERSION}" STREQUAL "")
	set(INFO_CXX_COMPILER_VERSION "0.0.0")
endif()

# Compiler C/C++ suite name
if("${INFO_C_READEBLE_COMPILER_NAME}" STREQUAL "${INFO_CXX_READEBLE_COMPILER_NAME}")
	set(INFO_COMPILER_SUITE_NAME "${INFO_C_READEBLE_COMPILER_NAME}")
	set(INFO_COMPILER_FULL_SUITE_NAME "${INFO_C_READEBLE_FULL_COMPILER_NAME}")
else()
	set(INFO_COMPILER_SUITE_NAME "custom-unknown")
	set(INFO_COMPILER_FULL_SUITE_NAME "Custom or Unknown suite")
endif()

# Compiler C/C++ suite version
if("${INFO_C_COMPILER_VERSION}" STREQUAL "${INFO_CXX_COMPILER_VERSION}")
	set(INFO_COMPILER_SUITE_VERSION "${INFO_C_COMPILER_VERSION}")
else()
	set(INFO_COMPILER_SUITE_VERSION "0.0.0")
endif()

# Defines for compiler name and version

# C compiler defines:
if("${INFO_C_READEBLE_COMPILER_NAME}" STREQUAL "vc")
	set(CMAKE_C_FLAGS "-DC_COMPILER_VC ${CMAKE_C_FLAGS}")
elseif("${INFO_C_READEBLE_COMPILER_NAME}" STREQUAL "icc")
	set(CMAKE_C_FLAGS "-DC_COMPILER_ICC ${CMAKE_C_FLAGS}")
elseif("${INFO_C_READEBLE_COMPILER_NAME}" STREQUAL "llvm-gcc")
	set(CMAKE_C_FLAGS "-DC_COMPILER_GNU ${CMAKE_C_FLAGS}")
	set(CMAKE_C_FLAGS "-DC_COMPILER_LLVM_GCC ${CMAKE_C_FLAGS}")
	set(CMAKE_C_FLAGS "-DC_COMPILER_LLVM_FRONTEND ${CMAKE_C_FLAGS}")
elseif("${INFO_C_READEBLE_COMPILER_NAME}" STREQUAL "mingw-gcc")
	set(CMAKE_C_FLAGS "-DC_COMPILER_GNU ${CMAKE_C_FLAGS}")
	set(CMAKE_C_FLAGS "-DC_COMPILER_MINGW ${CMAKE_C_FLAGS}")
elseif("${INFO_C_READEBLE_COMPILER_NAME}" STREQUAL "unknown-gnu")
	set(CMAKE_C_FLAGS "-DC_COMPILER_GNU ${CMAKE_C_FLAGS}")
elseif("${INFO_C_READEBLE_COMPILER_NAME}" STREQUAL "clang")
	set(CMAKE_C_FLAGS "-DC_COMPILER_CLANG ${CMAKE_C_FLAGS}")
	set(CMAKE_C_FLAGS "-DC_COMPILER_LLVM_FRONTEND ${CMAKE_C_FLAGS}")
elseif("${INFO_C_READEBLE_COMPILER_NAME}" STREQUAL "bcc")
	set(CMAKE_C_FLAGS "-DC_COMPILER_BCC ${CMAKE_C_FLAGS}")
elseif("${INFO_C_READEBLE_COMPILER_NAME}" STREQUAL "pgi")
	set(CMAKE_C_FLAGS "-DC_COMPILER_PGI ${CMAKE_C_FLAGS}")
elseif("${INFO_C_READEBLE_COMPILER_NAME}" STREQUAL "gcc")
	set(CMAKE_C_FLAGS "-DC_COMPILER_GNU ${CMAKE_C_FLAGS}")
	set(CMAKE_C_FLAGS "-DC_COMPILER_GCC ${CMAKE_C_FLAGS}")
elseif("${INFO_C_READEBLE_COMPILER_NAME}" STREQUAL "ekopath")
	set(CMAKE_C_FLAGS "-DC_COMPILER_EKOPATH ${CMAKE_C_FLAGS}")
elseif("${INFO_C_READEBLE_COMPILER_NAME}" STREQUAL "sunpro")
	set(CMAKE_C_FLAGS "-DC_COMPILER_SUNPRO ${CMAKE_C_FLAGS}")
endif()

# C++ compiler defines:
if("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "vc")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_VC ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_VC ${CMAKE_CXX_FLAGS}")
elseif("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "icc")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_ICC ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_ICC ${CMAKE_CXX_FLAGS}")
elseif("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "llvm-gcc")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_GNU ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_LLVM_GCC ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_LLVM_FRONTEND ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_GNU ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_LLVM_GCC ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_LLVM_FRONTEND ${CMAKE_CXX_FLAGS}")
elseif("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "mingw-gcc")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_GNU ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_MINGW ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_GNU ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_MINGW ${CMAKE_CXX_FLAGS}")
elseif("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "unknown-gnu")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_GNU ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_GNU ${CMAKE_CXX_FLAGS}")
elseif("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "clang")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_CLANG ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_LLVM_FRONTEND ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_CLANG ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_LLVM_FRONTEND ${CMAKE_CXX_FLAGS}")
elseif("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "bcc")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_BCC ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_BCC ${CMAKE_CXX_FLAGS}")
elseif("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "pgi")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_PGI ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_PGI ${CMAKE_CXX_FLAGS}")
elseif("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "gcc")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_GNU ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_GCC ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_GNU ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_GCC ${CMAKE_CXX_FLAGS}")
elseif("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "ekopath")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_EKOPATH ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_EKOPATH ${CMAKE_CXX_FLAGS}")
elseif("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "sunpro")
	set(CMAKE_CXX_FLAGS "-DC_COMPILER_SUNPRO ${CMAKE_CXX_FLAGS}")
	set(CMAKE_CXX_FLAGS "-DCXX_COMPILER_SUNPRO ${CMAKE_CXX_FLAGS}")
endif()

# C/C++ compiler suite defines:
if("${INFO_COMPILER_SUITE_NAME}" STREQUAL "vc")
	add_definitions(-DCOMPILER_SUITE_VC)
elseif("${INFO_COMPILER_SUITE_NAME}" STREQUAL "icc")
	add_definitions(-DCOMPILER_SUITE_ICC)
elseif("${INFO_COMPILER_SUITE_NAME}" STREQUAL "llvm-gcc")
	add_definitions(-DCOMPILER_SUITE_GNU)
	add_definitions(-DCOMPILER_SUITE_LLVM_GCC)
	add_definitions(-DCOMPILER_SUITE_LLVM_FRONTEND)
elseif("${INFO_COMPILER_SUITE_NAME}" STREQUAL "mingw-gcc")
	add_definitions(-DCOMPILER_SUITE_GNU)
	add_definitions(-DCOMPILER_SUITE_MINGW)
elseif("${INFO_COMPILER_SUITE_NAME}" STREQUAL "unknown-gnu")
	add_definitions(-DCOMPILER_SUITE_GNU)
elseif("${INFO_COMPILER_SUITE_NAME}" STREQUAL "clang")
	add_definitions(-DCOMPILER_SUITE_CLANG)
	add_definitions(-DCOMPILER_SUITE_LLVM_FRONTEND)
elseif("${INFO_COMPILER_SUITE_NAME}" STREQUAL "bcc")
	add_definitions(-DCOMPILER_SUITE_BCC)
elseif("${INFO_COMPILER_SUITE_NAME}" STREQUAL "pgi")
	add_definitions(-DCOMPILER_SUITE_PGI)
elseif("${INFO_COMPILER_SUITE_NAME}" STREQUAL "gcc")
	add_definitions(-DCOMPILER_SUITE_GNU)
	add_definitions(-DCOMPILER_SUITE_GCC)
elseif("${INFO_COMPILER_SUITE_NAME}" STREQUAL "ekopath")
	add_definitions(-DCOMPILER_SUITE_EKOPATH)
elseif("${INFO_COMPILER_SUITE_NAME}" STREQUAL "sunpro")
	add_definitions(-DCOMPILER_SUITE_SUNPRO)
endif()

# Defines for target system info:
if(WIN32)
	add_definitions(-DOS_TARGET_WINDOWS)

	# Defines for target endianness:
	set(INFO_ENDIANNESS "Little-Endian")
	add_definitions(-DLITTLE_ENDIAN)
elseif(UNIX)
	add_definitions(-DOS_TARGET_UNIX)

	if("${INFO_OS_TARGET_NAME}" STREQUAL "Linux")
		add_definitions(-DOS_TARGET_LINUX)
	elseif("${INFO_OS_TARGET_NAME}" STREQUAL "Darwin")
		add_definitions(-DOS_TARGET_DARWIN)
	elseif("${INFO_OS_TARGET_NAME}" MATCHES "SunOS|Solaris")
		add_definitions(-DOS_TARGET_SOLARIS)
	elseif("${INFO_OS_TARGET_NAME}" MATCHES "BSD")
		add_definitions(-DOS_TARGET_BSD)
	elseif("${INFO_OS_TARGET_NAME}" STREQUAL "Cygwin")
		add_definitions(-DOS_TARGET_CYGWIN)
	endif()

	# Defines for target endianness:
	TEST_BIG_ENDIAN(BIGENDIAN)
	if(${BIGENDIAN})
		set(INFO_ENDIANNESS "Big-Endian")
		add_definitions(-DBIG_ENDIAN)
	else()
		set(INFO_ENDIANNESS "Little-Endian")
		add_definitions(-DLITTLE_ENDIAN)
	endif()
endif()

# Defines for target architecture info:
if("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "x86")
	add_definitions(-DOS_TARGET_ARCH_X86)
	add_definitions(-DOS_TARGET_ARCH_IA32)
elseif("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "x86_64")
	add_definitions(-DOS_TARGET_ARCH_X86_64)
	add_definitions(-DOS_TARGET_ARCH_AMD64)
elseif("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "ppc")
	add_definitions(-DOS_TARGET_ARCH_POWER)
	add_definitions(-DOS_TARGET_ARCH_PPC)
elseif("${INFO_CXX_READEBLE_COMPILER_NAME}" STREQUAL "ppc64")
	add_definitions(-DOS_TARGET_ARCH_POWER)
	add_definitions(-DOS_TARGET_ARCH_PPC64)
endif()

# Defines for host system info:
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
	# Windows NT
	execute_process(COMMAND "cmd" "/c" "ver" ERROR_QUIET OUTPUT_VARIABLE WINDOWS_VER_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)

	if(NOT "${WINDOWS_VER_OUTPUT}" STREQUAL "")
		if("${WINDOWS_VER_OUTPUT}" MATCHES "([0-9])+.([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+.([0-9])+" INFO_OS_HOST_VERSION "${WINDOWS_VER_OUTPUT}")
		elseif("${WINDOWS_VER_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_OS_HOST_VERSION "${WINDOWS_VER_OUTPUT}")
		elseif("${WINDOWS_VER_OUTPUT}" MATCHES "([0-9])+")
			string(REGEX MATCH "([0-9])+" INFO_OS_HOST_VERSION "${WINDOWS_VER_OUTPUT}")
		endif()

		if("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "6.2.9600" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "6.2.9600")
			set(INFO_OS_HOST_NAME "Windows 8.1")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "6.2.9200" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "6.2.9200")
			set(INFO_OS_HOST_NAME "Windows 8")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "6.1.7601" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "6.1.7601")
			set(INFO_OS_HOST_NAME "Windows 7 SP1")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "6.1.7600" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "6.1.7600")
			set(INFO_OS_HOST_NAME "Windows 7")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "6.0.6002" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "6.0.6002")
			set(INFO_OS_HOST_NAME "Windows Vista SP2")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "6.0.6001" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "6.0.6001")
			set(INFO_OS_HOST_NAME "Windows Vista SP1")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "6.0.6000" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "6.0.6000")
			set(INFO_OS_HOST_NAME "Windows Vista")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "5.2.3790" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "5.2.3790")
			set(INFO_OS_HOST_NAME "Windows Server 2003")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "5.1.2600" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "5.1.2600")
			set(INFO_OS_HOST_NAME "Windows XP")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "5.0.2195" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "5.0.2195")
			set(INFO_OS_HOST_NAME "Windows 2000")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "4.0.1381" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "4.0.1381")
			set(INFO_OS_HOST_NAME "Windows NT 4.0")
		else()
			set(INFO_OS_HOST_NAME "Wine")
		endif()

		execute_process(COMMAND "reg" "query" "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" ERROR_QUIET OUTPUT_VARIABLE REG_QUERY_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)

		if(REG_QUERY_OUTPUT MATCHES "(PROCESSOR_ARCHITECTURE)( )+(REG_SZ)( )+([A-Za-z0-9])+")
			string(REGEX MATCH "(PROCESSOR_ARCHITECTURE)( )+(REG_SZ)( )+([A-Za-z0-9])+" REG_QUERY_OUTPUT "${REG_QUERY_OUTPUT}")
		endif()

		string(TOLOWER "${REG_QUERY_OUTPUT}" REG_QUERY_OUTPUT)
		if(REG_QUERY_OUTPUT MATCHES "x86_64|x64|amd64")
			set(INFO_OS_HOST_ARCH "x86_64")
		else()
			set(INFO_OS_HOST_ARCH "x86")
		endif()
	endif()

	# Windows 9x
	execute_process(COMMAND "command" "/c" "ver" ERROR_QUIET OUTPUT_VARIABLE WINDOWS_VER_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)

	if(NOT "${WINDOWS_VER_OUTPUT}" STREQUAL "")
		if("${WINDOWS_VER_OUTPUT}" MATCHES "([0-9])+.([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+.([0-9])+" INFO_OS_HOST_VERSION "${WINDOWS_VER_OUTPUT}")
		elseif("${WINDOWS_VER_OUTPUT}" MATCHES "([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+" INFO_OS_HOST_VERSION "${WINDOWS_VER_OUTPUT}")
		elseif("${WINDOWS_VER_OUTPUT}" MATCHES "([0-9])+")
			string(REGEX MATCH "([0-9])+" INFO_OS_HOST_VERSION "${WINDOWS_VER_OUTPUT}")
		endif()

		set(INFO_OS_HOST_NAME "Windows 9x")
		set(INFO_OS_HOST_ARCH "x86")
	endif()
elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
	if(EXISTS "/etc/arch-release")
		set(INFO_OS_HOST_NAME "Arch Linux")
	endif()
elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin")
	execute_process(COMMAND "sw_vers" ERROR_QUIET OUTPUT_VARIABLE DARWIN_VER_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)

	if(NOT "${DARWIN_VER_OUTPUT}" STREQUAL "")
		if("${DARWIN_VER_OUTPUT}" MATCHES "([0-9])+.([0-9])+.([0-9])+")
			string(REGEX MATCH "([0-9])+.([0-9])+.([0-9])+" INFO_OS_HOST_VERSION "${DARWIN_VER_OUTPUT}")
		endif()

		if("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "10.7.0" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "10.7.0")
			set(INFO_OS_HOST_NAME "Mac OS X Lion")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "10.6.0" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "10.6.0")
			set(INFO_OS_HOST_NAME "Mac OS X Snow Leopard")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "10.5.0" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "10.5.0")
			set(INFO_OS_HOST_NAME "Mac OS X Leopard")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "10.4.0" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "10.4.0")
			set(INFO_OS_HOST_NAME "Mac OS X Tiger")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "10.3.0" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "10.3.0")
			set(INFO_OS_HOST_NAME "Mac OS X Pantner")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "10.2.0" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "10.2.0")
			set(INFO_OS_HOST_NAME "Mac OS X Jaguar")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "10.1.0" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "10.1.0")
			set(INFO_OS_HOST_NAME "Mac OS X Puma")
		elseif("${INFO_OS_HOST_VERSION}" VERSION_EQUAL "10.0" OR "${INFO_OS_HOST_VERSION}" VERSION_GREATER "10.0")
			set(INFO_OS_HOST_NAME "Mac OS X Cheetah")
		endif()
	endif()

	execute_process(COMMAND "uname" "-p" ERROR_QUIET OUTPUT_VARIABLE UNAME_ARCH_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)

	if(UNAME_ARCH_OUTPUT MATCHES "i[2-6]86|x86")
		set(INFO_OS_HOST_ARCH "x86")
	elseif(UNAME_ARCH_OUTPUT MATCHES "x86_64|amd64")
		set(INFO_OS_HOST_ARCH "x86_64")
	elseif(UNAME_ARCH_OUTPUT MATCHES "powerpc|ppc")
		set(INFO_OS_HOST_ARCH "ppc")
	endif()
endif()
