1SET(CMAKE_SYSTEM_NAME Linux) 2SET(CMAKE_SYSTEM_PROCESSOR aarch64) 3 4# Toolchain precedence: environment variable TROUT_CLANG_PATH > LV Clang Toolchain 5# AGL sysroot precedence: environment variable TROUT_AGL_SYSROOT > LV AGL sysroot 6IF(DEFINED ENV{LV_BUILD_PATH}) 7 SET(TROUT_CLANG_PATH $ENV{LV_BUILD_PATH}/tmp-glibc/sysroots-components/x86_64/clang-native) 8 SET(TROUT_AGL_SYSROOT $ENV{LV_BUILD_PATH}/tmp-glibc/sysroots/opsy-sa8155/) 9ENDIF() 10 11IF (DEFINED ENV{TROUT_CLANG_PATH}) 12 SET(TROUT_CLANG_PATH $ENV{TROUT_CLANG_PATH}) 13ENDIF() 14 15IF (DEFINED ENV{TROUT_AGL_SYSROOT}) 16 SET(TROUT_AGL_SYSROOT $ENV{TROUT_AGL_SYSROOT}) 17ENDIF() 18 19IF (NOT TROUT_CLANG_PATH) 20 MESSAGE(FATAL_ERROR "Please run `lunch`, or define environment variable LV_BUILD_PATH or TROUT_CLANG_PATH") 21ENDIF() 22 23IF (NOT TROUT_AGL_SYSROOT) 24 MESSAGE(FATAL_ERROR "Please define environment variable LV_BUILD_PATH or TROUT_AGL_SYSROOT") 25ENDIF() 26 27SET(_triple aarch64-none-linux-gnu) 28 29SET(CMAKE_CROSSCOMPILING TRUE) 30SET(CMAKE_SYSROOT ${TROUT_AGL_SYSROOT}) 31 32SET(CMAKE_C_COMPILER ${TROUT_CLANG_PATH}/usr/bin/clang) 33SET(CMAKE_C_COMPILER_TARGET ${_triple}) 34 35SET(CMAKE_CXX_COMPILER ${TROUT_CLANG_PATH}/usr/bin/clang++) 36SET(CMAKE_CXX_COMPILER_TARGET ${_triple}) 37 38SET(CMAKE_ASM_COMPILER_TARGET ${_triple}) 39 40SET(CMAKE_AR ${TROUT_CLANG_PATH}/usr/bin/llvm-ar) 41SET(CMAKE_NM ${TROUT_CLANG_PATH}/usr/bin/llvm-nm) 42SET(CMAKE_RANLIB ${TROUT_CLANG_PATH}/usr/bin/llvm-ranlib) 43 44SET(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES 45 ${TROUT_AGL_SYSROOT}/usr/include/c++/9.3.0 46 ${TROUT_AGL_SYSROOT}/usr/include/c++/9.3.0/aarch64-oe-linux 47) 48 49SET(CMAKE_EXE_LINKER_FLAGS 50 -fuse-ld=lld 51 -B ${TROUT_AGL_SYSROOT}/usr/lib/aarch64-oe-linux/9.3.0 52 -nodefaultlibs 53 -lstdc++ 54 -lm 55 -lc 56 -lgcc_s 57) 58STRING(REPLACE ";" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") 59 60SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 61SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 62SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 63SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 64