diff --git a/CMakeLists.txt b/CMakeLists.txt index 19e9705217..9e460bac8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/adm/cmake/TKernel/CMakeLists.txt b/adm/cmake/TKernel/CMakeLists.txt index 54e241e86e..e5fde8493c 100644 --- a/adm/cmake/TKernel/CMakeLists.txt +++ b/adm/cmake/TKernel/CMakeLists.txt @@ -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 diff --git a/adm/cmake/config/oce_build_config.h.cmake b/adm/cmake/config/oce_build_config.h.cmake index 0baec3d5a9..995386eecb 100644 --- a/adm/cmake/config/oce_build_config.h.cmake +++ b/adm/cmake/config/oce_build_config.h.cmake @@ -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 diff --git a/src/OSD/OSD_Chronometer.cxx b/src/OSD/OSD_Chronometer.cxx index 0e1949c511..c08f45488f 100644 --- a/src/OSD/OSD_Chronometer.cxx +++ b/src/OSD/OSD_Chronometer.cxx @@ -51,7 +51,7 @@ #include #endif -#if defined(__APPLE__) && defined(__MACH__) +#if defined(__APPLE__) && !defined(HAVE_CLOCK_GETTIME) #include "gettime_osx.h" #endif