How about using CMake to build your Arduino projects?
How about using CMakeLists.txt
files as simple as this?
cmake_minimum_required(VERSION 3.19)
project(CMakeBlink LANGUAGES CXX)
add_executable(CMakeBlink CMakeBlink.ino)
This all can be done using Arduino CLI. This toolchain is fully based upon this really great tool: There are no tricks, no hacks, no manual parsing of obscure text files at undocumented locations. Just the official API and some pretty straight forward CMake. That's the main principle of this toolchain file, and that's what hopefully makes it more robust than any other Arduino toolchain file before (— famous last words).
This project is in early development. So far nothing more than a fairly successful proof of concept.
#include <Arduino.h>
in the main sketch.Check "ready for public announcement" to see what's missing.
The following Arduino platforms are tested automatically:
Anyway, if you got some spare time, feel free to try out, to test, to give feedback, to contribute.
In general just configure your project like this:
cmake -S ~/Arduino/YourProject \
--toolchain PATH-TO/arduino-cli-toolchain.cmake \
-D ARDUINO_BOARD=arduino:avr:nano
The parameter ARDUINO_BOARD
is mandatory and provides your device's FQBN to the toolchain.
For more information about the FQBN string, or so called "fully qualified board names" visit the Arduino CLI wiki.
-DCMAKE_TOOLCHAIN_FILE:PATH=/YOUR/PATH/TO/cmake-toolchain-arduino-cli/toolchain/arduino-cli-toolchain.cmake
-DARDUINO_BOARD:STRING=esp8266:esp8266:nodemcuv2:baud=512000
Here you go! You are ready to open CMake based Arduino projects in QtCreator.
This toolchain file, its related tools, tests, and examples are provided by under the terms of the MIT License.
This project would not have been possible without all the previous hard work Arduino-CMake-Toolchain. I took good inspiration from it, especially when it comes to making CMake's initial compiler detection accept Arduinos very special binary layout.