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()
|
2020-09-11 17:45:40 +00:00
|
|
|
if(LIBRT)
|
2018-11-05 13:18:57 +00:00
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBRT}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2022-02-21 12:40:27 +00:00
|
|
|
int main(int, char **) {
|
2018-11-05 13:18:57 +00:00
|
|
|
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-09-18 16:53:30 +00:00
|
|
|
if (LIBRT)
|
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()
|
2020-06-26 16:32:53 +00:00
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(WrapRt DEFAULT_MSG WrapRt_FOUND)
|