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

cmake: find threads before applying compiler settings

Summary:
In D10405960 I moved folly-deps.cmake to be processed after
FollyCompilerMSVC.cmake.

It turns out that this causes configuration to fail in confusing ways when
compiling with clang.  CMake fails reporting that it cannot find pthread.h,
but the real problem is just that clang does not like the `-std=gnu++14` flag
that has been applied by FollyCompilerUnix.cmake.  CMake doesn't appear to
have C++-only version of `CMAKE_REQUIRED_FLAGS`, so this `-std` flag was being
used even when invoking clang in C-only mode.

Moving the `find_package(Threads)` call avoids this issue.

Reviewed By: yfeldblum

Differential Revision: D10435249

fbshipit-source-id: 214ec9bbef43679864f714dc39c1e4423081c09b
parent 7bcd14c5
...@@ -2,13 +2,6 @@ include(CheckCXXSourceCompiles) ...@@ -2,13 +2,6 @@ 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
......
...@@ -68,6 +68,13 @@ set( ...@@ -68,6 +68,13 @@ set(
include(GNUInstallDirs) include(GNUInstallDirs)
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)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows") if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
include(FollyCompilerMSVC) include(FollyCompilerMSVC)
else() else()
......
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