CDRIVER-5876 detect aligned_alloc via CMake instead of feature test macros #1851
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.
Resolves CDRIVER-5876. Alternative (preferable?) solution to #1841.
When #1072 was implemented,
check_symbol_exists
was deliberately avoided due to difficulty with accurately setting the requiredCMAKE_REQUIRED_*
arguments, which are handled independently from the actual definitions and options used with the libraries being built (i.e. the various*_SOURCE
macros used to control POSIX, FreeBSD, and Darwin features). However, it seems there are enough platform-specific edge cases concerning the actual availability ofaligned_alloc
despite efforts to use approprate feature test macros that a build system check is sufficiently well-motivated at this stage.Therefore, this PR proposes adding a new
BSON_HAVE_ALIGNED_ALLOC
option tobson-config.h
, which is detected usingcheck_symbol_exists
alongside other existing checks. This PR also applies a drive-by scan and update toCMAKE_REQUIRED_*
variables to ensure better consistency of definitions/options being used forcheck_*_exists
and the built libraries.As a reminder,
check_symbol_exists
behaves as follows:and:
Although
add_definitions
,add_compile_options
, and other directory-level and target-specific properties are not observed bycheck_symbol_exists
, configuration options such asCMAKE_C_STANDARD
andCMAKE_C_FLAGS
are observed bycheck_symbol_exists
. It is not entirely clear where/how the line is drawn. For our purposes, maintainingCMAKE_REQUIRED_DEFINITIONS
andCMAKE_REQUIRED_LIBRARIES
is probably sufficient to ensure consistency between symbol checks and built libraries.