Page 1 of 1

How to include components from another project?

Posted: Sun Mar 06, 2022 7:29 pm
by paul_deg
Hi there,
I have 2 IDF projects, let's call them "main" and "extra", and I'd like to include components from "extra" project into "main". How do I do that?
So far I tried setting EXTRA_COMPONENT_DIRS, and SRC_DIRS in the main project CMakeLists file, but still build process cannot find them.
Any help would be appreciated.

Re: How to include components from another project?

Posted: Wed Mar 09, 2022 12:13 am
by gtjoseph
You need to set it in the project's top-level CMakeLists.txt file the as opposed to its own "main" component file. Then do an idf reconfigure.

Code: Select all

cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS /path/to/somecomponent)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(MyProject)
If you're not on Windows, you can also just create a symlink in the project's "components" directory that points to the other component's directory. This is how I do it when I'm working on both the main project and components at the same time because it's easier to move between the two from an IDE. In fact, all of my components live outside the main projects and the projects just symlink to them. There's no conflict because all project build artifacts go into the project's build directory.