π Simplifying C++ Multi-Platform Builds
Simplifying C++ Multi-Platform Builds with a single Python script. It started out with only Bash scripts and using Cygwin for on Windows.
Cross-platform C++ development often means juggling multiple toolchains, environments, and build configurations.
After wrestling with this complexity, I built a unified solution using a comprehensive automation script for CMake builds,
which uses information from the presets json-configuration files.
What makes it powerful:
β
Multi-Toolchain Support β Seamlessly switch between GNU, MinGW, MSVC, and ARM (cross-)compilers
β
Cross-Platform Made Easy β Build for Linux, Windows, and ARM64 from a single environment
β
Nested Execution β Chain Docker and Wine environments for specialized builds (yes, MSVC builds on Linux!)
β
Interactive Interface β Optional menu system for selecting presets and targets
β
Smart Environment Management β Automatic toolchain configuration with INI-based inheritance
β
Complete Workflow Automation β Configure, build, test, package, and runβall in one command
β
CI/CD Pipeline Docker β Run a complete workflow for all toolchains in CI/CD pipeline
β
Run with Environment β Runs a build-target using the presets' environment
This approach has dramatically reduced build complexity in projects, enabling to focus on
code rather than environment configuration.
The script leverages CMakePresets.json (+ CMakeUserPresets.json), supports custom toolchain paths,
and handles the messy details of PATH variables, Wine prefixes, and Docker mounts automatically.
It allows building projects for multiple platforms and run the unittests on a single machine (Linux).
When necessary, the project can be built and debugged natively on any of the supported platforms.
π’ One unified interface for all platforms beats maintaining separate scripts for each toolchain.
Seeing is believing:
π¬ Boilerplate C++ project on Linux and Docker: https://youtu.be/124de2qlJ_M
π¬ Boilerplate C++ project on Windows: https://youtu.be/hlRSf4TdPtk
π¬ Piper1-GPL text-to-speech library: https://youtu.be/UL2fycF1sE8
#CPlusPlus #DevOps #BuildAutomation #CMake #CrossPlatform #DeveloperTools #SoftwareEngineering