1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
# Module that makes the clock_gettime() function available
#
# Sets the following variables:
# HAVE_LIBRT
# LIBRT_LIBRARIES
#
# perform tests
include(CheckCSourceCompiles)
# first check if we need to add anything at all to be able to use
# clock_gettime()
CHECK_CXX_SOURCE_COMPILES("
#include <time.h>
int main()
{
timespec time1;
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1);
};
" HAVE_LIBRT)
cmake_pop_check_state()
if (HAVE_LIBRT)
# if this worked, we're already happy
set(LIBRT_LIBRARIES "")
else()
# if not, let's try the same program with linking to librt (required
# on some systems)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES "rt")
CHECK_CXX_SOURCE_COMPILES("
#include <time.h>
int main()
{
timespec time1;
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1);
};
" HAVE_LIBRT2)
cmake_pop_check_state()
set(HAVE_LIBRT "${HAVE_LIBRT2}")
if (HAVE_LIBRT)
set(LIBRT_LIBRARIES "rt")
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibRT
DEFAULT_MSG
HAVE_LIBRT
)
|