diff --git a/CMake/FindPThread.cmake b/CMake/FindPThread.cmake new file mode 100644 index 000000000..557d704d7 --- /dev/null +++ b/CMake/FindPThread.cmake @@ -0,0 +1,27 @@ +# - 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) diff --git a/CMake/HPHPFindLibs.cmake b/CMake/HPHPFindLibs.cmake index 6398e94dc..8253882e0 100644 --- a/CMake/HPHPFindLibs.cmake +++ b/CMake/HPHPFindLibs.cmake @@ -18,7 +18,6 @@ include(CheckFunctionExists) # boost checks - find_package(Boost 1.48.0 COMPONENTS system program_options filesystem regex REQUIRED) include_directories(${Boost_INCLUDE_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) @@ -255,6 +254,10 @@ include_directories(${LDAP_INCLUDE_DIR}) find_package(Ncurses REQUIRED) include_directories(${NCURSES_INCLUDE_PATH}) +# libpthreads +find_package(PThread REQUIRED) +include_directories(${LIBPTHREAD_INCLUDE_DIRS}) + find_package(Readline REQUIRED) include_directories(${READLINE_INCLUDE_DIR}) @@ -394,7 +397,9 @@ endif() target_link_libraries(${target} ${BFD_LIB}) target_link_libraries(${target} ${BINUTIL_LIB}) - target_link_libraries(${target} pthread) +if (${LIBPTHREAD_LIBRARIES}) + target_link_libraries(${target} ${LIBPTHREAD_LIBRARIES}) +endif() target_link_libraries(${target} ${TBB_LIBRARIES}) target_link_libraries(${target} ${OPENSSL_LIBRARIES}) target_link_libraries(${target} ${ZLIB_LIBRARIES})