summaryrefslogtreecommitdiffstats
path: root/Modules/FindProtobuf.cmake
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2013-05-08 20:04:30 (GMT)
committerMatthew Woehlke <matthew.woehlke@kitware.com>2013-05-24 19:44:10 (GMT)
commit8961c4b68bdf3202be0451a68418922cf869439c (patch)
tree696839ce7e36980f002f593e7e231eac29ce37a8 /Modules/FindProtobuf.cmake
parent619fa2cce851728790986108e6519e7f440387ee (diff)
downloadCMake-8961c4b68bdf3202be0451a68418922cf869439c.zip
CMake-8961c4b68bdf3202be0451a68418922cf869439c.tar.gz
CMake-8961c4b68bdf3202be0451a68418922cf869439c.tar.bz2
FindProtobuf: also find pthread
Modify FindProtobuf.cmake to find the pthread library on UNIX platforms, and to add the same to PROTOBUF_LIBRARIES, as this is a link dependency of libraries using the protobuf headers.
Diffstat (limited to 'Modules/FindProtobuf.cmake')
-rw-r--r--Modules/FindProtobuf.cmake13
1 files changed, 13 insertions, 0 deletions
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index af0c2dd..2972198 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -156,6 +156,16 @@ function(_protobuf_find_libraries name filename)
endif()
endfunction()
+# Internal function: find threads library
+function(_protobuf_find_threads)
+ set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
+ find_package(Threads)
+ if(Threads_FOUND)
+ list(APPEND PROTOBUF_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
+ set(PROTOBUF_LIBRARIES "${PROTOBUF_LIBRARIES}" PARENT_SCOPE)
+ endif()
+endfunction()
+
#
# Main.
#
@@ -190,6 +200,9 @@ if(MSVC)
set(CMAKE_FIND_LIBRARY_PREFIXES "${PROTOBUF_ORIG_FIND_LIBRARY_PREFIXES}")
endif()
+if(UNIX)
+ _protobuf_find_threads()
+endif()
# Find the include directory
find_path(PROTOBUF_INCLUDE_DIR