if(NOT ${CMAKE_C_COMPILER} MATCHES "icc.*$")
    ERROR("Intel Compiler required for first generation Intel Xeon Phi!")
endif()
if("$ENV{MPSS_SYSROOTS}" STREQUAL "")
    ERROR("MPSS not found!")
endif()

if($ENV{MPSS_VERSION} MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
    set(MPSS_VERSION $ENV{MPSS_VERSION})
else()
    set(MPSS_VERSION $ENV{MPSS_VERSION}.0)
endif()

string(REPLACE "." "" MPSS_VERSION ${MPSS_VERSION})

if(${MPSS_VERSION} LESS 370)
    ERROR("MPSS too old! Require at least Intel MPSS 3.7")
endif()

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR k1om)
set(CMAKE_SYSTEM_VERSION 1)
set(_CMAKE_TOOLCHAIN_PREFIX  x86_64-k1om-linux-)
set(CMAKE_FIND_ROOT_PATH $ENV{MPSS_SYSROOTS}/k1om-mpss-linux)
set(CMAKE_C_FLAGS "-mmic ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-mmic ${CMAKE_CXX_FLAGS}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/mic)
set(CMAKE_EXECUTABLE_SUFFIX ".mic")

INFO("Building for first generation Intel Xeon Phi.")
