Add ARM64 cross compilation toolchain

This commit is contained in:
Louis Gombert 2024-10-27 20:15:39 +01:00
parent f6faeaacb7
commit 73d2c5803c
2 changed files with 17 additions and 7 deletions

View File

@ -152,24 +152,22 @@ Once CMake finishes, the built files will be put in `builds/linux/build/Debug` o
## Cross-compilation ## Cross-compilation
In order to cross-compile Descent3 to another platform (for example, Linux ARM64), you'll need to build auxiliary In order to cross-compile Descent3 to another platform (for example, Linux ARM64), you'll need to build auxiliary
tools which needed to build data files. First create build-native directory and configure project in it: tools natively which are needed to build data files. First create build-native directory and configure project in it:
```shell ```shell
mkdir build-native mkdir build-native
cd build-native cd build-native
cmake .. cmake ..
make HogMaker cmake --build . --target HogMaker
``` ```
Now you ready for cross-compilation. Create cross-compile directory and configure project in it, but this time add Now, you are ready for cross-compilation. Create a new cross-compilation build directory and configure the project in it, but this time specify the location of the HogMaker native executable just built, as well as the [toolchain file](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#id14) location. This enables the cross-compilation environment. An example toolchain file is provided for a Linux ARM64 build at `cmake/toolchains/linux-aarch64-gcc-toolchain.cmake`. The custom toolchain system can be used in combination with VCPKG to build all dependencies for the target system.
`-DCMAKE_TOOLCHAIN_FILE=MyToolchain.cmake` and `-DHogMaker_DIR=<path-to-Descent3/build-native/` options. This enables
cross-compilation environment.
```shell ```shell
mkdir build-cross mkdir build-cross
cd build-cross cd build-cross
cmake -DCMAKE_TOOLCHAIN_FILE=MyToolchain.cmake -DHogMaker_DIR=~/src/build-native/ .. cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/MyToolChain.cmake -DHogMaker_DIR=../build-native/ ..
make cmake --build .
``` ```
## Build Options ## Build Options

View File

@ -0,0 +1,12 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
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)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_CROSSCOMPILING ON)