eolas/zk/ESP32_project_structure.md

42 lines
781 B
Markdown

---
tags:
- C
- ESP32
- ESP-IDF
---
For a project named `example-project`.
```
example-project/
CMakeLists.txt
main/
main.c
CMakeList.txt
```
The parent `CMakeLists.txt`:
```
cmake_minimum_required(VERSION 3.16)
# This env var is sourced from:
# . /opt/esp-idf/export.sh
# when the compilation terminal session starts
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(example-project)
```
The `CMakeLists.txt` in `main/`:
```
idf_component_register(SRCS "main.c"
INCLUDE_DIRS ".")
```
Both must exist before you run `idf.py build`.
The `build/` directory and `sdkconfig` files will be created either when you run
`idf.py set target` or the first build (not sure of sequence, but anyway they
are autogenerated).