CMake: Link libm to test binaries if available.

If libm is available link it to test binaries which will otherwise
fail to compile. Tested on FreeBSD 13-STABLE.

Signed-off-by: Daniel Engberg <daniel.engberg.lists@pyret.net>
Signed-off-by: Ralph Giles <giles@thaumas.net>
2 jobs for libm in 1 minute and 48 seconds (queued for 5 seconds)
Status Job ID Name Coverage
  Build
passed #11676
docker
autoconf

00:01:48

passed #11677
docker
cmake

00:00:37