-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Use find_package to find SASL2 library #5243
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
base: master
Are you sure you want to change the base?
Use find_package to find SASL2 library #5243
Conversation
Instead of relying only on the pkg-config to find the SASL2 library, we should also respect the CMAKE_PREFIX_PATH by using find_package in case sasl2 should be linked statically.
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
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.
Pull Request Overview
This PR enhances the SASL2 library detection mechanism in CMake by adding find_package support alongside the existing pkg-config method. This allows the build system to respect CMAKE_PREFIX_PATH for static linking scenarios.
Key changes:
- Added
find_package(SASL2)as the primary detection method before falling back to pkg-config - Restructured the conditional logic to check for SASL2 via find_package first
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if(PkgConfig_FOUND) | ||
| pkg_check_modules(SASL libsasl2) | ||
| if(SASL_FOUND) | ||
| set(with_sasl_default ON) | ||
| set(SASL_LIBRARIES "-lsasl2") | ||
| else() | ||
| set(with_sasl_default OFF) | ||
| endif() | ||
| else() | ||
| try_compile( | ||
| WITH_SASL_CYRUS_BOOL | ||
| "${CMAKE_CURRENT_BINARY_DIR}/try_compile" | ||
| "${TRYCOMPILE_SRC_DIR}/libsasl2_test.c" | ||
| LINK_LIBRARIES "-lsasl2" | ||
| ) | ||
| if(WITH_SASL_CYRUS_BOOL) | ||
| set(with_sasl_default ON) | ||
| set(SASL_LIBRARIES "-lsasl2") | ||
| else() | ||
| set(with_sasl_default OFF) |
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.
Not sure whether we still need this if we are using find_package(SASL2).
Instead of relying only on the pkg-config to find the SASL2 library, we should also respect the CMAKE_PREFIX_PATH by using find_package in case sasl2 should be linked statically.