-
Notifications
You must be signed in to change notification settings - Fork 455
Define a platform-support CMake target #1332
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
Conversation
mongo::detail::c_platform is intended to hold usage requirements common to all libraries in the project. This will replace usage of directory-level compile/link options, which do not propagate on the generated libraries when they are installed. This allows one to export/install libmongoc libraries that expose additional usage requirements, such as linking instrumentation runtimes (coverage, sanitizers, etc.) Also: Sanitizers.cmake and ENABLE_COVERAGE now attach their options to the platform-support library. This allows installed libmongoc with sanitizers enabled to "just work," as downstream users will now receive link options for coverage and sanitizers as usage requirements from the libbson and libmongoc libraries. Also: Enable threading on c_platform rather than linking. Fix the bson and mongoc packages to pull Threads::Threads as a dependency This also affects generated pkg-config files automatically.
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.
LGTM
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.
Minor feedback; otherwise, LGTM. 👏 for more target-based configuration.
build/cmake/MongoC-Warnings.cmake
Outdated
@@ -47,7 +47,7 @@ function (mongoc_add_platform_compile_options) | |||
endif() | |||
set(opt "$<${expr}:${suffix}>") | |||
else () | |||
message (SEND_ERROR "Unknown option prefix to mongoc_add_platform_compile_options(): “${prefix}” in “${opt}”") | |||
message (SEND_ERROR "Unknown option prefix to mongoc_add_warning_options(): “${prefix}” in “${opt}”") |
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.
message (SEND_ERROR "Unknown option prefix to mongoc_add_warning_options(): “${prefix}” in “${opt}”") | |
message (SEND_ERROR "Unknown option prefix to ${CMAKE_CURRENT_FUNCTION}(): “${prefix}” in “${opt}”") |
build/cmake/MongoPlatform.cmake
Outdated
# Enable multi-threading: | ||
set(THREADS_PREFER_PTHREAD_FLAG TRUE) | ||
find_package(Threads REQUIRED) | ||
mongo_platform_use_target(Threads::Threads) |
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.
Seems a little out-of-place. Suggest moving into root CMakeLists.txt
given it applies to both libbson and libmongoc.
add_library(_mongo-platform INTERFACE) | ||
add_library(mongo::detail::c_platform ALIAS _mongo-platform) | ||
set_property(TARGET _mongo-platform PROPERTY EXPORT_NAME detail::c_platform) | ||
install(TARGETS _mongo-platform EXPORT bson-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.
install(TARGETS _mongo-platform EXPORT bson-targets) | |
install(TARGETS _mongo-platform EXPORT bson-targets) | |
install(TARGETS _mongo-platform EXPORT mongoc-targets) |
Do we want to include the imported target in the mongoc-targets file as well? Or are we fine with obtaining it transitively via libbson?
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.
Seems a little out-of-place. Consider moving the install()
command into src/libbson/CMakeLists.txt
?
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.
It has to be exported only once, otherwise it will be defined twice and goofs will ensue. I chose the bson-targets export set only because it is pulled by both bson and mongoc. An "ideal" would be to define a third export set, but I think that has diminishing value when it can just ride along with the bson targets. I've also tucked it into the "detail" namespace so that we "reserve the right" to move/break/change/delete it in the future.
This changeset introduces a target
mongo::detail::c_platform
, which exposes usage requirements common to the platform on which we are being built. This consolidates some duplicated build setting handling between libbson and libmongoc, and introduces a central location for such settings.This also replaces usage of
add_compile_options
for directory-level build settings. Such settings are now propagated properly on install results (including the generated pkg-config files).