Skip to content

Commit

Permalink
Create aarch64-toolchain.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravbug authored Aug 5, 2024
1 parent 249b0ca commit a26e4b8
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions aarch64-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# adapted from: https://vulkan.lunarg.com/issue/view/66adac57aa8cf92bbcfd1eb1

# Define our host system
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_CROSSCOMPILING 1)
set(CMAKE_SYSTEM_VERSION 1)

set(CROSS_PREFIX "aarch64-linux-gnu")
set(CURRENT_COMPILER_VERSION "-12")

# Define the cross compiler locations
if(NOT TOOLCHAIN_ROOT_DIR) # If the toolchain directory is not passed via command line
set(TOOLCHAIN_ROOT_DIR /usr/${CROSS_PREFIX})
endif()

# Check if the cross compiler is installed
if(NOT EXISTS "${TOOLCHAIN_ROOT_DIR}")
message(FATAL_ERROR "\
ARM toolchain is not installed.\n\
On debian based systems it can be installed by the commands\n\
sudo apt-get install g{cc,++}-aarch64-linux-gnu\n\
Or you can specify its location by specifying it via -DTOOLCHAIN_ROOT_DIR=")
endif()

include_directories(include ${TOOLCHAIN_ROOT_DIR}/local/include)

# Define our compilers
set(CMAKE_C_COMPILER ${CROSS_PREFIX}-gcc${CURRENT_COMPILER_VERSION})
set(CMAKE_CXX_COMPILER ${CROSS_PREFIX}-g++${CURRENT_COMPILER_VERSION})

# Define the sysroot
set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_ROOT_DIR})
message(STATUS "Searching for ARM toolchain in: ${CMAKE_FIND_ROOT_PATH}")

# Use our definitions for compiler tools
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Search for libraries and headers in the target directories only
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(ASM aarch64-linux-gnu-as)

0 comments on commit a26e4b8

Please sign in to comment.