2019-06-05 12:28:31 +00:00
|
|
|
# We can't create the same interface imported target multiple times, CMake will complain if we do
|
|
|
|
# that. This can happen if the find_package call is done in multiple different subdirectories.
|
|
|
|
if(TARGET WrapRt)
|
|
|
|
set(WrapRt_FOUND ON)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2020-02-24 13:34:15 +00:00
|
|
|
set(WrapRt_FOUND OFF)
|
|
|
|
|
2018-11-05 13:18:57 +00:00
|
|
|
include(CheckCXXSourceCompiles)
|
2019-02-12 15:04:57 +00:00
|
|
|
include(CMakePushCheckState)
|
2018-11-05 13:18:57 +00:00
|
|
|
|
|
|
|
find_library(LIBRT rt)
|
|
|
|
|
2019-02-12 15:04:57 +00:00
|
|
|
cmake_push_check_state()
|
2018-11-05 13:18:57 +00:00
|
|
|
if(LIBRT_FOUND)
|
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBRT}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
timespec ts; clock_gettime(CLOCK_REALTIME, &ts);
|
|
|
|
}" HAVE_GETTIME)
|
|
|
|
|
2019-02-12 15:04:57 +00:00
|
|
|
cmake_pop_check_state()
|
2018-11-05 13:18:57 +00:00
|
|
|
|
|
|
|
|
2020-02-24 13:34:15 +00:00
|
|
|
if(HAVE_GETTIME)
|
|
|
|
set(WrapRt_FOUND ON)
|
|
|
|
add_library(WrapRt INTERFACE IMPORTED)
|
|
|
|
if (LIBRT_FOUND)
|
|
|
|
target_link_libraries(WrapRt INTERFACE "${LIBRT}")
|
|
|
|
endif()
|
|
|
|
endif()
|