CMakeLists.txt Editor
Warning
This will override any existing code in the file with the one generated in the editor. If you have any code not included in the schema (or single line comments), use a regular text editor instead.
When you right-click any CMakeLists.txt
file, this extension provides a custom CMakeLists.txt
editor to fill an ESP-IDF project and component registration as specified in:
You need to choose which kind of CMakeLists.txt
file (project or component) to edit. There are two types of input: a simple string and an array of strings, such as Component Sources (SRCS).
Note
All inputs are described in the CMakeLists.txt schema.
This editor doesn’t support all CMake functions and syntax. Use it only for simple
CMakeLists.txt
options, such as component registration (usingidf_component_register
) and basic project elements. For more customization or advancedCMakeLists.txt
, review ESP-IDF Build System. You may also refer to CMakeLists.txt editor schema for a list of supported code.
For this tutorial we will use the blink example.
Right-click the
<project_path>/blink/CMakeLists.txt
, clickESP-IDF: CMakeLists.txt Editor
and selectProject CMakeLists.txt
.Add new elements by selecting them from the
New Element
dropdown and clicking theAdd
button. For simplicity, change the project name and save changes with theSave
button.When re-opening the file in a regular text editor, changes are reflected.
Create a new ESP-IDF component in this project to modify its
CMakeLists.txt
. Go to menuView
>Command Palette
, typeESP-IDF: Create New ESP-IDF Component
, and enter the new component name.A new component will be created in
<project_path>/blink/components/<component_name>
. OpenCMakeLists.txt
in the regular text editor, you will see anidf_component_register
method with:idf_component_register(SRCS "my_component.c" INCLUDE_DIRS "include")
Right-click
<project_path>/blink/components/<component_name>/CMakeLists.txt
, clickESP-IDF: CMakeLists.txt Editor
and selectComponent CMakeLists.txt
.Observe that some fields are of array types such as Component Sources (SRCS) since you can add several paths, while others are just string input fields (as described in
cmakeListsSchema.json
).Note
While using this extension, source files are added and deleted automatically from the same directory where
CMakeLists.txt
is located without user intervention.Add a new element
Public Component Requirements for the Component (REQUIRES)
and click theAdd
button. A new array field will appear.As described in Component CMakeLists Files,
REQUIRES
is used to list the component dependencies. Typembedtls
and click the+
button (you can also press enter after typing).Click the
Save
button and close theCMakeLists.txt
editor. If you open<project_path>/blink/components/<component_name>/CMakeLists.txt
in a regular text editor, you will see:idf_component_register(SRCS "my_component.c" INCLUDE_DIRS "include" REQUIRES "mbedtls")
Reference Links
To review all fields used in the CMakeLists.txt
editor, go to: