cmake-multiplatform: fix for others than x86-64 #144
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CMake on multiple platforms | |
on: | |
workflow_dispatch: | |
push: | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
architecture: [aarch64-linux-gnu, ""] # arm-linux-gnueabihf | |
build_type: [RelWithDebInfo] # MinSizeRel | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install generic dependencies | |
run: | | |
sudo apt clean && sudo apt update | |
sudo apt-get -y install --no-install-recommends \ | |
curl \ | |
git \ | |
pkg-config \ | |
systemd \ | |
systemd-sysv \ | |
dbus \ | |
ca-certificates \ | |
build-essential \ | |
cmake \ | |
file \ | |
gdb | |
sudo apt-get -y remove \ | |
libzip-dev \ | |
libssl-dev \ | |
libcurl4-openssl-dev \ | |
libsqlite3-dev \ | |
libyaml-dev \ | |
libsystemd-dev \ | |
liburiparser-dev \ | |
uuid-dev \ | |
libevent-dev | |
- name: Install x86-64 dependencies / settings | |
if: matrix.architecture == '' | |
run: | | |
sudo apt-get -y install \ | |
cmake \ | |
build-essential \ | |
libcurl4-openssl-dev \ | |
libevent-dev \ | |
libssl-dev \ | |
libsqlite3-dev \ | |
libsystemd-dev \ | |
liburiparser-dev \ | |
libyaml-dev \ | |
libzip-dev \ | |
uuid-dev | |
echo "cmake_settings=" >> "$GITHUB_OUTPUT" | |
- name: Install arm64 dependencies / settings | |
if: matrix.architecture == 'aarch64-linux-gnu' | |
run: | | |
sudo apt-get remove -y \ | |
libcurl4-openssl-dev | |
sudo rm -rf /etc/apt/sources.list.d/* | |
cat << EOF | sudo tee -a /etc/apt/sources.list.d/cross-packages.list | |
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble main restricted universe multiverse | |
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main restricted universe multiverse | |
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main restricted universe multiverse | |
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-security main restricted universe multiverse | |
EOF | |
sudo dpkg --add-architecture arm64 | |
sudo apt clean && sudo apt update | |
sudo apt-get -y install \ | |
binutils-aarch64-linux-gnu \ | |
g++-aarch64-linux-gnu \ | |
gcc-aarch64-linux-gnu \ | |
libzip-dev:arm64 \ | |
libcurl4-openssl-dev:arm64 \ | |
libevent-dev:arm64 \ | |
libssl-dev:arm64 \ | |
libsqlite3-dev:arm64 \ | |
libsystemd-dev:arm64 \ | |
liburiparser-dev:arm64 \ | |
libyaml-dev:arm64 \ | |
libzip-dev:arm64 \ | |
uuid-dev:arm64 | |
cat << EOF | tee -a ${{ matrix.architecture }}.cmake | |
set(CMAKE_SYSTEM_NAME Linux) | |
set(CMAKE_SYSTEM_PROCESSOR aarch64) | |
set(CMAKE_SYSTEM_VERSION 1) | |
set(CMAKE_C_COMPILER_TARGET ${{ matrix.architecture }}) | |
set(CMAKE_CXX_COMPILER_TARGET ${{ matrix.architecture }}) | |
set(CMAKE_CROSSCOMPILING TRUE) | |
set(CMAKE_C_COMPILER_WORKS TRUE) | |
set(CMAKE_CXX_COMPILER_WORKS TRUE) | |
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | |
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | |
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | |
find_program(C_COMPILER_FULL_PATH NAMES ${{ matrix.architecture }}-gcc) | |
if(NOT C_COMPILER_FULL_PATH) | |
message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") | |
endif() | |
set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) | |
find_program(CXX_COMPILER_FULL_PATH NAMES ${{ matrix.architecture }}-g++) | |
if(NOT CXX_COMPILER_FULL_PATH) | |
message(FATAL_ERROR "C++ Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") | |
endif() | |
set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) | |
EOF | |
echo "CMAKE_SETTINGS=-DCMAKE_TOOLCHAIN_FILE=${{ matrix.architecture }}.cmake" >> "$GITHUB_ENV" | |
- name: Install arm32 dependencies / settings | |
if: matrix.architecture == 'arm-linux-gnueabihf' | |
run: | | |
sudo rm -rf /etc/apt/sources.list.d/* | |
cat << EOF | sudo tee -a /etc/apt/sources.list.d/cross-packages.list | |
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ noble main restricted universe multiverse | |
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main restricted universe multiverse | |
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main restricted universe multiverse | |
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ noble-security main restricted universe multiverse | |
EOF | |
sudo dpkg --add-architecture armhf | |
sudo apt clean && sudo apt update | |
sudo apt-get -y install \ | |
libc6-dev-armhf-cross \ | |
libc6-armhf-cross \ | |
binutils-arm-linux-gnueabihf \ | |
g++-arm-linux-gnueabihf \ | |
gcc-arm-linux-gnueabihf \ | |
libcurl4-openssl-dev:armhf \ | |
libevent-dev:armhf \ | |
libssl-dev:armhf \ | |
libsqlite3-dev:armhf \ | |
libsystemd-dev:armhf \ | |
liburiparser-dev:armhf \ | |
libyaml-dev:armhf \ | |
libzip-dev:armhf \ | |
uuid-dev:armhf \ | |
libcurl4-openssl-dev:armhf | |
cat << EOF | tee -a ${{ matrix.architecture }}.cmake | |
set(CMAKE_SYSTEM_NAME Linux) | |
set(CMAKE_SYSTEM_PROCESSOR arm) | |
set(CMAKE_SYSTEM_VERSION 1) | |
set(CMAKE_C_COMPILER_TARGET "${{ matrix.architecture }}") | |
set(CMAKE_CXX_COMPILER_TARGET "${{ matrix.architecture }}") | |
set(CMAKE_CROSSCOMPILING TRUE) | |
set(CMAKE_CROSSCOMPILING_EMULATOR qemu-arm-static -L /usr/${{ matrix.architecture }}/) | |
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | |
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | |
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | |
find_program(C_COMPILER_FULL_PATH NAMES ${{ matrix.architecture }}-gcc) | |
if(NOT C_COMPILER_FULL_PATH) | |
message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") | |
endif() | |
set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) | |
find_program(CXX_COMPILER_FULL_PATH NAMES ${{ matrix.architecture }}-g++) | |
if(NOT CXX_COMPILER_FULL_PATH) | |
message(FATAL_ERROR "C++ Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") | |
endif() | |
set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) | |
EOF | |
echo "CMAKE_SETTINGS=-DCMAKE_TOOLCHAIN_FILE=${{ matrix.architecture }}.cmake" >> "$GITHUB_ENV" | |
- name: Set reusable strings | |
id: strings | |
shell: bash | |
run: | | |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
- name: | |
Configure CMake ${{ matrix.build_type }} / ${{ matrix.architecture }} | |
shell: bash | |
run: | | |
export PKG_CONFIG_PATH=/usr/lib/${{ matrix.architecture }}/pkgconfig | |
echo PKG_CONFIG_PATH: $PKG_CONFIG_PATH | |
cmake \ | |
${{ env.CMAKE_SETTINGS }} \ | |
-B ${{ steps.strings.outputs.build-output-dir }} \ | |
-DCMAKE_INSTALL_PREFIX=/opt/aws-greengrass-lite \ | |
-DGGL_LOG_LEVEL=DEBUG \ | |
-S ${{ github.workspace }} \ | |
-DCMAKE_C_COMPILER_TARGET=${{ matrix.architecture }} \ | |
-DCMAKE_FIND_DEBUG_MODE=ON \ | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | |
- name: Build | |
run: | | |
make -C ${{ steps.strings.outputs.build-output-dir }} -j$(nproc) | |
- name: Package | |
working-directory: ${{ steps.strings.outputs.build-output-dir }} | |
run: | | |
cpack -G DEB | |
mkdir ${{ github.workspace }}/zipfile/ | |
cp ${{ steps.strings.outputs.build-output-dir }}/*.deb ${{ github.workspace }}/zipfile/ | |
- name: Generate readme / install file | |
run: | | |
cat ${{ github.workspace }}/.github/workflows/cmake-multi-platform/readme.template.txt >> ${{ github.workspace }}/zipfile/readme.txt | |
cp ${{ github.workspace }}/.github/workflows/cmake-multi-platform/install-greengrass-lite.sh ${{ github.workspace }}/zipfile/ | |
- name: Save package | |
uses: actions/upload-artifact@v4 | |
with: | |
name: aws-greengrass-lite-ubuntu-${{ matrix.architecture || 'x86-64'}}_${{ matrix.build_type }} | |
path: | | |
${{ github.workspace }}/zipfile/* | |
retention-days: 1 |