CXX-2745 Add advanced CMake options to toggle root namespace redeclarations #1324
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.
An intermediate PR related to CXX-2745 following #1318.
Add advanced, for-development-only CMake options
BSONCXX_API_OVERRIDE_DEFAULT_ABI
andMONGOCXX_API_OVERRIDE_DEFAULT_ABI
to permit toggling the ABI namespace that is used by root namespace redeclarations.Important
These options are NOT intended for public use. This is strictly for development purposes. Enabling these options will emit CMake configuration warnings:
The options are also marked as "advanced" so they do not show up in CMake GUIs by default.
When enabled, relevant root namespace redeclarations will use
v1
interfaces instead ofv_noabi
interfaces, e.g.:This permits manually verifying compilation and runtime compatibility of
v1
interfaces via root namespace redeclarations against existing code (e.g.bsoncxx::document::view (bsoncxx::v1::document::view)
). This toggle will continue to be used throughout upcoming PRs to both document and control the set of v1 interfaces which are "ready for use". These options may be toggled individually for each library (although mongocxx should be only be enabled when bsoncxx is also enabled).At the moment, this PR only applies this option to
stdx::string_view
andstdx::optional<T>
. These are the only v1 interfaces which are currently "ready for use". This can be validated right now by building and running the C++ Driver with theBSONCXX_API_OVERRIDE_DEFAULT_ABI
option enabled.As more
v1
interfaces are introduced andv_noabi
interfaces updated to support forward-compatibility withv1
interfaces, the application of this configuration option will be incrementally extended to allow for reuse of existing (test) code for API and behavioral testing ofv1
interfaces. This macro may also be used to denote v_noabi interfaces which do not have direct v1 counterparts (no correspondingv1
redeclarations), e.g.:Conversely, new v1 interfaces, or those which substantially differ from their v_noabi equivalents, may introduce new redeclarations without v_noabi counterparts (reverse of the above).
Once v1 interfaces are sufficiently ready for use, this pattern will also permit users to opt-into using
v1
interfaces early and migrate fromv_noabi
tov1
. This may be done either with a different CMake option designed to target user configuration rather than internal development, or by converting this CMake option from advanced, for-development-only into a user-facing CMake option.