Code your ESP8266 project with CLion IDE


The next RTOS SDK releases - version 4+ - are going to use CMake as the default build process but it is already present into the current version 3.2, meaning it is already possible to use CLion IDE to code your project. This post will explain how to configure your favorite IDE for that purpose.
Create your project
First copy the getting-started project template present in the exemple directory of the ESP SDK.
Open the directory inside CLion. It will be detected as a CMake project.
Configure a new toolchain

Open the IDE settings and go to Build, Execution, Deployment / Toolchains:
- Create the toolchain xtensa-lx106-elfand specify the required paths of compiler toolsgccandg++.
Configure the CMake profile

Go to Build, Execution, Deployment / CMake:
- Select the newly created toolchain - xtensa-lx106-elf
- Add the CMake option: - -DIDF_PATH=/home/boris/.local/share/ESP8266_RTOS_SDK
- Add these environment variables: - IDF_PATH=/home/boris/.local/share/ESP8266_RTOS_SDK;PATH=/home/boris/.local/share/xtensa-lx106-elf/bin BATCH_BUILD=1
Configure the IDE terminal

Go to Tools / Terminal:
- Configure the terminal environment: - IDF_PATH=/home/boris/.local/share/ESP8266_RTOS_SDK PATH=/home/boris/.local/share/xtensa-lx106-elf/bin:/usr/bin:/bin:/home/boris/.local/share/ESP8266_RTOS_SDK/tools
Reload the project
Reload the CMake project by right clicking on the project name in the project view and check that no CMake error is generated.
You can now build the project.
Flash your device
To flash the firmware into your ESP device, select the build configuration flash and execute it.
You can also open the IDE terminal to execute directly the associated command:
$ idf.py flash monitor
Enjoy coding!