Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Arduino SDK 1.6 compatibility #174

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8d19e10
Added Arduino SDK 1.6 compatibility
JonasProgrammer May 5, 2017
5bc8777
Merge branch 'feature/arduino16-compatibility' into n3-stable
JonasProgrammer May 5, 2017
b77542e
Fix SPI hardware library detection
JonasProgrammer May 9, 2017
3d3c4d4
Merge branch 'feature/arduino16-compatibility' into n3-stable
JonasProgrammer May 9, 2017
2bd93c3
Fix libraries, improve CMake compatibility
JonasProgrammer May 11, 2017
110921e
Merge branch 'feature/arduino16-compatibility' into n3-stable
JonasProgrammer May 11, 2017
1c6484a
Fix upload target for build paths containing spaces or special charac…
JonasProgrammer May 20, 2017
e28eb25
Merge branch 'feature/arduino16-compatibility' into n3-stable
JonasProgrammer May 20, 2017
39f80c4
Fixed Firmware-Size script possibly not executing on Windows systems.
MrPointer May 30, 2017
08ca0ee
Reformatted file to have basic indentations.
MrPointer May 30, 2017
de0097e
Added a valuable comment to a somewhat unclear intention in the 'REGI…
MrPointer May 31, 2017
8ae7de0
Added support for menu settings, compatible with the Arduino 1.6 SDK,…
MrPointer May 31, 2017
ae273d6
Added custom parse to the 'board.menu.cpu' sub-setting, creating a li…
MrPointer Jun 1, 2017
33c7a73
Updated documentation of the 'LOAD_ARDUINO_STYLE_SETTINGS' function w…
MrPointer Jun 1, 2017
a8e4faf
Updated .gitignore file to ignore CMake files as well as Jetbrains ID…
MrPointer Jun 1, 2017
ba408f6
Collapsed all functions into logical regions.
MrPointer Jun 1, 2017
c842cd6
Added a feature to automatically find and set board's upload speed in…
MrPointer Jun 2, 2017
4118c50
Added a feature to automatically find and set bootloader arguments in…
MrPointer Jun 2, 2017
2aa7b04
Merge pull request #2 from MrPointer/arduino16-board_settings
JonasProgrammer Jun 2, 2017
f548d26
Merge remote-tracking branch 'origin/arduino16-board_settings' into f…
MrPointer Jun 3, 2017
f58dae2
Merge remote-tracking branch 'origin/feature/arduino16-compatibility'…
MrPointer Jun 3, 2017
4ebd7a4
Added Arduino basic examples support.
MrPointer Jun 3, 2017
5a25fef
Extended support for basic built-in Arduino examples.
MrPointer Jun 4, 2017
a8ff121
Added support for all 'Example categories indices'.
MrPointer Jun 6, 2017
0a72486
Renamed 'ARDUINO_EXAMPLES' cached variable to 'ARDUINO_EXAMPLES_CATEG…
MrPointer Jun 6, 2017
f0c7f20
Modified a lot of the library setup procedure.
MrPointer Jun 10, 2017
2e7444f
Huge commit - resolved a tough issue regarding sketches.
MrPointer Jun 18, 2017
0aaa0b9
Fixed a small potential bug in the 'find_arduino_libraries' function …
MrPointer Jun 24, 2017
7e5bdd3
Fixed some bugs related to category parsing.
MrPointer Jun 24, 2017
749aaad
Merge remote-tracking branch 'origin/arduino_examples' into arduino_i…
MrPointer Jun 24, 2017
a689bea
Merge remote-tracking branch 'origin/arduino_libraries' into arduino_…
MrPointer Jun 24, 2017
b21b28a
Turned off *arduino_debug* messages, added an alternative (by comment…
MrPointer Jun 24, 2017
cadbd7f
Added case-insensitive support for category names as well as example …
MrPointer Jun 24, 2017
c97280f
Merge remote-tracking branch 'origin/arduino_examples' into arduino_i…
MrPointer Jun 24, 2017
dbacacb
Updated README.rst to be up-to-date with the fork
MrPointer Jun 24, 2017
2608e7b
Merge pull request #3 from MrPointer/arduino_improvements
JonasProgrammer Jun 24, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
build

### CMake template
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
121 changes: 98 additions & 23 deletions README.rst
Original file line number Diff line number Diff line change
@@ -19,29 +19,35 @@ Features

* Integrates with *Arduino SDK*
* Supports all Arduino boards.
* Supports Arduino type libraries
* Supports Arduino type libraries.
* Automatic detection of Arduino libraries.
* Generates firmware images.
* Generates built-in examples.
* Generates libraries.
* Sketch support.
* Upload support.
* Hardware Platform support.
* Programmer support (with bootloader upload).
* Supports multiple build system types (Makefiles, Eclipse, KDevelop, CodeBlocks, XCode, etc).
* Cross-platform: Windows, Linux, Mac
* Extensible build system, thanks to CMake
* Cross-platform: Windows, Linux, Mac.
* Extensible build system, thanks to CMake.


Feedback
--------

**Arduino CMake** is hosted on GitHub and is available at:
**Arduino CMake** is hosted on GitHub and is available on multiple forks (At the time of writing up to **156(!)**),
with the most advanced and maintainable being the following:

https://github.com/JonasProgrammer/arduino-cmake/

However, the original repository deserves its honor, therefore a direct link to it is provided as well:

https://github.com/queezythegreat/arduino-cmake

Did you find a bug or would like a specific feature, please report it at:

https://github.com/queezythegreat/arduino-cmake/issues
https://github.com/JonasProgrammer/arduino-cmake/issues

If you would like to hack on this project, don't hesitate to fork it on GitHub.
I will be glad to integrate your changes if you send me a ``Pull Request``.
@@ -68,6 +74,8 @@ Contributors

I would like to thank the following people for contributing to **Arduino CMake**:

* Jonas (`JonasProgrammer`_)
* MrPointer (`MrPointer`_)
* Marc Plano-Lesay (`Kernald`_)
* James Goppert (`jgoppert`_)
* Matt Tyler (`matt-tyler`_)
@@ -89,6 +97,8 @@ I would like to thank the following people for contributing to **Arduino CMake**
* Mike Purvis (`mikepurvis`_)
* Steffen Hanikel (`hanikesn`_)

.. _JonasProgrammer: https://github.com/JonasProgrammer
.. _MrPointer: https://github.com/MrPointer
.. _Kernald: https://github.com/Kernald
.. _jgoppert: https://github.com/jgoppert
.. _matt-tyler: https://github.com/matt-tyler
@@ -127,17 +137,18 @@ Contents
1. `Getting Started`_
2. `Using Arduino CMake`_

1. `Creating firmware images`_
2. `Creating libraries`_
1. `Creating Firmware Images`_
2. `Creating Libraries`_
3. `Arduino Sketches`_
4. `Arduino Libraries`_
5. `Arduino Library Examples`_
6. `Compiler and Linker Flags`_
7. `Programmers`_
8. `Pure AVR Development`_
9. `Advanced Options`_
10. `Miscellaneous Functions`_
11. `Bundling Arduino CMake`_
4. `Arduino Built-in Examples`_
5. `Arduino Libraries`_
6. `Arduino Library Examples`_
7. `Compiler and Linker Flags`_
8. `Programmers`_
9. `Pure AVR Development`_
10. `Advanced Options`_
11. `Miscellaneous Functions`_
12. `Bundling Arduino CMake`_

3. `Linux Environment`_

@@ -278,7 +289,7 @@ You can also specify it at build configuration time::
cmake -DCMAKE_TOOLCHAIN_FILE=../path/to/toolchain/file.cmake PATH_TO_SOURCE_DIR


Creating firmware images
Creating Firmware Images
~~~~~~~~~~~~~~~~~~~~~~~~

Once you have the **Arduino CMake** loaded you can start defining firmware images.
@@ -401,7 +412,7 @@ This will create a target named ``${TARGET_NAME}-serial`` (in this example: blin



Creating libraries
Creating Libraries
~~~~~~~~~~~~~~~~~~

Creating libraries is very similar to defining a firmware image, except we use the ``generate_arduino_library`` command. This command creates static libraries, and are not to be confused with `Arduino Libraries`_. The full command syntax::
@@ -464,7 +475,6 @@ Once that library is defined we can use it in our other firmware images... Let's
CMake has automatic dependency tracking, so when you build the ``blink`` target, ``blink_lib`` will automatically get built, in the right order.



Arduino Sketches
~~~~~~~~~~~~~~~~

@@ -481,6 +491,72 @@ Note: When specifying the sketch directory path, arduino-cmake is expecting to f

You can also specify the path to the main sketch file, then the parent directory of that sketch will be search for additional sketch files.

Arduino Built-in Examples
~~~~~~~~~~~~~~~~~~~~~~~~~

The Arduino SDK comes with a handful of code examples, providing an easy setup for simple operations.
Since there are many examples, they were categorized, making each example be under a certain category.
Each example consists of at least one source file, named after the example and has the *.ino* or *.pde* extension, and sits under a directory which is also named after the example.
Each category is a directory named after it, having all its examples as sub-directories, named after them.
One such example is ``Blink``, probrably the most popular one as well. It's located under the ``Basics`` category and has a source file named ``Blink.ino``.

**Arduino CMake** has the abillity to automatically generate these examples, simply by passing their name and optionally their category, as some sort of an optimization. **It supports case-insensitive names**
If you would like to generate and upload some of those examples you can use the `generate_arduino_example` command. The syntax of the command is::

generate_arduino_example(target_name
EXAMPLE example_name
[CATEGORY] category_name
[BOARD board_id]
[PORT port]
[SERIAL serial command]
[PORGRAMMER programmer_id]
[AFLAGS avrdude_flags])

The options are:


+--------------------+----------------------------------------------------------------------+------------------------------------+
| **Name** | **Description** | **Required** |
+--------------------+----------------------------------------------------------------------+------------------------------------+
| **EXAMPLE** | Example name. | **REQUIRED** |
+--------------------+----------------------------------------------------------------------+------------------------------------+
| **BOARD** | Board ID *(such as uno, mega2560, ...)* | **REQUIRED** |
+--------------------+----------------------------------------------------------------------+------------------------------------+
| **CATEGORY** | Category name. | |
+--------------------+----------------------------------------------------------------------+------------------------------------+
| **PORT** | Serial port, for upload and serial targets (see `Upload Firmware`_) | |
+--------------------+----------------------------------------------------------------------+------------------------------------+
| **SERIAL** | Serial command for serial target (see `Serial Terminal`_) | |
+--------------------+----------------------------------------------------------------------+------------------------------------+
| **PROGRAMMER** | Programmer ID, enables programmer burning (see `Programmers`_). | |
+--------------------+----------------------------------------------------------------------+------------------------------------+
| **AFLAGS** | avrdude flags for target | |
+--------------------+----------------------------------------------------------------------+------------------------------------+

To generate a target for the **blink** example from the **Basics** category for the **Uno** board::

generate_arduino_example(blink_example
CATEGORY Basics
EXAMPLE Blink
BOARD uno
PORT /dev/ttyUSB0)

You can also rewrite the previous like so::

set(blink_example_CATEGORY Basics)
set(blink_example_EXAMPLE Blink)
set(blink_example_BOARD uno)
set(blink_example_PORT /dev/ttyUSB0)

generate_arduino_example(blink_example)

The previous example will generate the following two target::

blink_example
blink_example-upload

**Note:** The above example will work perfectly fine even if the ``Basics`` category hadn't been passed.

Arduino Libraries
~~~~~~~~~~~~~~~~~

@@ -524,9 +600,9 @@ Arduino Libraries are not to be confused with normal static libraries (for exmap
Arduino Library Examples
~~~~~~~~~~~~~~~~~~~~~~~~

Most Arduino libraries have examples bundled with them. If you would like to generate and upload some of those examples you can use the `generate_arduino_example` command. The syntax of the command is::
Most Arduino libraries have examples bundled with them. If you would like to generate and upload some of those examples you can use the `generate_arduino_library_example` command. The syntax of the command is::

generate_arduino_example(target_name
generate_arduino_library_example(target_name
LIBRARY library_name
EXAMPLE example_name
[BOARD board_id]
@@ -558,7 +634,7 @@ The options are:

To generate a target for the **master_writer** example from the **Wire** library for the **Uno**::

generate_arduino_example(wire_example
generate_arduino_library_example(wire_example
LIBRARY Wire
EXAMPLE master_writer
BOARD uno
@@ -571,7 +647,7 @@ You can also rewrite the previous like so::
set(wire_example_BOARD uno)
set(wire_example_PORT /dev/ttyUSB0)

generate_arduino_example(wire_example)
generate_arduino_library_example(wire_example)

The previous example will generate the following two target::

@@ -1228,4 +1304,3 @@ Here are some resources you might find useful in getting started.
.. _CMake: http://www.cmake.org/cmake/resources/software.html
.. _CMake Installer: http://www.cmake.org/cmake/resources/software.html
.. _Arduino SDK: http://www.arduino.cc/en/Main/Software

33 changes: 33 additions & 0 deletions cmake/ArduinoToolchain.cmake
Original file line number Diff line number Diff line change
@@ -32,6 +32,35 @@ elseif(WIN32)
include(Platform/WindowsPaths)
endif()

#=============================================================================#
# Toolchain file variable scope workaround #
#=============================================================================#
foreach(VAR
ARDUINO_SDK_PATH
ARDUINO_AVRDUDE_CONFIG_PATH
ARDUINO_AVRDUDE_FLAGS
ARDUINO_AVRDUDE_PROGRAM
ARDUINO_BOARDS_PATH
ARDUINO_BOOTLOADERS_PATH
ARDUINO_CORES_PATH
ARDUINO_LIBRARIES_PATH
ARDUINO_OBJCOPY_EEP_FLAGS
ARDUINO_OBJCOPY_HEX_FLAGS
ARDUINO_PLATFORMS
ARDUINO_PROGRAMMERS_PATH
ARDUINO_VARIANTS_PATH
ARDUINO_VERSION_PATH
AVRSIZE_PROGRAM)
if(${VAR})
# Environment variables are always preserved.
set(ENV{_ARDUINO_CMAKE_WORKAROUND_${VAR}} "${${VAR}}")
else()
if($ENV{_ARDUINO_CMAKE_WORKAROUND_${VAR}})
set(${VAR} "$ENV{_ARDUINO_CMAKE_WORKAROUND_${VAR}}")
message(DEBUG "RESTORED ${VAR} from env: ${${VAR}}")
endif()
endif()
endforeach()

#=============================================================================#
# Detect Arduino SDK #
@@ -64,6 +93,10 @@ if(NOT ARDUINO_SDK_PATH)
endif()
list(SORT SDK_PATH_HINTS)
list(REVERSE SDK_PATH_HINTS)

if(DEFINED ENV{ARDUINO_SDK_PATH})
list(APPEND SDK_PATH_HINTS $ENV{ARDUINO_SDK_PATH})
endif()
endif()

find_path(ARDUINO_SDK_PATH
Loading