Cmake is not looking for components in EXTRA_COMPONENT_DIRS

User avatar
gunar.kroeger
Posts: 143
Joined: Fri Jul 27, 2018 6:48 pm

Cmake is not looking for components in EXTRA_COMPONENT_DIRS

Postby gunar.kroeger » Tue Mar 31, 2020 5:06 pm

This is our folder structure

Code: Select all

common
	minmea
	
project_a
	components
		GPS_logger
		...	
	main
project_b
	components
		GPS_visualizer
		...
I'm trying to make project_a and project_b search for the minmea component in "common" instead of having two copies to mantain.
I tried modifying the projects CMakeLists.txt as follows:

Code: Select all

# 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)

set(EXTRA_COMPONENT_DIRS, "PROJECT_DIR/../common")

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(project_a)
but I'm getting an error

Code: Select all

⚠️ CMake Error at C:/Users/Gunar/esp-idf/tools/cmake/build.cmake:185 (message):
⚠️   Failed to resolve component 'minmea'.
Call Stack (most recent call first):
  C:/Users/Gunar/esp-idf/tools/cmake/build.cmake:211 (__build_resolve_and_add_req)
  C:/Users/Gunar/esp-idf/tools/cmake/build.cmake:425 (__build_expand_requirements)
  C:/Users/Gunar/esp-idf/tools/cmake/project.cmake:337 (idf_build_process)
  CMakeLists.txt:8 (project)


-- Configuring incomplete, errors occurred!
I'm running idf v4.0 in vs-code windows
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."

User avatar
gunar.kroeger
Posts: 143
Joined: Fri Jul 27, 2018 6:48 pm

Re: Cmake is not looking for components in EXTRA_COMPONENT_DIRS

Postby gunar.kroeger » Thu Apr 09, 2020 6:19 pm

Can someone help with this issue? I imagine it should be an easy fix, but I can't find the solution. :?
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."

nvannote
Posts: 51
Joined: Thu Nov 14, 2019 10:42 pm

Re: Cmake is not looking for components in EXTRA_COMPONENT_DIRS

Postby nvannote » Fri Apr 10, 2020 4:51 am

While I am not familiar with the exact structure of your project and CMakeLists.txt files outside of the “brief” you shared; I will make an attempt.

In your original set statement...

Code: Select all

set(EXTRA_COMPONENT_DIRS, "PROJECT_DIR/../common")
Try changing that to something along the lines of...

Code: Select all

set(EXTRA_COMPONENT_DIRS "${PROJECT_DIR}/../common")
Or perhaps in the context of the dependent projects CMakeLists.txt…

Code: Select all

set(EXTRA_COMPONENT_DIRS "../common")
Depending on how “common” is structured. You may need to spell out “ common/minmea” in the above.

Also, I have never seen a comma as a separator in a set command, but perhaps it is valid.

Best Regards

nvannote
Posts: 51
Joined: Thu Nov 14, 2019 10:42 pm

Re: Cmake is not looking for components in EXTRA_COMPONENT_DIRS

Postby nvannote » Fri Apr 10, 2020 6:50 am

Ok,

I actually had a couple of projects that could benefit from the same scenario (shared custom component). To date, (being on a unix’y machine) I had just created a symbolic link to the shared component in each projects “components” directory and that works just fine.

So, I removed that and attempted to do it within the IDF idf.py/cmake methodology, and also skimmed the relevant documentation on how IDF uses cmake.

As far as I can tell, the relative path method seems to be the way to make that work in the absence of an absolute path. Turns out PROJECT_DIR is a IDF/cmake property and not a variable that is always present.

Code: Select all

set(EXTRA_COMPONENT_DIRS "../common/some_shared_component")
But I will let someone more familiar with how IDF uses CMake chime in.

Regards

User avatar
gunar.kroeger
Posts: 143
Joined: Fri Jul 27, 2018 6:48 pm

Re: Cmake is not looking for components in EXTRA_COMPONENT_DIRS

Postby gunar.kroeger » Thu Apr 16, 2020 6:21 pm

nvannote wrote:
Fri Apr 10, 2020 6:50 am

Code: Select all

set(EXTRA_COMPONENT_DIRS "../common/some_shared_component")
I tried it this way, but get the same error. How should one link to the some_shared_component from inside the project components that REQUIRE it?

The way I thought it would work and that I think would be the most usefull is if:

1. look for components in the project componets folder
2. look for components in the EXTRA_COMPONENTS_DIRS
3. look for components in the idf

and if it finds components with the same name, it uses the one's with higher priority, so you could overwrite something without changing idf, or your own components library
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."

nvannote
Posts: 51
Joined: Thu Nov 14, 2019 10:42 pm

Re: Cmake is not looking for components in EXTRA_COMPONENT_DIRS

Postby nvannote » Fri Apr 17, 2020 6:33 am

gunar.kroeger wrote:
Thu Apr 16, 2020 6:21 pm
I tried it this way, but get the same error. How should one link to the some_shared_component from inside the project components that REQUIRE it?

What may be different is in my case; in my primary projects "main" source directory CMakeLists.txt; I have following line.

The normal idf_component_register, followed by a target_compile_options.

Code: Select all

target_compile_options(${COMPONENT_LIB})
Regards

User avatar
gunar.kroeger
Posts: 143
Joined: Fri Jul 27, 2018 6:48 pm

Re: Cmake is not looking for components in EXTRA_COMPONENT_DIRS

Postby gunar.kroeger » Fri Apr 24, 2020 8:01 pm

Can someone from the esp team explain how we are supposed to achieve this?
Just following the docs I could not make it work and nvannote's way did not work with our project, so how is the official way to include components that are not in the project folder?
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."

Who is online

Users browsing this forum: No registered users and 173 guests