[Solved] EXTRA_COMPONENT_DIRS not working for me

RobMeades
Posts: 85
Joined: Thu Nov 29, 2018 1:12 pm

[Solved] EXTRA_COMPONENT_DIRS not working for me

Postby RobMeades » Sat May 30, 2020 12:25 pm

I have arranged my builds such that I have a common CMakeLists.txt in one directory and below it, in sub-directories, I have builds that make use of this common CMakeLists.txt, e.g. "thing1", which will in turn have the usual "main" sub-directory inside them. The common CMakeLists.txt pulls in generic source code, "thing1" will bring in its own main.c and anything else it needs.

In the CMakeLists.txt file in each of the "thingx" directories I set EXTRA_COMPONENT_DIRS to ".." in the hope of referring to the common CMakeLists.txt in the directory above. However, this doesn't work, the contents of my common CMakeLists.txt never make it into the build, it is never listed in the list of components. What might I be doing wrong?

This is the CMakeLists.txt in the "thingx" directory:

Code: Select all

cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS "..")
# Empty the component list, main will bring in just what it needs
set(COMPONENTS "")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(example)
...and this is the kind of thing I have in the common CMakeLists.txt in the directory above:

Code: Select all

set(COMPONENT_ADD_INCLUDEDIRS "../../api" "../../cfg")
set(COMPONENT_SRCS "../../src/blah.c")
register_component()
...and, for completeness, this is the CMakeLists.txt from the "main" directory of "thingx":

Code: Select all

set(COMPONENT_SRCS "main.c")
set(COMPONENT_REQUIRES "esp32" "esptool_py")
register_component()
This is with ESP-IDF version 4.1 and I am in the "thing1" directory when I execute "idf.py flash".

Thanks in advance for your help.
Last edited by RobMeades on Tue Jun 02, 2020 7:08 am, edited 1 time in total.

ESP_renz
Posts: 18
Joined: Tue May 14, 2019 2:41 am

Re: EXTRA_COMPONENT_DIRS not working for me

Postby ESP_renz » Tue Jun 02, 2020 2:00 am

Hi, it seems that the component in the directory above 'thingx' is rightfully not pulled in, since `main` in your snippet does not seem to do so?

RobMeades
Posts: 85
Joined: Thu Nov 29, 2018 1:12 pm

Re: EXTRA_COMPONENT_DIRS not working for me

Postby RobMeades » Tue Jun 02, 2020 7:07 am

Ah, yes, of course, EXTRA_COMPONENT_DIRS makes the component directory available to the CMake system but it doesn't actually _include_ the component in my case, main has to pull it in by naming it explicitly. That must be it.

Thank you for pointing out my "deliberate" mistake :-).

Who is online

Users browsing this forum: No registered users and 83 guests