|
1 | 1 | CMakeLists.txt Editor |
2 | | -============================== |
| 2 | +===================== |
| 3 | + |
| 4 | +:link_to_translation:`zh_CN:[中文]` |
3 | 5 |
|
4 | 6 | .. warning:: |
5 | | - * 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. |
6 | 7 |
|
7 | | -When you right click on any CMakeLists.txt file this extension provides a custom CMakeLists.txt Editor to fill an ESP-IDF Project and Component Registration as specified in: |
| 8 | + 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. |
| 9 | + |
| 10 | +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: |
8 | 11 |
|
9 | | -- `ESP-IDF Project CMakeLists.txt <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#project-cmakelists-file>`_ |
10 | | -- `ESP-IDF Component CMakeLists.txt Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#component-cmakelists-files>`_ |
| 12 | +- `Project CMakeLists File <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#project-cmakelists-file>`_ |
| 13 | +- `Component CMakeLists Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#component-cmakelists-files>`_ |
11 | 14 |
|
12 | | -You need to choose which kind of CMakeLists.txt file (project or component) to edit. There is 2 types of input, one is a simple string and another is an array of strings, such as Component Sources (SRCS). |
| 15 | +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). |
13 | 16 |
|
14 | 17 | .. note:: |
15 | | - * All inputs are described in the `CMakeLists.txt schema <https://github.com/espressif/vscode-esp-idf-extension/blob/master/cmakeListsSchema.json>`_ |
16 | | - * This editor doesn't support all CMake functions and syntaxes. This editor should only be used for simple CMakeLists.txt options such as component registration (using idf_component_register) and basic project elements. If you need more customization or advanced CMakeLists.txt, consider reviewing `ESP-IDF Build System <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html>`_. Also review **CMakeLists.txt editor schema** for a list of supported code. |
17 | 18 |
|
| 19 | + * All inputs are described in the `CMakeLists.txt schema <https://github.com/espressif/vscode-esp-idf-extension/blob/master/cmakeListsSchema.json>`_. |
| 20 | + * This editor doesn't support all CMake functions and syntax. Use it only for simple ``CMakeLists.txt`` options, such as component registration (using ``idf_component_register``) and basic project elements. For more customization or advanced ``CMakeLists.txt``, review `ESP-IDF Build System <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html>`_. You may also refer to **CMakeLists.txt editor schema** for a list of supported code. |
18 | 21 |
|
19 | | -For this tutorial we will use the get-started's blink example. |
| 22 | +For this tutorial we will use the blink example. |
20 | 23 |
|
21 | | -1. Right click the ``<project_path>/blink/CMakeLists.txt``, click on **ESP-IDF: CMakeLists.txt Editor** and select ``Project CMakeLists.txt``. |
| 24 | +1. Right-click the ``<project_path>/blink/CMakeLists.txt``, click ``ESP-IDF: CMakeLists.txt Editor`` and select ``Project CMakeLists.txt``. |
22 | 25 |
|
23 | | -.. image:: ../../../media/tutorials/cmakelists_editor/cmakelists_editor.png |
| 26 | + .. image:: ../../../media/tutorials/cmakelists_editor/cmakelists_editor.png |
24 | 27 |
|
25 | | -2. We can add new elements by selecting them from the ``New Element`` dropdown and clicking the ``Add`` button. For simplicity we will just change the project name and save changes with the ``Save`` button. |
| 28 | +2. Add new elements by selecting them from the ``New Element`` dropdown and clicking the ``Add`` button. For simplicity, change the project name and save changes with the ``Save`` button. |
26 | 29 |
|
27 | | -We can observe when we re-open the file in a regular text-editor changes are reflected. |
| 30 | + When re-opening the file in a regular text editor, changes are reflected. |
28 | 31 |
|
29 | | -3. Now let's create a new ESP-IDF component in this project to modify its ``CMakeLists.txt``. Click menu **View** > **Command Palette** and type **ESP-IDF: Create New ESP-IDF Component** and enter the new component name. |
| 32 | +3. Create a new ESP-IDF component in this project to modify its ``CMakeLists.txt``. Go to menu ``View`` > ``Command Palette``, type ``ESP-IDF: Create New ESP-IDF Component``, and enter the new component name. |
30 | 33 |
|
31 | | -4. A new component will be created in ``<project_path>/blink/components/<component_name>``. Opening in the regular text editor, you will see an ``idf_component_register`` method with: |
| 34 | +4. A new component will be created in ``<project_path>/blink/components/<component_name>``. Open ``CMakeLists.txt`` in the regular text editor, you will see an ``idf_component_register`` method with: |
32 | 35 |
|
33 | | -.. code-block:: C |
| 36 | + .. code-block:: C |
34 | 37 |
|
35 | | - idf_component_register(SRCS "my_component.c" |
36 | | - INCLUDE_DIRS "include") |
| 38 | + idf_component_register(SRCS "my_component.c" |
| 39 | + INCLUDE_DIRS "include") |
37 | 40 |
|
38 | | -Right click on ``<project_path>/blink/components/<component_name>/CMakeLists.txt``, click on **ESP-IDF: CMakeLists.txt Editor** and select ``Component CMakeLists.txt``. |
| 41 | + Right-click ``<project_path>/blink/components/<component_name>/CMakeLists.txt``, click ``ESP-IDF: CMakeLists.txt Editor`` and select ``Component CMakeLists.txt``. |
39 | 42 |
|
40 | | -.. image:: ../../../media/tutorials/cmakelists_editor/components_editor.png |
| 43 | + .. image:: ../../../media/tutorials/cmakelists_editor/components_editor.png |
41 | 44 |
|
42 | | -5. Observe that some fields are of array types such as **Component Sources (SRCS)** since we can add several paths while other are just string input fields (as described in cmakeListsSchema.json). |
| 45 | +5. 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``). |
43 | 46 |
|
44 | | -.. note:: |
45 | | - While using this extension, source files are added and deleted automatically from the same directory where CMakeLists.txt is located without user intervention. |
| 47 | + .. note:: |
| 48 | + |
| 49 | + While using this extension, source files are added and deleted automatically from the same directory where ``CMakeLists.txt`` is located without user intervention. |
46 | 50 |
|
47 | | -6. Add a new element ``Public Component Requirements for the Component (REQUIRES)`` and click the ``Add`` button. A new array field will appear. |
| 51 | +6. Add a new element ``Public Component Requirements for the Component (REQUIRES)`` and click the ``Add`` button. A new array field will appear. |
48 | 52 |
|
49 | | -7. As described in `ESP-IDF Component CMakeLists.txt Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#component-cmakelists-files>`_, ``REQUIRES`` is used to list the component dependencies. Type ``mbedtls`` and click the ``+`` button (can also press enter on typing). |
| 53 | +7. As described in `Component CMakeLists Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#component-cmakelists-files>`_, ``REQUIRES`` is used to list the component dependencies. Type ``mbedtls`` and click the ``+`` button (you can also press enter after typing). |
50 | 54 |
|
51 | | -8. Click on ``Save`` button and close the CMakeLists.txt editor. If you open ``<project_path>/blink/components/<component_name>/CMakeLists.txt`` on a regular text editor, you will see: |
| 55 | +8. Click the ``Save`` button and close the ``CMakeLists.txt`` editor. If you open ``<project_path>/blink/components/<component_name>/CMakeLists.txt`` in a regular text editor, you will see: |
52 | 56 |
|
53 | | -.. code-block:: C |
| 57 | + .. code-block:: C |
54 | 58 | |
55 | | - idf_component_register(SRCS "my_component.c" |
56 | | - INCLUDE_DIRS "include" |
57 | | - REQUIRES "mbedtls") |
| 59 | + idf_component_register(SRCS "my_component.c" |
| 60 | + INCLUDE_DIRS "include" |
| 61 | + REQUIRES "mbedtls") |
58 | 62 |
|
59 | | -Reference links |
60 | | ------------------------ |
| 63 | +Reference Links |
| 64 | +--------------- |
61 | 65 |
|
62 | | -To review all fields used in the CMakeLists.txt editor go to: |
| 66 | +To review all fields used in the ``CMakeLists.txt`` editor, go to: |
63 | 67 |
|
64 | | -1. `ESP-IDF Project CMakeLists.txt <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#project-cmakelists-file>`_ |
| 68 | +- `ESP-IDF Project CMakeLists Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#project-cmakelists-file>`_ |
65 | 69 |
|
66 | | -2. `ESP-IDF Component CMakeLists.txt Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#component-cmakelists-files>`_ |
| 70 | +- `ESP-IDF Component CMakeLists Files <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#component-cmakelists-files>`_ |
0 commit comments