Created
August 7, 2019 13:22
-
-
Save balazsgrill/c59585ec70ea245f2edbdf8d5a89f25e to your computer and use it in GitHub Desktop.
Arduino nano cmake toolchain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set(ARDUINOCORE ARDUINO_CORE_NOT_FOUND CACHE FILEPATH "") | |
set(CMAKE_SYSTEM_NAME "Generic") | |
set(CMAKE_C_COMPILER avr-gcc.exe) | |
set(CMAKE_CXX_COMPILER avr-g++.exe) | |
include_directories("${ARDUINOCORE}/cores/arduino") | |
include_directories("${ARDUINOCORE}/variants/standard") | |
set(CMAKE_CXX_FLAGS "-MMD -mmcu=atmega328p -Wall -DF_CPU=16000000L -Os") | |
set(CMAKE_C_FLAGS "-MMD -mmcu=atmega328p -Wall -DF_CPU=16000000L -Os") | |
add_library(core STATIC | |
"${ARDUINOCORE}/cores/arduino/main.cpp" | |
"${ARDUINOCORE}/cores/arduino/wiring.c" | |
"${ARDUINOCORE}/cores/arduino/wiring_digital.c" | |
"${ARDUINOCORE}/cores/arduino/wiring_analog.c" | |
"${ARDUINOCORE}/cores/arduino/hooks.c" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.10) | |
add_executable(program program.cpp) | |
target_link_libraries(program core) | |
add_custom_command( | |
TARGET program POST_BUILD | |
COMMAND ${CMAKE_OBJCOPY} -O ihex -R .eeprom program program.hex | |
COMMENT "OBJCOPY program" | |
BYPRODUCTS program.hex | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include "program.ino" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment