Add support for building without PThread to the CMake files
authorChristopher Dykes <cdykes@fb.com>
Fri, 14 Apr 2017 20:51:43 +0000 (13:51 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 14 Apr 2017 21:05:01 +0000 (14:05 -0700)
Summary: Because, soon it won't be required.

Reviewed By: yfeldblum

Differential Revision: D4892076

fbshipit-source-id: 6bfbf5bf523262659c0af336f659398ae8545e50

CMake/folly-config.h.cmake
CMake/folly-deps.cmake
CMakeLists.txt

index e3c1396..7841aa0 100755 (executable)
@@ -16,6 +16,8 @@
 \r
 #pragma once\r
 \r
+#cmakedefine FOLLY_HAVE_PTHREAD\r
+\r
 #define FOLLY_HAVE_LIBGFLAGS 1\r
 #define FOLLY_UNUSUAL_GFLAGS_NAMESPACE 1\r
 #define FOLLY_GFLAGS_NAMESPACE google\r
@@ -24,7 +26,6 @@
 #define FOLLY_HAVE_MALLOC_H 1\r
 #define FOLLY_HAVE_MEMRCHR 0\r
 #define FOLLY_HAVE_PREADV 0\r
-#define FOLLY_HAVE_PTHREAD_SPINLOCK_T 1\r
 #define FOLLY_HAVE_PWRITEV 0\r
 #define FOLLY_HAVE_SCHED_H 1\r
 #define FOLLY_HAVE_STD__IS_TRIVIALLY_COPYABLE 1\r
index 8f972c5..211c6fb 100755 (executable)
@@ -15,4 +15,4 @@ find_package(GFlags MODULE REQUIRED)
 find_package(GLog MODULE REQUIRED)\r
 find_package(LibEvent MODULE REQUIRED)\r
 find_package(OpenSSL MODULE REQUIRED)\r
-find_package(PThread MODULE REQUIRED)\r
+find_package(PThread MODULE)\r
index 030d1c7..3670146 100755 (executable)
@@ -62,6 +62,11 @@ add_custom_command(
   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/folly/build/
   COMMENT "Generating the group varint tables..." VERBATIM
 )
+
+include(folly-deps) # Find the required packages
+if (LIBPTHREAD_FOUND)
+  set(FOLLY_HAVE_PTHREAD ON)
+endif()
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/CMake/folly-config.h.cmake
   ${CMAKE_CURRENT_BINARY_DIR}/folly/folly-config.h
@@ -125,14 +130,12 @@ source_group("folly\\build" FILES
   ${CMAKE_CURRENT_BINARY_DIR}/folly/build/GroupVarintTables.cpp
 )
 
-include(folly-deps) # Find the required packages
 target_include_directories(folly_base
   PUBLIC
     ${DOUBLE_CONVERSION_INCLUDE_DIR}
     ${LIBGFLAGS_INCLUDE_DIR}
     ${LIBGLOG_INCLUDE_DIR}
     ${LIBEVENT_INCLUDE_DIR}
-    ${LIBPTHREAD_INCLUDE_DIRS}
 )
 target_link_libraries(folly_base
   PUBLIC
@@ -147,11 +150,14 @@ target_link_libraries(folly_base
     ${LIBEVENT_LIB}
     ${LIBGFLAGS_LIBRARY}
     ${LIBGLOG_LIBRARY}
-    ${LIBPTHREAD_LIBRARIES}
     OpenSSL::SSL
     OpenSSL::Crypto
     Ws2_32.lib
 )
+if (FOLLY_HAVE_PTHREAD)
+  target_include_directories(folly_base PUBLIC ${LIBPTHREAD_INCLUDE_DIRS})
+  target_link_libraries(folly_base PUBLIC ${LIBPTHREAD_LIBRARIES})
+endif()
 
 # Now to generate the fingerprint tables
 add_executable(GenerateFingerprintTables