Last active
August 20, 2023 23:00
-
-
Save ParadoxV5/5025f277479ba710740b3ea123d8ef19 to your computer and use it in GitHub Desktop.
`CMakeLists.txt` to work with Arduino Sketches in CLion (only IDE insignts, still need Arduino IDE or CLI to build/upload)
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.26) | |
project("Arduino Sketches") | |
set(CMAKE_CXX_STANDARD 11) | |
# Path to Arduino Package | |
set(ARDUINO [PATH/TO/%LOCALAPPDATA%]/Arduino15/packages/arduino/hardware/avr/1.8.6/) | |
# Microcontroller | |
add_compile_definitions(__AVR_ATmega328P__) # Arduino UNO | |
set(ARDUINO_HARDWARE ${ARDUINO}/hardware/avr/1.8.6/) | |
set(ARDUINO_HARDWARE_CORE ${ARDUINO_HARDWARE}/cores/arduino) | |
include_directories(BEFORE SYSTEM | |
${ARDUINO}/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/avr/include/ | |
${ARDUINO_HARDWARE}/variants/standard/ | |
${ARDUINO_HARDWARE_CORE} | |
) | |
function(sketch SKETCH) | |
list(TRANSFORM ARGN PREPEND ${SKETCH}/) | |
add_executable( | |
${SKETCH} | |
${ARDUINO_HARDWARE_CORE}/main.cpp | |
${SKETCH}/${SKETCH}.ino | |
${ARGN} | |
) | |
endfunction() | |
sketch(Sketch additional_files) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment