Don't use the unofficial libevent component #1837
Merged
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.
The official libevent cmake file, does not declare the libevent component, which is a combination of
core
andextra
, see https://github.com/libevent/libevent/blob/master/cmake/LibeventConfig.cmake.in, so it should not be used here, even if the embeddedFindLibevent.cmake
supports it.This causes problems for me in combination with the Conan package manager, which sets
CMAKE_FIND_PACKAGE_PREFER_CONFIG
to true, which makesfind_package
use the system version instead of the embedded version, and therefore fails to find thelibevent
component. See this discussion and other linked issues for more information about that conan-io/conan#12488This is a problem only if the configuration is set to not need libevent, since
find_package
is called unconditionally. When libevent is actually needed, the Conan version will be used instead, which does not cause any problems.The fix is simple, just request
core
andextra
instead oflibevent
. I did not make any changes toFindLibevent.cmake
, since this change works with the version in this repository without any changes. But I do believe that in the long run it would be better to replace it with something much closer to the officialLibeventConfig.cmake
.