Just sharing a practical GitHub Actions workflow for testing cross-platform and cross-compilation builds - something many (if not the most) C++ projects eventually need.
👉 View the full YAML workflow here
It’s part of a small demo project that integrates another open-source project -- Areg SDK.
A quick note about Areg SDK for context:
it provides its own internal CMake variables (
AREG_*) to detect and configure target platforms, and these can be combined with standard CMake toolchain files for flexible cross-builds.The YAML demonstrates both methods:
Example 1: Using a Toolchain File for ARM32
Install the compiler first (!!!):
- name: Install GNU 32-bit ARM compilers
run: sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
Configure and build using a predefined toolchain file:
- name: Configure (ARM32 toolchain)
run: |
cmake -B ./product/cache/gnu-linux-arm32 \
-DCMAKETOOLCHAINFILE=${{github.workspace}}/toolchains/gnu-linux-arm32.cmake \
-DAREGEXTENDED:BOOL=OFF
- name: Build (ARM32)
run: cmake --build ./product/cache/gnu-linux-arm32 -j20
In this example, the project is configured in `./product/cache/gnu-linux-arm32`.
The build artifacts are generated in `./product/build/gnu-g++/linux-32-arm32-release-shared`, which follows Areg SDK’s *custom directory structure*. Your project may use a different layout.
**Example 2:** Using Areg SDK *Custom CMake Variables*
Same cross-build, but without a toolchain file:
- name: Configure (GNU on ARM32, shared)
run: cmake -B ./product/cache/gnu-arm-so \
-DAREGCOMPILERFAMILY=gnu \
-DAREGPROCESSOR=arm
- name: Build (GNU on ARM32, shared)
run: cmake --build ./product/cache/gnu-arm-so -j20
The workflow also includes additional configurations (x86, x86_64, ARM64). Sharing it as a ready-to-use reference for anyone building portable C++ projects that need to run across multiple architectures.
P.S. If this isn’t the right sub, feel free to point me to a better one.
https://redd.it/1ogm11y
@r_cpp