core: move main() function into Curses GUI
core: do not exit WeeChat in weechat_end() (let the caller do that)

This is needed for automated tests, to exit with return code of tests.
core: move some detections from src/CMakeLists.txt to root CMakeLists.txt
tests: add unit tests using CppUTest

The tests can be run only via CMake:

  1. build with tests: cmake .. -DENABLE_TESTS=ON
  2. make
  3. ctest  (or ctest -V for verbose output)