Commit 5357c117 authored by Rob Sherwood's avatar Rob Sherwood Committed by Facebook Github Bot

Tweak the OSS gflags dependency inference logic

Summary:
The current logic for "which gflags library should we use" checks for
the first library (e.g., libgflags vs. libgflags-shared) listed as a TARGET.
Unfortunately, on some number of systems, the gflags-config.cmake (read:
the file that is supposed to tell you how to use gflags with cmake) actually
defines (but doesn't use!) libraries that don't exist (!) so this logic breaks.

Instead, use the system defined gflags_LIBRARIES variable which explicitly
tells us which library to use.

Reviewed By: yfeldblum, simpkins

Differential Revision: D14512966

fbshipit-source-id: add4ecf6bade502b2d12aad2bdfcf0476eeba465
parent 65fa2c4b
......@@ -25,14 +25,13 @@ set(FOLLY_HAVE_LIBGFLAGS OFF)
find_package(gflags CONFIG QUIET)
if (gflags_FOUND)
message(STATUS "Found gflags from package config")
message(STATUS "gflags_CONFIG=${gflags_CONFIG}")
set(FOLLY_HAVE_LIBGFLAGS ON)
if (TARGET gflags-shared)
list(APPEND FOLLY_SHINY_DEPENDENCIES gflags-shared)
elseif (TARGET gflags)
list(APPEND FOLLY_SHINY_DEPENDENCIES gflags)
else()
message(FATAL_ERROR "Unable to determine the target name for the GFlags package.")
endif()
# ${GFLAGS_TARGET} contains the desired gflags target to depend on.
# The ${gflags_LIBRARIES} variable is an alias to it, and is more compatible
# with older versions of gflags.
message(STATUS "Using gflags libraries ${gflags_LIBRARIES}")
list(APPEND FOLLY_SHINY_DEPENDENCIES ${gflags_LIBRARIES})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${GFLAGS_LIBRARIES})
list(APPEND CMAKE_REQUIRED_INCLUDES ${GFLAGS_INCLUDE_DIR})
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