PROTON-2327: Fix example build breakage on cmake 2.8.12
diff --git a/c/examples/CMakeLists.txt b/c/examples/CMakeLists.txt
index 87f85c4..04758e2 100644
--- a/c/examples/CMakeLists.txt
+++ b/c/examples/CMakeLists.txt
@@ -24,6 +24,24 @@
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
+# The following block is purely for CMake 2.8.12
+# Remove it when we no longer support CMake 2.8.12
+if(NOT TARGET Threads::Threads)
+ add_library(Threads::Threads UNKNOWN IMPORTED)
+
+ if(THREADS_HAVE_PTHREAD_ARG)
+ set_target_properties(Threads::Threads PROPERTIES
+ INTERFACE_COMPILE_OPTIONS "-pthread"
+ )
+ endif()
+
+ if(CMAKE_THREAD_LIBS_INIT)
+ set_target_properties(Threads::Threads PROPERTIES
+ IMPORTED_LOCATION "${CMAKE_THREAD_LIBS_INIT}"
+ )
+ endif()
+endif()
+
foreach (name broker send receive direct send-abort send-ssl raw_echo raw_connect)
add_executable(c-${name} ${name}.c)
target_link_libraries(c-${name} Proton::core Proton::proactor Threads::Threads)
diff --git a/cpp/examples/CMakeLists.txt b/cpp/examples/CMakeLists.txt
index a5b9c91..9b80b6a 100644
--- a/cpp/examples/CMakeLists.txt
+++ b/cpp/examples/CMakeLists.txt
@@ -24,6 +24,24 @@
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
+# The following block is purely for CMake 2.8.12
+# Remove it when we no longer support CMake 2.8.12
+if(NOT TARGET Threads::Threads)
+ add_library(Threads::Threads UNKNOWN IMPORTED)
+
+ if(THREADS_HAVE_PTHREAD_ARG)
+ set_target_properties(Threads::Threads PROPERTIES
+ INTERFACE_COMPILE_OPTIONS "-pthread"
+ )
+ endif()
+
+ if(CMAKE_THREAD_LIBS_INIT)
+ set_target_properties(Threads::Threads PROPERTIES
+ IMPORTED_LOCATION "${CMAKE_THREAD_LIBS_INIT}"
+ )
+ endif()
+endif()
+
macro (has_cxx_features result)
set(${result} OFF)
if (DEFINED CMAKE_CXX_COMPILE_FEATURES)