set(CMAKE_SYSTEM_NAME Windows)

if(NOT TOOLCHAIN_PATH)
  set(TOOLCHAIN_PATH /usr)
endif()
if(WIN32)
  set(TOOLCHAIN_SUFFIX .exe)
endif()
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)

set(TOOLCHAIN_BINDIR "${TOOLCHAIN_PATH}/bin")
set(TOOLCHAIN_LIBDIR "${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}/lib")
set(TOOLCHAIN_INCLUDEDIR "${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}/include")

set(CMAKE_C_COMPILER "${TOOLCHAIN_BINDIR}/${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "C Compiler")
set(CMAKE_CXX_COMPILER "${TOOLCHAIN_BINDIR}/${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "C++ Compiler")

set(CMAKE_SIZE "${TOOLCHAIN_BINDIR}/${TOOLCHAIN_PREFIX}-size${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "Size")
set(CMAKE_DEBUGER "${TOOLCHAIN_BINDIR}/${TOOLCHAIN_PREFIX}-gdb${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "Debugger")
set(CMAKE_OBJCOPY "${TOOLCHAIN_BINDIR}/${TOOLCHAIN_PREFIX}-objcopy${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "Objcopy")
set(CMAKE_OBJDUMP "${TOOLCHAIN_BINDIR}/${TOOLCHAIN_PREFIX}-objdump${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "Objdump")
set(CMAKE_CPPFILT "${TOOLCHAIN_BINDIR}/${TOOLCHAIN_PREFIX}-c++filt${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "C++filt")

set(CMAKE_FIND_ROOT_PATH "${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}" ${EXTRA_FIND_PATH})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
