waf: cxx_checks: add check_librt()

That function verifies for the necessity of linking against librt. If so, then
it checks if it is possible to do so.
This commit is contained in:
Gustavo Jose de Sousa 2016-05-19 17:24:12 -03:00 committed by Lucas De Marchi
parent e630c2b33f
commit f10c150e70
1 changed files with 24 additions and 0 deletions

View File

@ -123,3 +123,27 @@ def ap_common_checks(cfg):
msg="Checking for NEED_CMATH_ISNAN_STD_NAMESPACE",
mandatory=False,
)
@conf
def check_librt(cfg):
success = cfg.check(
compiler='cxx',
fragment='''
#include <time.h>
int main() {
clock_gettime(CLOCK_REALTIME, NULL);
}''',
msg='Checking for need to link with librt',
okmsg='not necessary',
errmsg='necessary',
mandatory=False,
)
if success:
return success
return cfg.check(
compiler='cxx',
lib='rt',
)