Reputation: 89
I have multiple IDF projects and many of them use the same components. Instead of having a copy of the components in each project's directory, I want to place all the components in a global directory and use them in all my projects. I'm using ESP-IDF v.4.4.4 in VSCode. Here is the structure I want:
main_directory
|
|__global_components
| |__component1
| |__component2
| |__component3
|
|__project1
| |__CMakeLists.txt
| |__sdkconfig
| |__main/
| | |__CMakeLists.txt
| | |__src.c
| |__build
|
|__project2
| |__CMakeLists.txt
| |__sdkconfig
| |__main/
| | |__CMakeLists.txt
| | |__src.c
| |__build
|
|__project3
This is what the CMakeLists.txt
file in my project directory looks like:
# The following 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(esp32_project)
How will I have to change this file?
This is what the CMakeLists.txt
in my project/main directory looks like:
idf_component_register(
SRCS "crypto.cpp" "image.cpp" "main.cpp"
INCLUDE_DIRS "."
)
Will I have to change this file too? Thanks for the help. If I am approaching this in the wrong way and there is a better way to manage the problem I would love to know.
I tried set(EXTRA_COMPONENT_DIRS $(PROJECT_PATH)/../global_components/)
but that did not work.
Upvotes: 1
Views: 726
Reputation: 1443
Try to define
set(EXTRA_COMPONENT_DIRS $(PROJECT_PATH)/../global_components/)
in your root CMakeLists.txt
file before you declare the project. Like this:
set(EXTRA_COMPONENT_DIRS $(PROJECT_PATH)/../global_components/)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(esp32_project)
Upvotes: 0