set(CMAKE_SYSTEM_NAME QNX)
set(CMAKE_SYSTEM_VERSION 6.6.0)
set(CMAKE_SYSTEM_PROCESSOR armv7)
set(TOOLCHAIN QNX)

if(CMAKE_HOST_WIN32)
	set(HOST_EXECUTABLE_SUFFIX ".exe")
endif(CMAKE_HOST_WIN32)

find_path(QNX_HOST
	NAME usr/bin/qcc${HOST_EXECUTABLE_SUFFIX}
	PATHS $ENV{QNX_HOST}
	NO_CMAKE_PATH
	NO_CMAKE_ENVIRONMENT_PATH
)

if(!QNX_HOST)
	message(WARNING "QNX_HOST not found (ENV{QNX_HOST}: $ENV{QNX_HOST})")
endif()

find_path(QNX_TARGET
	NAME usr/include/errno.h
	PATHS $ENV{QNX_TARGET}
	NO_CMAKE_PATH
	NO_CMAKE_ENVIRONMENT_PATH
)

if(!QNX_TARGET)
	message(WARNING "QNX_TARGET not found (ENV{QNX_TARGET}: $ENV{QNX_TARGET})")
endif()

set(CMAKE_FIND_ROOT_PATH ${QNX_TARGET})
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_C_COMPILER ${QNX_HOST}/usr/bin/nto${CMAKE_SYSTEM_PROCESSOR}-gcc${HOST_EXECUTABLE_SUFFIX})
set(CMAKE_CXX_COMPILER ${QNX_HOST}/usr/bin/nto${CMAKE_SYSTEM_PROCESSOR}-g++${HOST_EXECUTABLE_SUFFIX})

