[CMake] Test for libdl and libpthread presence