set(CMAKE_SYSTEM_NAME Linux)
set(SDK_SYSROOT_DIR $ENV{SDK_SYSROOT_DIR})
set(SDK_TOOLCHAIN_DIR $ENV{SDK_TOOLCHAIN_DIR})
set(SDK_TARGET_TRIPLE $ENV{SDK_TARGET_TRIPLE})

if(NOT SDK_SYSROOT_DIR OR
  NOT SDK_TOOLCHAIN_DIR OR
  NOT SDK_TARGET_TRIPLE
)
  message(FATAL_ERROR
    "Please set all of SDK_TARGET_TRIPLE, SDK_SYSROOT_DIR and "
    "SDK_TOOLCHAIN_DIR in the environment when crosscompiling.")
endif()

set(CMAKE_SYSROOT ${SDK_SYSROOT_DIR})
set(CMAKE_C_COMPILER ${SDK_TOOLCHAIN_DIR}/bin/${SDK_TARGET_TRIPLE}-gcc)
set(CMAKE_CXX_COMPILER ${SDK_TOOLCHAIN_DIR}/bin/${SDK_TARGET_TRIPLE}-g++)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
