On systems where a previous version of Libevent is installed we don't want the system version of the headers to be included before the ones in the build tree. This happened on my OSX system where I had an ancient version of Libevent installed. It would then load the incorrect event-config.h and fail because the system introspection macros weren't set properly.
Use lcov/gcov to gather coverage info for the tests (Only works with gcc/clang and make).
cmake -DEVENT__COVERAGE=1 -DCMAKE_BUILD_TYPE=Debug ..
make
make verify_coverage
Current coverage (run on debian):
Line coverage 79.1 % 10231 / 12939
Function coverage 86.1 % 933 / 1083
Windows does not have the "unset" command, but this doesn't matter since
the problem that requires us to use unset doesn't happen on Windows.
Also did some minor cosmetic changes, and dependcy changes.
This is more than for cosmetic purposes to match how it's done with autoconf.
Due to the fact that we use environment variables to turn off certain backends during the tests, simply running "ctest" or "make test" can result in failed tests.
This is because if you do "EVENT_NOEPOLL=yes && export EVENT_NOEPOLL" and then run the tests, when running the epoll tests, the EPOLL backend will be turned off. There is no way of unsetting an environment variable for a test in CMake, you can only set them. And since libevent simply checks if the environment variable is set (it doesn't check the actual value of it), this won't work.
So to remedy this, we create the "make verify" target that first unsets all the EVENT_NO* environment variables, and then runs ctest.
Also bumped the required CMake version from 2.6 to 2.8, since the set_test_properties(bla PROPERTIES ENVIRONMENT "SOME_VAR") requires 2.8
Added some explicit dependencies for the test programs to libevent, so they don't just fail if you try to run the tests without first doing "make"
Fix how the CMake project adds the tests using the different backends. At
first we tried to do it exactly as it's done in test/test.sh.
However, test.sh uses a special program test-init to decide if a given
backend is available or not before running the actual tests. Doing it this way
will not be possible using CMake. Since then we would have to have the
test-init executable compiled at the time we run CMake, to know what tests
we should add. (And since CMake generates the make/project files that
compiles the executables, there's a catch 22).
Instead of deciding what tests to run this way, we simply use the result
of the CMake system introspection (that figures out what backends are
available) to decide what backend tests to add.