Hi guys !
Here's my quick guide to set up CLion to work with the Arduino (and others) platforms. Once you get the gist (pun) of it, you should be fine !
Follow the instructions here
# Create new folder YourProject
mkdir YourProject
platformio init -b uno -d YourProject
This will populate the folder YourProject with a src
and lib
folder.
You should have somewhere on your drive the Arduino core library, on Windows I've found it in C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino
. Copy its contents to the lib folder of your project along with the CMakeLists.txt file
If you start having more than one file in your src folder, you'll need to add them to the src CMake file.
CMake is a bit tricky to get at first, but it's a really powerful tool, and cross platform. With this setup you'll be able to develop on Windows and as well on Linux and OSX.
Open CLion and select "Import Project from Sources" and pick your newly created project. Once in the IDE, create a new Run configuration:
You will need to find the platformio executable and set it.
Enjoy !
Hey @adrien-f, thanks for sharing this! It's working pretty good for me except that CLion can't find the Arduino.h even though it's in the lib directory. I've also tried marking that directory as "library root" but that doesn't fix it either. Do you have any ideas?