Skip to content

Commit

Permalink
Fix clock_gettime detection on osx
Browse files Browse the repository at this point in the history
  • Loading branch information
xzcvczx committed Jan 21, 2017
1 parent d6e7193 commit cbfdba8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -609,6 +609,7 @@ if (NOT WIN32)
# Check library functions
include(CheckFunctionExists)
check_function_exists(localtime_r HAVE_LOCALTIME_R)
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)
Expand Down
12 changes: 5 additions & 7 deletions adm/cmake/TKernel/CMakeLists.txt
Expand Up @@ -28,19 +28,17 @@ set(TOOLKIT_LIBS ${TOOLKIT_LIBS} ${CMAKE_DL_LIBS} ${LM})
if(WIN32)
set(TOOLKIT_LIBS ${TOOLKIT_LIBS} ${CSF_SOCKETLibs_LIB} ${CSF_advapi32_LIB} ${CSF_gdi32_LIB} ${CSF_user32_LIB} ${CSF_kernel32_LIB} ${CSF_psapi_LIB})
else(WIN32)
#  An implementation for Mac OS X has been added in src/OSD/gettime_osx.h
if(NOT APPLE)
include( CheckFunctionExists )
check_function_exists( clock_gettime CLOCK_GETTIME_IN_LIBC )
if(NOT CLOCK_GETTIME_IN_LIBC)
if(NOT HAVE_CLOCK_GETTIME)
# An implementation for macOS has been added in src/OSD/gettime_osx.h
if(NOT APPLE)
include( CheckLibraryExists )
check_library_exists(rt clock_gettime "" CLOCK_GETTIME_IN_LIBRT)
if(NOT CLOCK_GETTIME_IN_LIBRT)
message(FATAL_ERROR "Could not find clock_gettime.")
endif(NOT CLOCK_GETTIME_IN_LIBRT)
set(TOOLKIT_LIBS ${TOOLKIT_LIBS} rt)
endif(NOT CLOCK_GETTIME_IN_LIBC)
endif(NOT APPLE)
endif(NOT APPLE)
endif(NOT HAVE_CLOCK_GETTIME)
endif(WIN32)

# Adde-DHAVE_TBB in TKernel in order to benefit from Standard_MMgrTBBalloc
Expand Down
3 changes: 3 additions & 0 deletions adm/cmake/config/oce_build_config.h.cmake
Expand Up @@ -22,6 +22,9 @@
/* Define to 1 if the localtime_r function is available. */
#cmakedefine HAVE_LOCALTIME_R 1

/* Define to 1 if the clock_gettime function is available in libc. */
#cmakedefine HAVE_CLOCK_GETTIME 1

/* Define to 1 if the posix_memalign function is available. */
#cmakedefine HAVE_POSIX_MEMALIGN 1

Expand Down
2 changes: 1 addition & 1 deletion src/OSD/OSD_Chronometer.cxx
Expand Up @@ -51,7 +51,7 @@
#include <mach/mach.h>
#endif

#if defined(__APPLE__) && defined(__MACH__)
#if defined(__APPLE__) && !defined(HAVE_CLOCK_GETTIME)
#include "gettime_osx.h"
#endif

Expand Down

0 comments on commit cbfdba8

Please sign in to comment.