Commit 6e85117e authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook GitHub Bot

fix how folly and its downstream projects find boost

Summary:
Folly links explicitly links against boost statically on Windows.  However,
many downstream projects that use folly independently performed their own
discovery of boost and normally used the default option of linking against it
dynamically.  This resulted in boost being listed twice on the link line on
Windows for some downstream projects: both its static libraries and dynamic
libraries would be present.  This ends up causing linking failures due to
duplicate definitions.

This updates folly's installed CMake file to correctly call
`find_dependency(Boost)` so that downstream projects don't need to perform
their own independent discovery.  This ensures that all downstream projects
use a consistent method of linking against Boost.  I updated many downstream
projects to remove their explicit separate discovery, and rely only on this
behavior from folly.

I also added a configuration setting to allow explicitly selecting whether to
link against boost statically at folly configure time.

Reviewed By: wez

Differential Revision: D21232164

fbshipit-source-id: 9ecc3ce988add48905252297e979403c42e7e148
parent 4162d2f4
...@@ -30,6 +30,18 @@ set(FOLLY_LIBRARIES Folly::folly) ...@@ -30,6 +30,18 @@ set(FOLLY_LIBRARIES Folly::folly)
# Find folly's dependencies # Find folly's dependencies
find_dependency(fmt) find_dependency(fmt)
set(Boost_USE_STATIC_LIBS "@FOLLY_BOOST_LINK_STATIC@")
find_dependency(Boost 1.51.0 MODULE
COMPONENTS
context
filesystem
program_options
regex
system
thread
REQUIRED
)
if (NOT folly_FIND_QUIETLY) if (NOT folly_FIND_QUIETLY)
message(STATUS "Found folly: ${FOLLY_PREFIX_DIR}") message(STATUS "Found folly: ${FOLLY_PREFIX_DIR}")
endif() endif()
...@@ -16,9 +16,23 @@ include(CheckCXXSourceCompiles) ...@@ -16,9 +16,23 @@ include(CheckCXXSourceCompiles)
include(CheckIncludeFileCXX) include(CheckIncludeFileCXX)
include(CheckFunctionExists) include(CheckFunctionExists)
if(MSVC) set(
set(Boost_USE_STATIC_LIBS ON) #Force static lib in msvc BOOST_LINK_STATIC "auto"
endif(MSVC) CACHE STRING
"Whether to link against boost statically or dynamically."
)
if("${BOOST_LINK_STATIC}" STREQUAL "auto")
# Default to linking boost statically on Windows with MSVC
if(MSVC)
set(FOLLY_BOOST_LINK_STATIC ON)
else()
set(FOLLY_BOOST_LINK_STATIC OFF)
endif()
else()
set(FOLLY_BOOST_LINK_STATIC "${BOOST_LINK_STATIC}")
endif()
set(Boost_USE_STATIC_LIBS "${FOLLY_BOOST_LINK_STATIC}")
find_package(Boost 1.51.0 MODULE find_package(Boost 1.51.0 MODULE
COMPONENTS COMPONENTS
context context
......
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