Commit f09065c9 authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

cmake: use the built-in FindThreads module

Summary:
Use CMake's built-in FindThreads module rather than having our own custom
FindPThread.cmake module.

Reviewed By: yfeldblum

Differential Revision: D9212535

fbshipit-source-id: 9a652c510cb310c18547d31bd8215dedd8532a4c
parent 48d6f314
# - Try to find libpthread
#
# Once done this will define
#
# LIBPTHREAD_FOUND - system has libpthread
# LIBPTHREAD_INCLUDE_DIRS - the libpthread include directory
# LIBPTHREAD_LIBRARIES - Link these to use libpthread
# LIBPTHREAD_DEFINITIONS - Compiler switches required for using libpthread
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (LIBPTHREAD_LIBRARIES AND LIBPTHREAD_INCLUDE_DIRS)
set (LIBPTHREAD_FIND_QUIETLY TRUE)
endif (LIBPTHREAD_LIBRARIES AND LIBPTHREAD_INCLUDE_DIRS)
find_path (LIBPTHREAD_INCLUDE_DIRS NAMES pthread.h)
find_library (LIBPTHREAD_LIBRARIES NAMES pthread)
include (FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPTHREAD DEFAULT_MSG
LIBPTHREAD_LIBRARIES LIBPTHREAD_INCLUDE_DIRS)
mark_as_advanced(LIBPTHREAD_INCLUDE_DIRS LIBPTHREAD_LIBRARIES LIBPTHREAD_FOUND)
...@@ -2,6 +2,13 @@ include(CheckCXXSourceCompiles) ...@@ -2,6 +2,13 @@ include(CheckCXXSourceCompiles)
include(CheckIncludeFileCXX) include(CheckIncludeFileCXX)
include(CheckFunctionExists) include(CheckFunctionExists)
set(CMAKE_THREAD_PREFER_PTHREAD ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(FOLLY_HAVE_PTHREAD "${CMAKE_USE_PTHREADS_INIT}")
list(APPEND CMAKE_REQUIRED_LIBRARIES Threads::Threads)
list(APPEND FOLLY_LINK_LIBRARIES Threads::Threads)
find_package(Boost 1.51.0 MODULE find_package(Boost 1.51.0 MODULE
COMPONENTS COMPONENTS
context context
...@@ -74,15 +81,6 @@ list(APPEND CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) ...@@ -74,15 +81,6 @@ list(APPEND CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES})
list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
check_function_exists(ASN1_TIME_diff FOLLY_HAVE_OPENSSL_ASN1_TIME_DIFF) check_function_exists(ASN1_TIME_diff FOLLY_HAVE_OPENSSL_ASN1_TIME_DIFF)
find_package(PThread MODULE)
set(FOLLY_HAVE_PTHREAD ${LIBPTHREAD_FOUND})
if (LIBPTHREAD_FOUND)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBPTHREAD_LIBRARIES})
list(APPEND CMAKE_REQUIRED_INCLUDES ${LIBPTHREAD_INCLUDE_DIRS})
list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LIBPTHREAD_INCLUDE_DIRS})
list(APPEND FOLLY_LINK_LIBRARIES ${LIBPTHREAD_LIBRARIES})
endif()
find_package(ZLIB MODULE) find_package(ZLIB MODULE)
set(FOLLY_HAVE_LIBZ ${ZLIB_FOUND}) set(FOLLY_HAVE_LIBZ ${ZLIB_FOUND})
if (ZLIB_FOUND) if (ZLIB_FOUND)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment