When ESP-IDF is installed as an extension in VSCode, the build system is basically composed of “CMake” and “ninja” configuration. – CMake(build management software): A program that creates build files. – ninja(build system): A program that builds with build files. (etc. Make) [Info] Since CMake 2.8.9, ninja is integrated.
Import
When a project(ProjectTest) is created, a “CMakeLists.txt” file is created in the top directory by default as shown below. cmake_minimun_required(VERSION 3.16) include($ENV{IDF_PATH}/toos/cmake/project.cmake) project(ProjectTest)
Set the component[directory](ComponentTest) to add the above contents as follows. cmake_minimun_required(VERSION 3.16) list(APPEND EXTRA_COMPONENT_DIRS "ComponentTest") include($ENV{IDF_PATH}/toos/cmake/project.cmake) project(ProjectTest)
Create a new “CMakeLists.txt” in the component directory(ComponentTest) to be added later.
Set the “C File”(CFileTest.c) and “Include Directory”(IncludeTest) to be added to the newly created “CMakeLists.txt” as below. idf_component_register(SRCS "CFileTest.c" INCLUDE_DIRS "IncludeTest")
Afterwards, when building is performed, the added component(ComponentTest) is checked in the top-level “CMakeList.txt”, and the “C File”(CFileTest.c) to be built is found in the “CMakeList.txt” in the component and built. [Note!] If the component is added correctly, it will be added to the “compile_commands.json” file in the “build” directory.