I’ve tried to follow the documentation for setting up a CLion project, but I can’t get it to work.
I’m on a Mac, and used homebrew to install platformio, and it was upgraded today as part of brew upgrade
.
$ brew list platformio /usr/local/Cellar/platformio/2.11.1/bin/pio /usr/local/Cellar/platformio/2.11.1/bin/platformio /usr/local/Cellar/platformio/2.11.1/libexec/bin/ (2 files) /usr/local/Cellar/platformio/2.11.1/libexec/lib/ (180 files) /usr/local/Cellar/platformio/2.11.1/libexec/vendor/ (226 files)
My basic summary of steps taken while following the docs – Redirecting...
$ mkdir ard_test01 $ cd ard_test01/ $ platformio init --ide clion --board teensy31
The current working directory /Users/home/pyMTS/arduino/ard_test01 will be used for project. You can specify another project directory via `platformio init -d %PATH_TO_THE_PROJECT_DIR%` command.
The next files/directories will be created in /Users/home/pyMTS/arduino/ard_test01 platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-| src - Put your source files here lib - Put here project specific (private) libraries Do you want to continue? [y/N]: y
Project has been successfully initialized! Useful commands: `platformio run` - process/build project from the current directory `platformio run --target upload` or `platformio run -t upload` - upload firmware to embedded board `platformio run --target clean` - clean project (remove compiled files) `platformio run --help` - additional information
At this point instructions ask to add source files…
$ cp ../tft_demo/src/demo.ino src/ $ ls src demo.ino
Now I open CLion. The docs say to do “Menu: File > Import Project”, but when there are no projects open, the splash screen import option reads “Import Project from Sources”.
I navigate to the project directory and select it – /Users/home/pyMTS/arduino/ard_test01
Just to confirm that it has the ini file there
$ ls /Users/home/pyMTS/arduino/ard_test01 CMakeLists.txt CMakeListsPrivate.txt lib platformio.ini src
Now CLion complains that the the import is blocked by an existing CMakeLists.txt file…
At this point, it appears the Import action is not valid on the platformio project… so I’ll try each option.
First “Open Project”
CLion opens a project window, shows platformio.ini and complains in the “CMake” pane:
Error:add_executable called with incorrect number of arguments
I hit F4 to navigate to the source of the error, and it show the last line of CMakeLists.txt
add_executable(${PROJECT_NAME} ${SRC_LIST})
If I just ignore the error, the next step in the docs is to open a source file and build… so I open src/demo.ino and do “Menu: Run > Build”. That brings up the Run/Debug window, and it has an Error: Target ‘PLATFORMIO_BUILD(and_test01)’ not found.
I guess that’s related to the preceding “add_executable” error from earlier?
So, I try an initialise a new project to try the “overwrite” option when trying to import the project…
$ cd .. $ mkdir ard_test02 $ cd ard_test02 $ platformio init --ide clion --board teensy31
The current working directory /Users/home/pyMTS/arduino/ard_test02 will be used for project. You can specify another project directory via `platformio init -d %PATH_TO_THE_PROJECT_DIR%` command.
The next files/directories will be created in /Users/home/pyMTS/arduino/ard_test02 platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-| src - Put your source files here lib - Put here project specific (private) libraries Do you want to continue? [y/N]: y
Project has been successfully initialized! Useful commands: `platformio run` - process/build project from the current directory `platformio run --target upload` or `platformio run -t upload` - upload firmware to embedded board `platformio run --target clean` - clean project (remove compiled files) `platformio run --help` - additional information
$ cp ../tft_demo/src/demo.ino src/
Switch to CLion, Import Project from Sources, select ard_test02
, and this time choose “Overwrite CMakeLists.txt”
I tick the boxes for including the “lib
” and “src
” project directories, and then OK.
The project window opens on CMakeLists.txt, and the CMake pane is showing two errors and a few warnings…
CMakeLists.txt
looks like this:
cmake_minimum_required(VERSION 3.5) project(ard_test02)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES lib/readme.txt src/demo.ino)
add_executable(ard_test02 ${SOURCE_FILES})
And the errors/warnings:
Where did I go wrong? How can I achieve a CLion IDE integration that lets me follow dependencies and have code completion etc?
As a side note, the demo.ino sketch will build and upload from the CLI…
$ platformio run --target upload [Tue Jul 12 22:11:30 2016] Processing teensy31 (platform: teensy, board: teensy31, framework: arduino) .. snip .. Teensy Loader, Command Line, Version 2.0 Read ".pioenvs/teensy31/firmware.hex": 23712 bytes, 9.0% usage Soft reboot is not implemented for OSX Waiting for Teensy device... (hint: press the reset button)
And this is my CLion install, from “Menu : CLion > About CLion”
CLion 2016.1.3 Build #CL-145.1617, built on June 7, 2016 JRE: 1.8.0_76-release-b198 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o