Conversation
Add a USE_VENDORED_JSON CMake option (default ON) mirroring the other USE_VENDORED_* options. When disabled, find_package(nlohmann_json) is used instead of the bundled header, so the library and the consuming application can share the exact same nlohmann::json version and avoid ODR/ABI mismatches (issue BehaviorTree#1138). The bundled header is moved to contrib/nlohmann_json.hpp and contrib/json.hpp becomes a thin forwarding header that includes either the bundled copy or <nlohmann/json.hpp> depending on BTCPP_USE_EXTERNAL_JSON. Verified: library builds with USE_VENDORED_JSON=ON (vendored) and =OFF (system nlohmann-json 3.12.0); test suite 529/531 (2 pre-existing failures unrelated: CoroTest flake + SqliteLogger SIGSEGV).
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #1138.
Adds a
USE_VENDORED_JSONCMake option (defaultON), mirroring the existingUSE_VENDORED_CPPZMQ/USE_VENDORED_FLATBUFFERS/USE_VENDORED_MINICORO/USE_VENDORED_MINITRACEoptions.Why:
nlohmann::jsonis header-only, so when an application bundles a different version than the one vendored ininclude/behaviortree_cpp/contrib/json.hpp, you get ODR/ABI mismatches (duplicate/conflictingnlohmann::jsonsymbols and inconsistent behavior). This lets users opt into an externally providednlohmann_jsonpackage so both sides share the exact same version.Changes:
contrib/nlohmann_json.hpp.contrib/json.hppbecomes a thin forwarding header: includes<nlohmann/json.hpp>whenBTCPP_USE_EXTERNAL_JSONis defined, otherwise the bundled copy. No call sites change.USE_VENDORED_JSONoption +find_package(nlohmann_json)when disabled, withnlohmann_json::nlohmann_jsonlinkedPUBLICandBTCPP_USE_EXTERNAL_JSONpropagatedPUBLICso installed consumers get consistent behavior.Verified locally:
USE_VENDORED_JSON=ON(bundled) and=OFF(systemnlohmann-json3.12.0).CoroTest.sequence_childflake,LoggerTest.SqliteLogger_ExecSqlStatementSIGSEGV) reproduce on a cleanmasterand are unrelated to this change.