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
Move bundling of JSON-C to CMake. #17207
Conversation
a160e7a
to
9f7cf2e
Compare
Rebased to resolve merge conflicts and pick up latest changes. |
adea2a0
to
08a1274
Compare
Rebased again to pick up latest changes in master. |
d67d429
to
92e25c0
Compare
This is required to ensure that options we set are propagated correctly into the sub-project.
92e25c0
to
17c564e
Compare
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.
If you address my comment (or disagree with it) feel free to red button this.
# | ||
# The specified target must already exist, and the netdata_detect_json-c | ||
# macro must have already been run at least once for this to work correctly. | ||
function(netdata_add_jsonc_to_target _target) |
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.
Please, don't do this. Over time it will become difficult to figure out easily the dependency DAG of targets.
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’m not sure how this significantly complicates things, unless you’re using some external script to parse the CMakeLists file and try to figure out the dependency graph from that.
This function being called on a target says quite clearly that that target depends on JSON-C. And because of how CMake handles adding dependencies, you need to be searching the whole file for the target name anyway instead of just blindly looking for target_*
calls on the target. I’m also trying to follow a netdata_add_*_to_target
pattern for functions like this so that they are easy to find and properly descriptive.
To clarify, my intent here is to keep all the arcana involved in getting this to actually work properly encapsulated. By handling it like this, anybody working on the build system won’t need to remember the names of the variables used to add JSON-C to a target, or where they are set, or whether the include directories need to be appended or prepended to the search list, or the fact that you need to add a supplementary dependency to the target to ensure that headers can be found correctly when using a vendored copy of JSON-C.
Summary
Similar rationale to #17190, our handling of JSON-C suffers from the same potential discrepancy between how our installer code sees the build environment and how CMake sees it. Shifting JSON-C vendoring into CMake eliminates that issue, and also allows for slightly better parallelization of the build/install process.
Test Plan
We actually validate vendoring of JSON-C in CI, so testing should not require anything other than confirming CI passes on this PR.