MONGOCRYPT-839 address CMP0169 for CMake 3.30 and newer #1053
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.
Followup to #1052.
Addresses CMP0169, which has been emitting a warning since CMake 3.18, but is made an error since 3.30 when the policy is set to
NEW(as is now the case following #1052):This is the same issue described in mongodb/mongo-cxx-driver#1186, and the solution is the same: using
*_MakeAvailable()for CMake 3.18 and newer (which supportsSOURCE_SUBDIR), and using*_Populate()for backward compatibility until the minimum required CMake version is raised to 3.18 or newer. This applies to IntelDFP (targets manually defined inIntelDFP.cmake) and libbson (manual call toadd_subdirectory()inImportBSON.cmake).Interestingly, the initial attempt to apply this change produced the following error:
This is due to the mongo-c-driver project being
add_subdirectory()'d twice: once by*_MakeAvailable()and once again later inImportBSON.cmake. Unlike in mongodb/mongo-cxx-driver#1186, it seems newer CMake versions do not acceptSOURCE_SUBDIR ""as a workaround (possibly due to CMP0174?). Therefore, although a bit more awkward,SOURCE_SUBDIRis set to"/dev/null"instead of"". (It just needs to be a (non-existent) directory which does not contain aCMakeLists.txtfile.)