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.txtoptions, 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 Editorand selectProject CMakeLists.txt.
Add new elements by selecting them from the
New Elementdropdown and clicking theAddbutton. For simplicity, change the project name and save changes with theSavebutton.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.txtin the regular text editor, you will see anidf_component_registermethod 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 Editorand 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.txtis located without user intervention.Add a new element
Public Component Requirements for the Component (REQUIRES)and click theAddbutton. A new array field will appear.As described in Component CMakeLists Files,
REQUIRESis used to list the component dependencies. Typembedtlsand click the+button (you can also press enter after typing).Click the
Savebutton and close theCMakeLists.txteditor. If you open<project_path>/blink/components/<component_name>/CMakeLists.txtin 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: