-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake -D settings are not passed to components (IDFGH-13793) #14651
Comments
Could you please show the part of your component CMakeLists file which uses the For example, modifying hello_world example with
|
I got:
|
Is that the entire contents of your main/CMakeLists.txt? If no, could you please post the complete file? I am guessing that the issue you are running into is that component CMakeLists files are evaluated twice: first time in script mode, to get the |
I don't have a project to share at moment.
I can confirm you:
So what does it mean? Am I able to create a workspace project with cmake build options without create a new folder/repository with a new project for every option? |
I'm sorry, I don't understand what you mean. Could you show an example of how you actually use this |
I have different uses cases: Debug/Release profiles, UnitTests profiles, different options that require different files to be included.. (different components/modules too) |
Regarding different components, you can use the following in project CMakeLists.txt: cmake_minimum_required(VERSION 3.16)
option(COMPONENT_X_INCLUDED "Include feature X" OFF)
set(COMPONENTS main)
if(COMPONENT_X_INCLUDED)
list(APPEND COMPONENTS component_x)
endif()
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(your-project) For adding source files or compilation options, you can use the following in your component CMakeLists file:
and so on. |
Do you have more resources to read on how to fine control selected COMPONENTS to the build?
Does this mean if I use it, it will stop from autodetect main and components on the subfolders? |
No, this way You can read about this in the docs: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#including-components-in-the-build and the nearby sections. Edit: you may also check out the talk about IDF build system from the recent DevCon as well as the slides, this might answer some of your questions. |
Sorry I'm not understanding your example:
If they are going to be found "automatically", what does this set(COMPONENTS main) and why append a component that will automatically be discovered? I read it was possible to assign different paths to main (what about components?) and that way I could have a manual control of what components and main is added ? Thanks for the slides (I didn't check the talk yet). |
Yes, you can use the same method for this. If OPTION_A is set, you can set COMPONENTS to main_a, if OPTION_B is set, then to main_b. |
I think this can be closed for inactivity and no further action was identified. |
Answers checklist.
IDF version.
5.3
Operating System used.
Linux
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
None
What is the expected behavior?
I expected that the defined option on main cmakefile or via command line, eg: cmake -DOPTION=ON to be passed to components and main component
What is the actual behavior?
At this moment, only the main CMakeLists.txt file receive this options (I test) but they don't appear on components or main
Steps to reproduce.
option(BUILD_OPTION "Set my option define" OFF)
...
Build or installation Logs.
No response
More Information.
No response
The text was updated successfully, but these errors were encountered: