Arduino CMake Build system

Overview

Arduino Cmake Example Project

This is the Cmake project settings for the Arduino platform. You can use this project as an example to develop C++ programs in JetBrains CLion IDE for Arduino and using toolchain from Arduino IDE 1.6+.

This project correctly works and tested in Windows with MinGW, but it should work in linux and mac with standard cmake/make pakages.

Original cmake project is licensed with Mozilla Public License, v. 2.0 http://mozilla.org/MPL/2.0/

Readme from the original project is moved to /README.original.rst. You can find all the authors and contributors there.

Usefull links

Original project URI: https://github.com/queezythegreat/arduino-cmake

Current project is it's fork with patches from pull requests https://github.com/queezythegreat/arduino-cmake/pulls and with my patches that fixes some major and minor bugs as long as adds other new features.

Some examples are taken from this article http://habrahabr.ru/post/247017/

Differencies between this project and original one

  1. Added patch "Adding support for SDK 1.5" https://github.com/queezythegreat/arduino-cmake/pull/104 Added support for Arduino IDE 1.5-1.6+.

  2. Added patch "fixed bug in find_file method" https://github.com/queezythegreat/arduino-cmake/pull/109 Now cmake project does not search for arduino toolchain files in standard windows paths.

  3. Added patch "Fix CMP0038 warnings on CMake >= 3.0" https://github.com/queezythegreat/arduino-cmake/pull/143 Removed warnings.

  4. Fixed windows paths to avr-size command. Now we can see the size of the compiled arduino program.

  5. Fixed parsing of the boards.txt settings that are used for compilation of the boards (that differs from arduino mega).

  6. All compilation settings are taken from original Arduino IDE. But i dont think i've done it the best way so you can try do better if you want.

  7. Removed any differences between all build flavors (debug, release, etc). This is descructive difference between this fork and original project, that is why you should not try to merge this fork into original project. I make it because i dont have enough experience in finding the best compile options for these different build types. So now it uses original Arduino IDE options.

  8. Original Readme is saved in README.original.rst

Installing CLion + Arduino IDE + MinGW

  1. Install MinGW (needed for CLion, includes make, g++, cpp)

This is needed only for windows. In different OS'es you should skip this and continue to the next - "2. Install Arduino IDE".

1.1. Installing MinGW http://sourceforge.net/projects/mingw/files/Installer/ Tested on version mingw-get-0.6.2-mingw32-beta-20131004-1

1.2. Run MinGW Installation Manager

1.3. Choose packages from "Basic Setup" - mingw-developer-toolkit - mingw32-base - mingw32-gcc-g++ - msys-base and push "Apply Changes"

  1. Install Arduino IDE 1.6 (needed for building the project, includes avr toolchain) http://www.arduino.cc/en/Main/OldSoftwareReleases Tested on version 1.6.3

  2. Install and setup JetBrains CLion 1.0

3.1. Install JetBrains CLion 1.0 https://www.jetbrains.com/clion/ Test on version 1.0

3.2. Run CLion

3.3. Setup toolchain Menu settings "File" -> "Settings" Choose "Build, Execudion, Deployment" -> "Toolchain" Setup - Env: MinGW "c:\mingw" - cmake: "bundled cmake"

MinGW option only exists in windows.

All is done, you can open project in CLion.

How to move you existing project from Arduino IDE

For example, you have your own project named Robot with the following files

  • /Robot.ino
  • /Chassis.cpp
  • /Chassis.h that already works in Arduino IDE, and you want to move it to CLion IDE.
  1. Make new project with name arduino-cmake-robot Clone this repository: git clone {THIS_REPO_URI} arduino-cmake-robot

We do not need origin any more, we will use our own project repository. Remove origin: git remote rm origin

  1. Copy our existing project files Robot Make folder /robot in the root of new project. Copy files into this folder. Now we have 3 new files in new project

    • /robot/Robot.ino
    • /robot/Chassis.cpp
    • /robot/Chassis.h
  2. Rename Robot.ino into robot.cpp Now our new files and folders structure is like the following:

    • /robot/robot.cpp
    • /robot/Chassis.cpp
    • /robot/Chassis.h
  3. Add standard Arduino library Add the following line before the very first line of the /robot/robot.cpp file #include "Arduino.h"

  4. Make file with cmake build settings Copy /example/CMakeLists.txt into /robot/CMakeLists.txt

  5. Setup CMakeLists.txt for "robot" project (/robot/CMakeLists.txt) Set up the name of the project set(PROJECT_NAME robot)

Set up the target platform. Example 1. For Arduino Pro (Arduino Pro Mini) it should look like this set(${PROJECT_NAME}_BOARD pro) Example 2. For Arduino UNO set(${PROJECT_NAME}_BOARD uno)

Set up the name of the file, that was previously with INO extension set(${PROJECT_NAME}_SRCS robot.cpp) Set up target COM port, which is connect to the board set(${PROJECT_NAME}_PORT COM3)

  1. Set up root folder CMakeLists.txt (/CMakeLists.txt) Choose correct CPU option for the board. This name is located in the file C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt This is windows path. For other OS'es it will look similar to "hardware\arduino\avr\boards.txt".

Example 1. For Arduino Pro 16Mhz 5V ATmega 328 we can file the line "pro.menu.cpu.16MHzatmega328=ATmega328 (5V, 16 MHz)" and than take correct CPU ID "16MHzatmega328", but not the value "ATmega328 (5V, 16 MHz)" set(ARDUINO_CPU 16MHzatmega328) Example 2. For Arduino UNO where is no need to define anything, just comment out the CPU ID line, because Arduino UNO does not have different CPU options # (commented) set(ARDUINO_CPU 16MHzatmega328)

Add project folder, change "example" to "robot" # (commented) add_subdirectory(example) add_subdirectory(robot)

  1. Open project in CLion IDE and choose build option "robot" (for compilation only)
    or "robot_upload" (for compilation and upload).
    Build project (CTRL+F9). After that project starts to build and upload to the Arduino board.
Comments
  • Suport for ESP32 using Arduino libs

    Suport for ESP32 using Arduino libs

    This PR is a follow-up of https://github.com/francoiscampbell/arduino-cmake/pull/7 and adds support for compiling programs for an Espressif ESP32 chip.

    In my tests I used an Adafruit Feather ESP32. It also adds an example for using the Access Point on ESP32

    opened by Pro 1
  • Respect CMake include path when searching for library dependency directories

    Respect CMake include path when searching for library dependency directories

    When I tried to combine "cmake lzz" and arduino-cmake, I stumped (among several other things) upon the issue of arduino-cmake not searching for header files in the cmake include_directories. This patch fixes that oversight.

    opened by ntninja 0
  • Bug fix: Allow linking for sketches

    Bug fix: Allow linking for sketches

    Currently running generate_arduino_firmware overwrites ALL_SRCS. This PR fixes that and also ensures that a change to a source results in recompiling the generated file.

    opened by staadecker 0
  • Я осмотрел, что почему этот ardunio-cmake не работает на ardunio UNO.

    Я осмотрел, что почему этот ardunio-cmake не работает на ardunio UNO.

    Поэтому сейчас хорошо работает ardunio-cmake на ardunio UNO. И я перестроил пример example.cpp, чтобы начинающий сразу принял движение. Я сделал испытание на Ubuntu 18.04.1 LTS.

    opened by piwikjapan 0
  • Include ASM files

    Include ASM files

    Some core Arduino libraries involve assembly files (ex: wiring_pulse.S), which are not included and can lead to build errors when the functions contained in these libraries are needed.

    opened by nikkoura 0
  • Add support for nightly build version.

    Add support for nightly build version.

    lib/version.txt just contain "nightly", which make CMAKE can not detect the SDK version. By setting the PARSED_VERSION="1.6.12" manually when detect "nightly" on lib/version.txt to solve this issue.

    opened by kamyuentse 0
  • Add LIBS input property to GENERATE_ARDUINO_EXAMPLE

    Add LIBS input property to GENERATE_ARDUINO_EXAMPLE

    This allows users to add static libraries to fix linking errors with generate_arduino_example that can sometimes occur.

    Some arduino examples with multiple dependencies give linking errors (undefined references) when built with the generate_arduino_example command. For example,

    generate_arduino_example(cardinfo-ex 
          LIBRARY SD
          EXAMPLE CardInfo
          BOARD pro) 
    

    Will fail to properly link with the SPI library. There is possibly a way to fix this under-the-hood with improved dependency discovery. I don't know where to start with this. As work-around that is perfectly consistent with the other arduino-cmake function, this change adds the LIBS input argument to generate_arduino_example. This works like the existing LIBS inputs on generate_arduino_firmware and generate_arduino_library

    The user can now use generate_arduino_library to create a static library for SPI, and then build the example with

    generate_arduino_example(cardinfo-ex 
          LIBRARY SD
          EXAMPLE CardInfo
          LIBS SPI #SPI target created with generate_arduino_library
          BOARD pro) 
    

    The cmake source code for the generate_arduino_example already handled this input since it contains list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS}), so no changes were necessary for the function itself.

    Hopefully this is helpful.

    opened by ryanpfeeley 0
Releases(1.1.0)
Owner
Francois Campbell
Francois Campbell
An Enhancement Suite for the CMake Build System

A CMake Enhancement Suite Usage Look through the files in the package. Most functions will be commented and the other's usage can be inferred. All fun

Tobias Becker 400 Nov 9, 2022
📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.

Setup-free CMake dependency management CPM.cmake is a CMake script that adds dependency management capabilities to CMake. It's built as a thin wrapper

CPM.cmake 1.5k Nov 25, 2022
CMake checks cache helper modules – for fast CI CMake builds!

cmake-checks-cache Cross platform CMake projects do platform introspection by the means of "Check" macros. Have a look at CMake's How To Write Platfor

Cristian Adam 64 Nov 18, 2022
CMake scripts for painless usage of SuiteSparse+METIS from Visual Studio and the rest of Windows/Linux/OSX IDEs supported by CMake

CMake scripts for painless usage of Tim Davis' SuiteSparse (CHOLMOD,UMFPACK,AMD,LDL,SPQR,...) and METIS from Visual Studio and the rest of Windows/Lin

Jose Luis Blanco-Claraco 393 Nov 18, 2022
cmake-font-lock - Advanced, type aware, highlight support for CMake

cmake-font-lock - Advanced, type aware, highlight support for CMake

Anders Lindgren 39 Oct 2, 2022
cmake-avr - a cmake toolchain for AVR projects

cmake-avr - a cmake toolchain for AVR projects Testing the example provided The toolchain was created and tested within the following environment: Lin

Matthias Kleemann 162 Oct 24, 2022
Make CMake less painful when trying to write Modern Flexible CMake

Izzy's eXtension Modules IXM is a CMake library for writing Modern flexible CMake. This means: Reducing the amount of CMake written Selecting reasonab

IXM 107 Sep 1, 2022
CMake module to enable code coverage easily and generate coverage reports with CMake targets.

CMake-codecov CMake module to enable code coverage easily and generate coverage reports with CMake targets. Include into your project To use Findcodec

HPC 82 Oct 25, 2022
unmaintained - CMake module to activate certain C++ standard, feature checks and appropriate automated workarounds - basically an improved version of cmake-compile-features

Compatibility This library provides an advanced target_compile_features() and write_compiler_detection_header(). The problem with those is that they a

Jonathan Müller 72 Apr 14, 2022
[CMake] [BSD-2] CMake module to find ICU

FindICU.cmake A CMake module to find International Components for Unicode (ICU) Library Note that CMake, since its version 3.7.0, includes a FindICU m

julp 29 Nov 2, 2022
curl cmake module libcurl build with msvc x86

curl-msvc Infomation curl cmake module libcurl build with MSVC10.0 arch (x86 | i386) source from https://github.com/curl/curl tags: curl-7_79_1 Usage

Jason Payne 0 May 16, 2022
Project to enable using CMake from a Maven build.

CMake-Maven-Project Introduction A Maven project for the CMake build system. It can be used by including it as a plugin within your Maven project's po

null 60 Nov 14, 2022
CMake and other scripts to help build process of FlyEM software

The BuildEM System The buildem repo is a modular CMake-based system that leverages CMake's ExternalProject to simplify and automate a complex build pr

null 27 Jun 9, 2022
CMake toolchain for all Arduino compatible boards

Arduino CMake Toolchain Arduino CMake toolchain is a CMake toolchain for cross-compiling CMake based projects for all Arduino compatible boards (AVR,

Arun 109 Nov 22, 2022
A fast build system that encourages the creation of small, reusable modules over a variety of platforms and languages.

Buck Buck is a build tool. To see what Buck can do for you, check out the documentation at http://buck.build/. Installation Since Buck is used to buil

Facebook 8.4k Nov 25, 2022
Tundra is a code build system that tries to be accurate and fast for incremental builds

Tundra, a build system Tundra is a high-performance code build system designed to give the best possible incremental build times even for very large s

Andreas Fredriksson 392 Nov 14, 2022
a small build system with a focus on speed

Ninja Ninja is a small build system with a focus on speed. https://ninja-build.org/ See the manual or doc/manual.asciidoc included in the distribution

null 8.8k Nov 25, 2022
muon is an implementation of the meson build system in C with minimal dependencies.

muon muon is an implementation of the meson build system in C with minimal dependencies. Non-features bug-for-bug compatibility with meson. In fact, m

Stone Tickle 49 Nov 7, 2022
A basic build system for the Skript scripting language.

skib A basic build system for the Skript scripting language. Features #include other files recursively #define preprocessor symbols and macros Usage #

Daniel 1 Jun 27, 2022