SET(CMAKE_SYSTEM_NAME Linux) SET(CMAKE_SYSTEM_PROCESSOR aarch64) # Toolchain precedence: environment variable TROUT_CLANG_PATH > LV Clang Toolchain # AGL sysroot precedence: environment variable TROUT_AGL_SYSROOT > LV AGL sysroot IF(DEFINED ENV{LV_BUILD_PATH}) SET(TROUT_CLANG_PATH $ENV{LV_BUILD_PATH}/tmp-glibc/sysroots-components/x86_64/clang-native) SET(TROUT_AGL_SYSROOT $ENV{LV_BUILD_PATH}/tmp-glibc/sysroots/opsy-sa8155/) ENDIF() IF (DEFINED ENV{TROUT_CLANG_PATH}) SET(TROUT_CLANG_PATH $ENV{TROUT_CLANG_PATH}) ENDIF() IF (DEFINED ENV{TROUT_AGL_SYSROOT}) SET(TROUT_AGL_SYSROOT $ENV{TROUT_AGL_SYSROOT}) ENDIF() IF (NOT TROUT_CLANG_PATH) MESSAGE(FATAL_ERROR "Please run `lunch`, or define environment variable LV_BUILD_PATH or TROUT_CLANG_PATH") ENDIF() IF (NOT TROUT_AGL_SYSROOT) MESSAGE(FATAL_ERROR "Please define environment variable LV_BUILD_PATH or TROUT_AGL_SYSROOT") ENDIF() SET(_triple aarch64-none-linux-gnu) SET(CMAKE_CROSSCOMPILING TRUE) SET(CMAKE_SYSROOT ${TROUT_AGL_SYSROOT}) SET(CMAKE_C_COMPILER ${TROUT_CLANG_PATH}/usr/bin/clang) SET(CMAKE_C_COMPILER_TARGET ${_triple}) SET(CMAKE_CXX_COMPILER ${TROUT_CLANG_PATH}/usr/bin/clang++) SET(CMAKE_CXX_COMPILER_TARGET ${_triple}) SET(CMAKE_ASM_COMPILER_TARGET ${_triple}) SET(CMAKE_AR ${TROUT_CLANG_PATH}/usr/bin/llvm-ar) SET(CMAKE_NM ${TROUT_CLANG_PATH}/usr/bin/llvm-nm) SET(CMAKE_RANLIB ${TROUT_CLANG_PATH}/usr/bin/llvm-ranlib) SET(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${TROUT_AGL_SYSROOT}/usr/include/c++/9.3.0 ${TROUT_AGL_SYSROOT}/usr/include/c++/9.3.0/aarch64-oe-linux ) SET(CMAKE_EXE_LINKER_FLAGS -fuse-ld=lld -B ${TROUT_AGL_SYSROOT}/usr/lib/aarch64-oe-linux/9.3.0 -nodefaultlibs -lstdc++ -lm -lc -lgcc_s ) STRING(REPLACE ";" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") 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 ONLY)