From: Roger Shimizu <rogershimizu@gmail.com>
Date: Tue, 19 Jul 2016 23:26:12 +0900
Subject: support cmake threads

Cherry-Pick a few changes from John Zachary's own github repo
to support CMake Threads

Thanks to great support from one of the original author of this library,
John Zachary <jzachary@jzachary.net>
---
 CMakeLists.txt     | 13 +++++++++++++
 src/CMakeLists.txt |  1 +
 2 files changed, 14 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e075911..a6b58e3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 # ----------------------------------------------------------------------
 # Copyright © 2011-2013, RedJack, LLC.
+#             2016, Cognize, LLC.
 # All rights reserved.
 #
 # Please see the LICENSE.txt file in this distribution for license
@@ -59,12 +60,24 @@ if(DEFINED ENV{TILERA_ROOT})
 endif()
 
 #-----------------------------------------------------------------------
+# Force a build type decision
+
+if(NOT CMAKE_BUILD_TYPE)
+    set(CMAKE_BUILD_TYPE Release CACHE STRING
+        "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
+        FORCE)
+endif(NOT CMAKE_BUILD_TYPE)
+
+#-----------------------------------------------------------------------
 # Check for prerequisite libraries
 
 pkg_check_modules(CORK REQUIRED "libcork >= 0.12.0")
 include_directories(${CORK_INCLUDE_DIRS})
 link_directories(${CORK_LIBRARY_DIRS})
 
+find_package(Threads)
+set(THREADS_LDFLAGS "${CMAKE_THREAD_LIBS_INIT}")
+
 #-----------------------------------------------------------------------
 # Set some options
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0d1bfb4..b61ff83 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -68,6 +68,7 @@ set_target_properties(libcorkipset PROPERTIES
     SOVERSION 1)
 target_link_libraries(libcorkipset
     ${CORK_LIBRARIES}
+    ${CMAKE_THREADS_LIBS_INIT}
 )
 
 install(TARGETS libcorkipset DESTINATION ${CMAKE_INSTALL_LIBDIR})
