CMake config files don't need any logic to detect the location of
installed headers or DSOs, because these locations are already
determined at project configuration time. They also don't need
to distinguish between build and install trees, because that is
already handled by the generated `LibeventTargets-*.cmake` files.
The current cmake/LibeventConfig.cmake.in has a few problems and I'm not
sure how cleanly developed it is. It seems rater complex for the little
things I would assume it needs to do.
I found two problems that are fixed in this PR:
- If the downstream user does not explicitly set LIBEVENT_STATIC_LINK
before calling find_package(libevent) then they will not be able to
detect the static library, even if its the only one that exists. Since
this may be rather strict, I've changed the behavior so that
LIBEVENT_STATIC_LINK can be set to ON or OFF, but if unset, it defaults
to whatever configuration libevent was built as.
- The other problem is a bug. The package configuration needs to unset
CMAKE_FIND_LIBRARY_SUFFIXES after use, otherwise all packages that are
detected after libevent will be "infected" by this setting. This was a
significant problem for us, and is very hard to detect in downstream
project, because the order of dependencies will lead to different search
results.
Since they are useful for debugging, and if autotools build them then
cmamke has to do this too, to make migration more simple.
And now:
- tests: uses shared libraries (since this is upstreams one)
- other binaries: uses static libraries
This removes next private config:
- EVENT__NEED_DLLIMPORT
This will remove openssl requirement if you don't use it (i.e. if you
not link with openssl_pthreads).
Plus it fixes some linking dependencies:
- libm required only for test-ratelim
And fix some coding style alignment issues.
Refs: #246