Pages: [1]   Go Down
Author Topic: Using CMake w/ Arduino  (Read 1477 times)
0 Members and 1 Guest are viewing this topic.
Mesa, AZ
Offline Offline
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

While the Wiki contains a way to build Arduino projects using CMake, it isn't very modular (i.e. not easy to build for the various Arduino platforms like UNO, Mega, Nano, etc.), it's out of date, and adding libraries is cumbersome.

So I started working on a FindArduino.cmake file.  This allows a CMakeLists.txt file like this:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ~/CMakeModules)  # Add my custom modules, including FindArduino.cmake!

set(ARDUINO_PLATFORM UNO)  # Setup for Arduino
find_package(Arduino REQUIRED SPI EEPROM)  # Include the SPI and EEPROM directories and libraries.

include_directories(ARDUINO_INCLUDE_DIR)  # Add core and library directories to the header search path
add_executable(firmware src/main.cpp)      # The executable
target_link_libraries(firmware ${ARDUINO_LIBS})    # add core and extra libraries to the link
flash(firmware)   # create a target to load this software onto the target hardware!

This is an improvement upon any existing CMake Arduino files I've seen.

Once I've got all the bugs worked out and features completed (for example, I think I'll combine add_executable, target_link_libraries, and flash into a single add_arduino_executable function, and it ONLY supports UNO at the moment) I'd like others to be able to find, use, and improve upon my effort.

So where/how should I share this? 

Global Moderator
Online Online
Shannon Member
Karma: 227
Posts: 14009
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PLayground article and refer to this thread as discussion / remarks thread , thats what I do (only using my own threads smiley

Rob Tillaart

Nederlandse sectie -,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: