cmake: add macro add_unit_test to reduce code duplication

This macro is now used by add_test_executable and
add_session_test_executable.
11 jobs for cmake-add-unit-test-macro in 10 minutes and 51 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Build
passed #5814595
build:cmake

00:05:20

passed #5814592
build:debug

00:07:24

manual #5814597
allowed to fail manual
build:i686-w64-mingw32-cmake
passed #5814596
build:i686-w64-mingw32-debug

00:07:06

manual #5814594
allowed to fail manual
build:legacy
passed #5814591
build:production

00:06:36

manual #5814593
allowed to fail manual
build:reduced
manual #5814600
allowed to fail manual
build:stretch
passed #5814598
build:x86_64-w64-mingw32

00:04:39

passed #5814599
build:x86_64-w64-mingw32-cmake-debug

00:10:41

manual #5814601
allowed to fail manual
build:xenial