Go Down

Topic: Using CMake w/ Arduino (Read 1 time) previous topic - next topic

ScottyB

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? 

robtillaart

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

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

Go Up