-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[cmake] modernize and simplify RConfigure generation #23261
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
Draft
ferdymercury
wants to merge
5
commits into
root-project:master
Choose a base branch
from
ferdymercury:rconfigmodern
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+87
−233
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
20e77f6
[cmake] modernize and simplify RConfigure generation
ferdymercury 99482fc
[cmake] fix define redefinition
ferdymercury 75cd2be
quotes
ferdymercury dd2cc23
Apply suggestions from code review
ferdymercury d2647f1
copilot fixes
ferdymercury File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 am not quite seeing (yet?) the simplification. (The boiler plate could technically be completely removed from the original with a macro and a list of things to test/set).
There is a significant difference between
configure_fileandfile(GENERATEwhich may or may not have drastic practical consequence. The timing of the file generation is different (Configure PhasevsGeneration Phase) and I am concerned that the file will be touched/regenerated at each re-invocation of cmake (leading to a full rebuild each time !?).I am also confused by
configure_fileis not the 'right' tool to generate a file containing configuration information. Is there a updated recommendation from KitWare?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.
Nope, see https://cmake.org/cmake/help/latest/command/file.html.
Generated files are modified and their timestamp updated on subsequent cmake runs only if their content is changed.Relying on global headers just for expressing "defines" is in general a bad idea: it's hard to express the dependency. The 'modern CMake' way is target compile definitions. This allows you to express dependencies. With global headers, it's harder
See
https://cmake.org/cmake/help/latest/guide/tutorial/In-Depth%20CMake%20Target%20Commands.html
The target_compile_definitions() command describes compile definitions as target properties. It is the most common mechanism for communicating build configuration information to the source code itself. As with all properties, the scope keywords apply as we have discussed.
The main advantage is that now you depend on a target rather than on a global header. This allows you to better track dependencies, as well as to do better intertwining of ROOT from other libraries if you just need some compile time definitions, so you do not need to link against Core, or otherwise do global target_include_directory but then that misses dependency tracking (if global header is changed, CMake does not know that it should rebuild)
See eg #23270
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.
a potential advantage of targets vs headers is that, rather than having to preprocess/parse a 400 lines long header file (RConfigure.h) for every compilation in ROOT, with a lot of ifdefs else branches, the compiler already gets the resolved defines via the -D flag, so the ifdef conditions are only checked once at configure time and never again. The difference will though probably be neglibible in building time.