Added missing librt to cmake which is required by clock_gettime.

librt does not automatically link for Ubuntu 12.04 for example,
so I added some changed to explicily link against it when found.
The changes to the CMakeLists.txt should be cross platform safe
since the changes are all conditionalized with if (RT_LIBRARY)