include(CMakeForceCompiler)

set(CMAKE_SYSTEM_NAME Generic)
set(PLATFORM_NAME "nuttx")

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 BOTH)

# Compiler tools
foreach(tool gcc ld ar)
	string(TOUPPER ${tool} TOOL)
    find_program(${TOOL} @CROSSDEV@${tool})
	if(NOT ${TOOL})
		message(FATAL_ERROR "could not find ${tool}")
	endif()
endforeach()

set(CMAKE_C_COMPILER @CROSSDEV@gcc)
set(CMAKE_CXX_COMPILER @CROSSDEV@g++)

SET(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "")
SET(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "")

include_directories(SYSTEM ${CMAKE_SYSROOT}/include)
add_compile_options(
    -std=c99
    @ARCH_CPU_FLAGS@
    @ARCH_OPT_FLAGS@
    )
