cmake_minimum_required(VERSION 2.6)

### compiler

if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
		if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
                set(TOOL_CHAIN_DIR "C:/Qt/Tools/mingw492_32/bin")
                list(APPEND CMAKE_LIBRARY_PATH "C:/Qt/Tools/mingw492_32/i686-w64-mingw32")
		elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU64")
                set(TOOL_CHAIN_DIR "C:/Qt/Tools/mingw492_64/bin")
	endif()
    set(TOOL_CXX     "g++.exe")
	set(TOOL_C       "gcc.exe")
	set(TOOL_AR      "ar.exe")
	set(TOOL_RC      "windres.exe")
	set(TOOL_NM      "nm.exe")
	set(TOOL_OBJCOPY "objcopy.exe")
	set(TOOL_OBJDUMP "objdump.exe")
	set(TOOL_RANLIB  "ranlib.exe")
	set(TOOL_STRIP   "strip.exe")
	set(TOOL_LINK    "ld.exe")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
		if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
				set(CMAKE_C_COMPILER_ID "Clang")
				set(TOOL_CXX "clang++")
				set(TOOL_C   "clang")
		elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
				set(TOOL_CXX "g++")
				set(TOOL_C   "gcc")

		endif()
	set(TOOL_CHAIN_DIR "/usr/bin")
	set(TOOL_RC        "rc")
	set(TOOL_AR        "ar")
	set(TOOL_NM        "gcc-nm")
	set(TOOL_OBJCOPY   "objcopy")
	set(TOOL_OBJDUMP   "objdump")
	set(TOOL_RANLIB    "gcc-ranlib")
	set(TOOL_STRIP     "strip")
	set(TOOL_LINK      "ld")
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")

set(CMAKE_CXX_COMPILER "${TOOL_CHAIN_DIR}/${TOOL_CXX}")
set(CMAKE_C_COMPILER   "${TOOL_CHAIN_DIR}/${TOOL_C}")
set(CMAKE_AR           "${TOOL_CHAIN_DIR}/${TOOL_AR}")
set(CMAKE_RC_COMPILER  "${TOOL_CHAIN_DIR}/${TOOL_RC}")
set(CMAKE_NM           "${TOOL_CHAIN_DIR}/${TOOL_NM}")
set(CMAKE_OBJCOPY      "${TOOL_CHAIN_DIR}/${TOOL_OBJCOPY}")
set(CMAKE_OBJDUMP      "${TOOL_CHAIN_DIR}/${TOOL_OBJDUMP}")
set(CMAKE_RANLIB       "${TOOL_CHAIN_DIR}/${TOOL_RANLIB}")
set(CMAKE_STRIP        "${TOOL_CHAIN_DIR}/${TOOL_STRIP}")
set(CMAKE_LINKER       "${TOOL_CHAIN_DIR}/${TOOL_LINK}")
