mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-12-03 03:31:27 +00:00
Improve check for clock_gettime() and use it on Darwin
Also remove the CMake check which was broken anyway.
This commit is contained in:
1 parent
30b928f6ae
commit
67996eca5d
2 files changed
+11
-49
No files matched your search
@@ -78,36 +78,6 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT(MSVC OR APPLE))
|
||||
include(CheckLibraryExists)
|
||||
CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_CLOCK_GETTIME)
|
||||
|
||||
if (NOT HAVE_CLOCK_GETTIME)
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES time.h)
|
||||
CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
|
||||
SET(CMAKE_EXTRA_INCLUDE_FILES)
|
||||
endif()
|
||||
|
||||
foreach(clock CLOCK_MONOTONIC CLOCK_MONOTONIC_RAW)
|
||||
message(STATUS "Testing whether ${clock} can be used")
|
||||
CHECK_CXX_SOURCE_COMPILES(
|
||||
"#define _POSIX_C_SOURCE 200112L
|
||||
#include <time.h>
|
||||
int main ()
|
||||
{
|
||||
struct timespec ts[1];
|
||||
clock_gettime (${clock}, ts);
|
||||
return 0;
|
||||
}" HAVE_${clock})
|
||||
if(HAVE_${clock})
|
||||
message(STATUS "Testing whether ${clock} can be used -- Success")
|
||||
else()
|
||||
message(STATUS "Testing whether ${clock} can be used -- Failed")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
endif()
|
||||
|
||||
target_include_directories(moonlight-common-c SYSTEM PUBLIC src)
|
||||
|
||||
target_include_directories(moonlight-common-c SYSTEM PRIVATE
|
||||
|
||||
Reference in new issue
Block a user