Home

Awesome

Arduino-CMake NG

AppVeyorTravis CI

Arduino-CMake is a framework which allows developers to write Arduino-based programs using any tool that supports cmake. Arduino-based? There are many other frameworks out there built upon Arduino's base, such as ESP32, and we respect that (Note that it doesn't mean we support it yet).
In other words, developers can use their favorite IDEs or text editors on their favorite OS to develop Arduino programs!

Wait - Hasn't it been possible all this time? Apparently not. You can read more about it in the Motivation section.

Note to new users: The master branch is used for active development only, so if you seek to simply use the framework then you should head to the releases section instead!

Important Notice

This project is dead and is no longer maintained! You can find more info here.
However, there's a new framework named Arduino-CMake-Toolchain that took the basis of this project and continued it very well - Please use it!

Features

Arduino-CMake should<sup id="fl1">1</sup> do almost<sup id="fl2">2</sup> <u>anything</u> that the Arduino IDE does!

What's supported?

It's also worth mentioning that Arduino-CMake is <u>cross platform</u> and works out-of-the-box on every OS that support CMake and Arduino.

<b id="f1">1</b> The framework is still a WIP, meaning there are some missing features.
<b id="f2">2</b> The Arduino IDE supports several concepts which make writing code easier but are completely unprofessional. Our framework is not willing to encourage such poor coding standards, and thus doesn't support them. These will be mentioned throughout the documentation.

Usage

A very basic example of how Arduino-CMake can be used is listed below:

# Define CMake's minimum version (must-do) and the project's name and supported languages
cmake_minimum_required(VERSION 3.8.2)
project(Hello_World)

# Call a framework utility function, passing it information about the hardware board that will be used - This function returns a structure known only to the framework
get_board_id(board_id nano atmega328)

# Create an executable suitable for Arduino using CMake-style target-creation
add_arduino_executable(Hello_World ${board_id} helloWorld.cpp)
# Upload the created target through a connected Serial Port (Where your board is connected to)
upload_arduino_target(Hello_World "${board_id}" COM3)

You should then call CMake (either through cmd, cmake-gui or an IDE if it supports that), passing it the argument -DCMAKE_TOOLCHAIN_FILE=[project_path]/cmake/Arduino-Toolchain.cmake where [project_path] is substituted by the project's full path. This is what allows cmake to use our framework.

That's it! It's super simple, yet super extensible :)

Motivation

Everyone has their favorite IDE or text editor, and would like to continue using it as long as they can. Upon encountering a framework that doesn't support it - We get frustrated. Unfortunately that's often the case with the Arduino framework, as it offers a custom toolchain that makes it uncomfortable to use outside the dedicated Arduino IDE.

Arduino-CMake solves it by creating a framework leveraging all of Arduino's features, including its' custom toolchain, by adding a single dependency - The CMake build system.

Project Roots

The original project started back in 2011 by queezythegreat and had been actively developed until 2014, when it had been abandoned due to unknown reasons. Since then more than 150 (!) forks have emerged, leading to a "chaos" in the Arduino-CMake sphere. The most important moment however was in 2017, when a combined effort by JonasProgrammer and MrPointer has brought new life to the project in the face of the arduino-cmake organization. And yet, it still had its own problems, leading once again to an abandoned state.

Then, in 2018, an extreme effort has been made and the project has been completely rewritten (mostly by MrPointer) with a few very clear goals in mind:

How it works

Arduino programs are simply C/C++ programs which take advantage of a framework which allows them to run on specific hardware devices. It means that those programs need to be compiled somehow. Back in the "old days" developers used compilers such as gcc directly from the command line. Then came build-tools such as make. Then came CMake. Most of the modern build systems today are managed by CMake and most of the modern IDEs know that and take advantage of it. But what's really useful in CMake, at least regarding our Arduino world, is the ability to cross-compile with a toolchain. The Arduino SDK, which one usually downloads together with the Arduino IDE, is actually also a toolchain, as it includes the required compilation & linkage tools for cross-compiling. Analyzing the SDK allows us to build a framework using this toolchain, and also all of Arduino's other cool features such as libraries, examples, etc.

What is NG

NG stands for "New Generation". Inferred from the written above, it can easily be understood why the project has this name. However, if you don't think this name is good enough or it confuses you - Feel free to propose a name of your own, we're open for offers :)

Requirements

The following list is the basic requirements of the framework in order to use it:

Installation

First, make sure to download the latest release of the framework.
Further instructions can be found in the Installation Wiki page.

Documentation

The entire documentation of the project is hosted on GitHub using Wiki pages.

Contributing

The project has strict contributing guidelines which can be found in the Contributing File.

License

MIT © 2018 Arduino-CMake