EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1285 background imageLoading...
Page #1285 background image
Chapter 4. API Guides
Optional componentsdirectory contains components that are part of the project. A project does not have
to contain custom components of this kind, but it can be useful for structuring reusable code or including third
party components that arent part of ESP-IDF. Alternatively, EXTRA_COMPONENT_DIRS can be set in
the top-level CMakeLists.txt to look for components in other places. See the renaming main section for more
info. If you have a lot of source files in your project, we recommend grouping most into components instead
of putting them all in main.
maindirectory is a special component that contains source code for the project itself. mainis a default
name, the CMake variable COMPONENT_DIRS includes this component but you can modify this variable.
builddirectory is where build output is created. This directory is created by idf.py if it doesnt already
exist. CMake configures the project and generates interim build files in this directory. Then, after the main
build process is run, this directory will also contain interim object files and libraries as well as final binary
output files. This directory is usually not added to source control or distributed with the project source code.
Component directories each contain a component CMakeLists.txt file. This file contains variable definitions to
control the build process of the component, and its integration into the overall project. See Component CMakeLists
Files for more details.
Each component may also include a Kconfig file defining the component configuration options that can be set via
menuconfig. Some components may also include Kconfig.projbuild and project_include.cmake
files, which are special files for overriding parts of the project.
4.4.4 Project CMakeLists File
Each project has a single top-level CMakeLists.txt file that contains build settings for the entire project. By
default, the project CMakeLists can be quite minimal.
Minimal Example CMakeLists
Minimal project:
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(myProject)
Mandatory Parts
The inclusion of these three lines, in the order shown above, is necessary for every project:
cmake_minimum_required(VERSION 3.5) tells CMake the minimum version that is required to
build the project. ESP-IDF is designed to work with CMake 3.5 or newer. This line must be the first line in
the CMakeLists.txt file.
include($ENV{IDF_PATH}/tools/cmake/project.cmake) pulls in the rest of the CMake
functionality to configure the project, discover all the components, etc.
project(myProject) creates the project itself, and specifies the project name. The project name is used
for the final binary output files of the app - ie myProject.elf, myProject.bin. Only one project can
be defined per CMakeLists file.
Optional Project Variables
These variables all have default values that can be overridden for custom behaviour. Look in
/tools/cmake/project.cmake for all of the implementation details.
COMPONENT_DIRS: Directories to search for components. Defaults to IDF_PATH/components,
PROJECT_DIR/components, and EXTRA_COMPONENT_DIRS. Override this variable if you dont
want to search for components in these places.
EXTRA_COMPONENT_DIRS: Optional list of additional directories to search for components. Paths can be
relative to the project directory, or absolute.
Espressif Systems 1274
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish