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.
|
2020-04-28 15:33:29 +00:00
|
|
|
if(TARGET WrapRt::WrapRt)
|
2019-06-05 12:28:31 +00:00
|
|
|
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)
|
2020-04-28 15:33:29 +00:00
|
|
|
add_library(WrapRt::WrapRt INTERFACE IMPORTED)
|
2020-02-24 13:34:15 +00:00
|
|
|
if (LIBRT_FOUND)
|
2020-04-28 15:33:29 +00:00
|
|
|
target_link_libraries(WrapRt::WrapRt INTERFACE "${LIBRT}")
|
2020-02-24 13:34:15 +00:00
|
|
|
endif()
|
|
|
|
endif()
|