Pages: [1]   Go Down
Author Topic: Using CMake w/ Arduino  (Read 1467 times)
0 Members and 1 Guest are viewing this topic.
Mesa, AZ
Offline Offline
Newbie
*
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? 
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 223
Posts: 13896
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
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: