方法一 通过命令行的形式
项目工程的文件夹下,执行在命令行:
idf.py -C components create-component my_component
方法二 修改项目文件的CMakeLists
修改前:
# For more information about build system see
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(TestenvPro)
修改后:
cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS "./components")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(TestenvPro)