The CLion is a cross-platform C/C++ IDE for Linux, OS X, and Windows integrated with the CMake build system. The initial version will support the GCC and Clang compilers and GDB debugger. Clion includes such features as a smart editor, code quality assurance, automated refactorings, project manager, integrated version control systems.
Refer to the CLion Documentation page for more detailed information.
Integration process consists of these steps:
- Install File Watchers plugin via “Clion: Preferences > Plugins”. We need it to automatically update project configuration when changes are made in “platformio.ini” (Project Configuration File)
- Open system Terminal and install PlatformIO Core (CLI)
- Create new folder for your project and change directory (
cd) to it
- Generate a project using PIO Core Project Generator (
platformio init --ide)
- Import project in IDE.
platformio init --ide clion --board <ID> # For example, generate project for Arduino UNO platformio init --ide clion --board uno
- Place source files (
*.c, *.cpp, *.h, *.hpp) to
srcdirectory and repeat
platformio init --idecommand above (to refresh source files list)
- Import this project via
Menu: File > Import Projectand specify root directory where is located “platformio.ini” (Project Configuration File)
- Open source file from
- Build project (DO NOT use “Run” button, see marks on the screenshot above):
Menu: Run > Build.
- PlatformIO Core (CLI) DOES NOT depend on
CMake, it has own cross-platform Build System. All data related to build flags and source code filtering should be specified using Build options in “platformio.ini” (Project Configuration File).
2. See know issue: Arduino .ino files are not supported and how to resolve it.
There are 11 predefined targets for building (NOT FOR RUNNING, see marks on the screenshot above):
PLATFORMIO_BUILD- Build project without auto-uploading
PLATFORMIO_BUILD_VERBOSE- Build project without auto-uploading in verbose mode
PLATFORMIO_UPLOAD- Build and upload (if no errors)
PLATFORMIO_CLEAN- Clean compiled objects
PLATFORMIO_MONITOR- Device monitor platformio device monitor
PLATFORMIO_TEST- PIO Unit Testing
PLATFORMIO_PROGRAM- Build and upload using external programmer (if no errors), see Upload using Programmer
PLATFORMIO_UPLOADFS- Upload files to file system SPIFFS, see Uploading files to file system SPIFFS
PLATFORMIO_UPDATE- Update installed platforms and libraries via platformio update
PLATFORMIO_REBUILD_PROJECT_INDEX- Rebuild C/C++ Index for the Project. Allows one to fix code completion and code linting issues.
PLATFORMIO_DEVICE_LIST- List connected devices.
If you have multiple environements, you can select which one the target is going to use by changing the build profile (See screenshot). Changing the build profile also updates defines and includes for code completion in the editor to those specified by the environement.
All runs the target for all environements ; this was the previous behavior.
The libraries which are added, installed or used in a project after
generating process will not be reflected in IDE. Please run
PLATFORMIO_REBUILD_PROJECT_INDEX target to resolve this issue.
CLion uses “CMake” tool for code completion and code linting. As result, it
doesn’t support Arduino files (
.pde) because they are
not valid C/C++ based source files:
- Missing includes such as
- Function declarations are omitted.
See how to Convert Arduino file to C++ manually.
- Dec 01, 2015 - JetBrains CLion Blog - C++ Annotated: Fall 2015. Arduino Support in CLion using PlatformIO
- Nov 22, 2015 - Michał Seroczyński - Using PlatformIO to get started with Arduino in CLion IDE
- Nov 09, 2015 - ÁLvaro García Gómez - Programar con Arduino “The good way” (Programming with Arduino “The good way”, Spanish)
See more Articles about us.