include(${CMAKE_CURRENT_LIST_DIR}/../cmake/devkitPro.cmake)

if(DEFINED ENV{LIBNX})
	set(LIBNX $ENV{LIBNX})
else()
	set(LIBNX ${DEVKITPRO}/libnx)
endif()

set(cross_prefix aarch64-none-elf-)
set(arch_flags "-mtune=cortex-a57 -ffunction-sections -march=armv8-a+crc+crypto -mtp=soft -fPIE")
set(inc_flags "-I${LIBNX}/include ${arch_flags}")
set(link_flags "-L${LIBNX}/lib -lnx -specs=${LIBNX}/switch.specs ${arch_flags}")

set(CMAKE_SYSTEM_PROCESSOR aarch64 CACHE INTERNAL "processor")
set(CMAKE_LIBRARY_ARCHITECTURE aarch64-none-elf CACHE INTERNAL "abi")

set(SWITCH ON)
add_definitions(-D__SWITCH__)

create_devkit(A64)

set(CMAKE_FIND_ROOT_PATH ${DEVKITA64}/${CMAKE_LIBRARY_ARCHITECTURE} ${DEVKITPRO}/portlibs/switch)
