cmake: mac: Don't require rt library

heavy-resources
Martin Plicht 2012-02-14 16:25:23 +01:00
parent f5e7743a77
commit 379836f32c
2 changed files with 13 additions and 1 deletions

View File

@ -1007,7 +1007,7 @@ if(USE_CONSOLE)
${READLINE_LIBRARIES}
)
endif()
if(UNIX)
if(UNIX AND NOT APPLE)
target_link_libraries(c4group rt)
target_link_libraries(c4script rt)
target_link_libraries(netpuncher rt)

View File

@ -30,14 +30,26 @@ unsigned int GetTime()
#else
#ifdef __APPLE__
#include <sys/time.h>
#else
#include <time.h>
#endif
unsigned int GetTime()
{
#ifdef __APPLE__
static time_t sec_offset;
timeval tv;
gettimeofday(&tv, 0);
if (!sec_offset) sec_offset = tv.tv_sec;
return (tv.tv_sec - sec_offset) * 1000 + tv.tv_usec / 1000;
#else
timespec tv;
clock_gettime(CLOCK_MONOTONIC, &tv);
static time_t sec_offset = tv.tv_sec;
return (tv.tv_sec - sec_offset) * 1000 + tv.tv_nsec / 1000000;
#endif
}
#endif