How to include components from another project?

paul_deg
Posts: 3
Joined: Sun Mar 06, 2022 7:24 pm

How to include components from another project?

Postby paul_deg » Sun Mar 06, 2022 7:29 pm

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.

User avatar
gtjoseph
Posts: 92
Joined: Fri Oct 15, 2021 10:55 pm

Re: How to include components from another project?

Postby gtjoseph » Wed Mar 09, 2022 12:13 am

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.

Who is online

Users browsing this forum: Bing [Bot] and 109 guests