preliminary cmake support. linking still broken.
[umurmur.git] / CMakeLists.txt
index 3b09b26cf2c40a0a95f7605ed41dc6ecc5c37672..9b2b5baf1cdae3e9c09371517b46d01d907f3ea6 100644 (file)
@@ -7,10 +7,23 @@ add_definitions()
 include(FindPkgConfig)
 include(CheckFunctionExists)
 include(CheckLibraryExists)
+include(CheckSymbolExists)
 
 pkg_check_modules(BASELIBS libconfig)
-check_function_exists(clock_gettime GAVE_CLOCK_GETTIME)
-check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_RT)
+
+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
+
+if(NOT HAVE_CLOCK_GETTIME)
+  check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_RT)
+  if(NOT HAVE_CLOCK_GETTIME_RT)
+    check_library_exists(c clock_get_time "mach/time.h" HAVE_CLOCK_GET_TIME)
+    if(NOT HAVE_CLOCK_GET_TIME)
+      message(FATAL_ERROR "Didn't find clock_gettime() or clock_get_time!")
+    endif()
+  else()
+    set(LIBRARIES ${LIBRARIES} rt)
+  endif()
+endif()
 
 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")