From 401be9c8b961cd4fcb6e5d58200dcd06a8c246b2 Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Wed, 11 Nov 2020 12:31:47 +0100 Subject: [BUILD] add CMake toolchain files to cross-compile for ppc and aarch64 --- README.md | 20 ++++++++++++++++++++ cmake/toolchain/Aarch64LinuxGnu.cmake | 24 ++++++++++++++++++++++++ cmake/toolchain/PowerpcLinuxGnu.cmake | 24 ++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 cmake/toolchain/Aarch64LinuxGnu.cmake create mode 100644 cmake/toolchain/PowerpcLinuxGnu.cmake diff --git a/README.md b/README.md index d8e390e..a46423e 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,26 @@ A value from the range of appropriate values can be assigend to each configurati cmake -D= [-D ...] ../. ``` +With the help of CMake, it is also possible to cross-compile the dnbd3 components for a Linux target architecture other than the compiling Linux host architecture. This repository is shipped with two CMake toolchain files to cross-compile all components for the following two Linux target architectures if necessary. + +> **Note that all used header files (eg. Linux kernel headers) and libraries (eg. jansson, fuse) for the target architecture are installed and set up properly, so that the cross-compiler can find and use them.** + + +#### Cross-Compiling for _powerpc_ Target +If you want to cross-compile all dnbd3 components for the _powerpc_ Linux target architecture (eg. for a Mac G5), make sure that the `powerpc-linux-gnu-gcc` cross-compiler is installed on your host system. Then, call CMake with the shipped toolchain file for this specific cross-compiler as follows. + +```shell +cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/PowerpcLinuxGnu.cmake [-D ...] ../. +``` + + +#### Cross-Compiling for _aarch64_ Target +If you want to cross-compile all dnbd3 components for the _aarch64_ Linux target architecture (eg. for a Raspberry Pi 4), make sure that the `aarch64-linux-gnu-gcc` cross-compiler is installed on your host system. Then, call CMake with the shipped toolchain file for this specific cross-compiler as follows. + +```shell +cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/Aarch64LinuxGnu.cmake [-D ...] ../. +``` + ### Debug In the `Debug` build configuration, all dnbd3 components can be built by calling `make`: diff --git a/cmake/toolchain/Aarch64LinuxGnu.cmake b/cmake/toolchain/Aarch64LinuxGnu.cmake new file mode 100644 index 0000000..59c5f00 --- /dev/null +++ b/cmake/toolchain/Aarch64LinuxGnu.cmake @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# CMAKE toolchain file for cross compilation with aarch64-linux-gnu-gcc +# +# Copyright (C) 2020 Manuel Bentele +# + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) +set(CMAKE_LINKER aarch64-linux-gnu-ld) +set(CMAKE_ASM_COMPILER aarch64-linux-gnu-as) +set(CMAKE_OBJCOPY aarch64-linux-gnu-objcopy) +set(CMAKE_STRIP aarch64-linux-gnu-strip) +set(CMAKE_CPP aarch64-linux-gnu-cpp) + +# path of headers and libraries for aarch64-linux-gnu target +set(CMAKE_FIND_ROOT_PATH "/usr/aarch64-linux-gnu") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/toolchain/PowerpcLinuxGnu.cmake b/cmake/toolchain/PowerpcLinuxGnu.cmake new file mode 100644 index 0000000..d3c1ca5 --- /dev/null +++ b/cmake/toolchain/PowerpcLinuxGnu.cmake @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# CMAKE toolchain file for cross compilation with powerpc-linux-gnu-gcc +# +# Copyright (C) 2020 Manuel Bentele +# + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR ppc) + +set(CMAKE_C_COMPILER powerpc-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER powerpc-linux-gnu-g++) +set(CMAKE_LINKER powerpc-linux-gnu-ld) +set(CMAKE_ASM_COMPILER powerpc-linux-gnu-as) +set(CMAKE_OBJCOPY powerpc-linux-gnu-objcopy) +set(CMAKE_STRIP powerpc-linux-gnu-strip) +set(CMAKE_CPP powerpc-linux-gnu-cpp) + +# path of headers and libraries for powerpc-linux-gnu target +set(CMAKE_FIND_ROOT_PATH "/usr/powerpc-linux-gnu") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -- cgit v1.2.3-55-g7522