-
Notifications
You must be signed in to change notification settings - Fork 8k
fix(tools): set *_IS_TOP_LEVEL cmake values at project() calls (IDFGH-16745) #17830
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
base: release/v5.5
Are you sure you want to change the base?
fix(tools): set *_IS_TOP_LEVEL cmake values at project() calls (IDFGH-16745) #17830
Conversation
👋 Hello benedekkupper, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on November 20
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
338ae7d to
c9c61f0
Compare
| set(${PROJECT_NAME}_HOMEPAGE_URL "${${PROJECT_NAME}_HOMEPAGE_URL}" PARENT_SCOPE) | ||
| if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21") | ||
| if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) | ||
| set(PROJECT_IS_TOP_LEVEL ON PARENT_SCOPE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this does not mimic how cmake sets PROJECT_IS_TOP_LEVEL. Specifically
The variable value will be true in:
a directory added by add_subdirectory() that does not also contain a project() call`
as described in docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also a change in the documentation between 3.23 and 3.24, so if we want to handle these variables completely up to spec, this should be reflected too. I'm a bit out of my depth here, do you have a proposal for the condition here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also a change in the documentation between 3.23 and 3.24, so if we want to handle these variables completely up to spec, this should be reflected too.
Ah, nice catch, I haven't noticed the change between 3.23 and 3.24.
I'm a bit out of my depth here, do you have a proposal for the condition here?
TBH I'm not sure neither. I guess it would be best to fully understand how the IsRootMakefile() function, used to set the PROJECT_IS_TOP_LEVEL variable, is implemented. I tried to take a look, but I would definitely need more time to understand the logic.
My worry is that with this change, which does not fully mimic cmake's behavior, we may fix problems for one set of people, but at the same time, we may change the expected behavior for others and break their components. At this point, I'm not sure this issue can be fully resolved, but I could be completely off here.
We are currently working on a next version of the build system, which is currently available as technical preview and it does not have this issue.
Thank you very much for looking into this problem!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that mean that there won't be further releases from 5.5? What is the timeline for releasing this new build system?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that mean that there won't be further releases from 5.5?
Please see https://github.com/espressif/esp-idf?tab=readme-ov-file#esp-idf-release-support-schedule. We will release bugfix releases for v5.5 up until 2028. All PRs should be targeted to the master branch and we can backport them to v5.5 if possible (patch is without breaking changes).
The build system what you know in v5.5 will be available in v6.0 as well. This is referred as cmakev1 in #17833. cmakev2 is available from v6.0 in preview state. cmakev2 will became the default build some later version of ESP-IDF. I'm unable to tell when will this happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think it is better to fix this in 5.5 one way or another, I don't believe that anybody is depending on the current wrong behavior and gets a worse experience with this fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @benedekkupper ,
I still think it is better to fix this in 5.5 one way or another, I don't believe that anybody is depending on the current wrong behavior and gets a worse experience with this fix.
This build system quirk is present for a long time and people may have worked around it already. For example there is another issue #17773 and the ESP_PLATFORM variable was used as a workaround(if(PROJECT_IS_TOP_LEVEL AND NOT ESP_PLATFORM)). Maybe this is something that could be used for your use case too. Note I don't think that your change would break this particular workaround, but we cannot be sure how the PROJECT_IS_TOP_LEVEL may be used in other components.
IIUC with the change you proposed we would actually set the PROJECT_IS_TOP_LEVEL variable always to OFF for components, which is now always ON. As stated above, I think this may break components which already worked around this unfortunate behavior.
I agree that it would be best to fix this, but I'm not sure if replacing one quirky behavior with another is the ideal solution. I of course can be wrong and maybe others have a different opinion.
Thank you very much
Description
As the comment at line 607 explains what's done here:
However, with cmake 3.21, two more variables are added to this list:
PROJECT_IS_TOP_LEVEL,
<PROJECT-NAME>_IS_TOP_LEVEL
When these aren't set correctly, builds fail in various ways, with rather vague error messages:
https://github.com/IntergatedCircuits/esp-idf-examples/actions/runs/19098336995/job/54563853753
With this change added, these variables are set as expected.
The condition used to set the value for these variables might be subject to change, I'm open for adjusting it as needed.
Checklist
Before submitting a Pull Request, please ensure the following:
Note
Sets
PROJECT_IS_TOP_LEVELand<PROJECT-NAME>_IS_TOP_LEVELintools/cmake/project.cmakefor CMake >= 3.21 based on whether the project is top-level.tools/cmake/project.cmaketo setPROJECT_IS_TOP_LEVELand<PROJECT-NAME>_IS_TOP_LEVEL(CMake >=3.21) after theproject()call, based onCMAKE_CURRENT_SOURCE_DIR == CMAKE_SOURCE_DIR.Written by Cursor Bugbot for commit c9c61f0. This will update automatically on new commits. Configure here.