diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4d0b7f1016749714838e6d731fdfef93e05573f4..7d8b71cb2cbe4a90ad337da2fc8935ff196642c5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,7 +11,12 @@ INCLUDE_DIRECTORIES(./exceptions ./mutex ./events ./threads ./logs ./time) ADD_LIBRARY(iriutils SHARED ${sources}) #edit the following line to add the necessary system libraries (if any) -TARGET_LINK_LIBRARIES(iriutils pthread rt) +IF(APPLE) + MESSAGE("APPLE SYSTEM FOUND") + TARGET_LINK_LIBRARIES(iriutils pthread) +ELSE(APPLE) + TARGET_LINK_LIBRARIES(iriutils pthread rt) +ENDIF(APPLE) INSTALL(TARGETS iriutils RUNTIME DESTINATION bin diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index be21df5cad72675ce23fdbd627dd7214ec2a9d6c..55933e95222c71f7654e4e70af73d04d33b4d536 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -32,7 +32,11 @@ TARGET_LINK_LIBRARIES(test_both iriutils pthread) ADD_EXECUTABLE(test_time test_time.cpp) # edit the following line to add the necessary libraries -TARGET_LINK_LIBRARIES(test_time iriutils pthread rt) +IF(APPLE) + TARGET_LINK_LIBRARIES(test_time iriutils pthread) +ELSE(APPLE) + TARGET_LINK_LIBRARIES(test_time iriutils pthread rt) +ENDIF(APPLE) # edit the following line to add the source code for the example and the name of the executable ADD_EXECUTABLE(test_logs test_logs.cpp) diff --git a/src/time/ctime.cpp b/src/time/ctime.cpp index bf1abf5d04c45ae19aca00be243b45af11a5ead5..162d609d785c9f9eea6f1e74ee58a3c43e84a05f 100644 --- a/src/time/ctime.cpp +++ b/src/time/ctime.cpp @@ -104,7 +104,14 @@ void CTime::set(double milliseconds) if(milliseconds<0.0) { - clock_gettime(CLOCK_REALTIME, &time_temp ); +#if defined __APPLE__ + struct timeval tv; + gettimeofday(&tv, NULL); + time_temp.tv_sec = tv.tv_sec; + time_temp.tv_nsec = tv.tv_usec*1000; +#else + clock_gettime(CLOCK_REALTIME, &time_temp ); +#endif } else {