Some steps replicate the ESP-IDF Get Started guide. Examples below are given for the case of macOS.
Prepare the environment
Using your system terminal, create a directory for ESP-IDF and clone the official repository:mkdir -p ~/esp cd ~/esp git clone --recursive https://github.com/espressif/esp-idf.git
ESP-IDF will be downloaded into ~/esp/esp-idf.
In the same shell, install the tools:cd ~/esp/esp-idf ./install.sh
Set up a sample project using CLion's terminal
In CLion, go to ~/esp/esp-idf directory.and select the
At this point, project loading might fail due to the Current directory '../esp/esp-idf' is not buildable... error.
Open CLion's built-in terminal (or Alt+F12 ).
Set up the environment variables by running
Let's configure the hello_world project from the examples/get-started directory. The following commands set ESP32 chip as the target and run the menuconfig configuration utility:cd $IDF_PATH/examples/get-started/hello_world idf.py set-target esp32 idf.py menuconfig
The last command opens the configuration menu. As the hello_world project we are using will run with default configuration, you don't need to set it up in this menu.
Step out from the menu, and check the configuration is complete.
Now we can build hello_world by running
Next up, you can continue working with the project in CLion using the terminal. This will not require additional CMake configuration. Alternatively, you can set up CMake so that the project can be loaded, built and run without the command line. A few tips are given below.
First step would be to switch from the top-level CMakeLists.txt to the one located in examples/get-started/hello_world. Navigate to it in the project tree, right-click it, and select Load CMake project. Loading might fail at this point.
Check the build failure message and set up the required environment variables.
For this, you can use the CMake settings dialog (Environment field)., the
Also, make sure you have the compiler, which is xtensa-esp32-elf-gcc for our project by default, installed on your machine. Add the full path to the
PATHvariable for CMake to be able to find it. Another option is to specify the paths in CMake settings (see Switching compilers in CLion ).