Commit 16b3011a authored by Dave Rigby's avatar Dave Rigby Committed by Facebook Github Bot

Make GFlags actually optional (#1325)

Summary:
The absence of GFlags is already partially optional -
portability/GFlags.h defines a number of stub macros / clases if
FOLLY_HAVE_LIBGFLAGS is false.

However the top-level CMake rules don't correctly handle when GFlags
isn't present - they unconditionally add GFlags-related variables to
CMAKE_REQUIRED_xxx variables.

Additionally there are a couple of source files which should not be
compiled if GFlags isn't available.
Pull Request resolved: https://github.com/facebook/folly/pull/1325

Differential Revision: D20252030

Pulled By: yfeldblum

fbshipit-source-id: 7c3441e8b2850d68df125fb9c14b8417f4d08b55
parent d72b38e4
...@@ -38,10 +38,12 @@ list(APPEND FOLLY_INCLUDE_DIRECTORIES ${DOUBLE_CONVERSION_INCLUDE_DIR}) ...@@ -38,10 +38,12 @@ list(APPEND FOLLY_INCLUDE_DIRECTORIES ${DOUBLE_CONVERSION_INCLUDE_DIR})
find_package(Gflags MODULE) find_package(Gflags MODULE)
set(FOLLY_HAVE_LIBGFLAGS ${LIBGFLAGS_FOUND}) set(FOLLY_HAVE_LIBGFLAGS ${LIBGFLAGS_FOUND})
list(APPEND FOLLY_LINK_LIBRARIES ${LIBGFLAGS_LIBRARY}) if(LIBGFLAGS_FOUND)
list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LIBGFLAGS_INCLUDE_DIR}) list(APPEND FOLLY_LINK_LIBRARIES ${LIBGFLAGS_LIBRARY})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBGFLAGS_LIBRARY}) list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LIBGFLAGS_INCLUDE_DIR})
list(APPEND CMAKE_REQUIRED_INCLUDES ${LIBGFLAGS_INCLUDE_DIR}) list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBGFLAGS_LIBRARY})
list(APPEND CMAKE_REQUIRED_INCLUDES ${LIBGFLAGS_INCLUDE_DIR})
endif()
find_package(Glog MODULE) find_package(Glog MODULE)
set(FOLLY_HAVE_LIBGLOG ${GLOG_FOUND}) set(FOLLY_HAVE_LIBGLOG ${GLOG_FOUND})
......
...@@ -272,6 +272,16 @@ else() ...@@ -272,6 +272,16 @@ else()
${FOLLY_DIR}/experimental/crypto/LtHash.h ${FOLLY_DIR}/experimental/crypto/LtHash.h
) )
endif() endif()
if (NOT ${LIBGFLAGS_FOUND})
list(REMOVE_ITEM files
${FOLLY_DIR}/experimental/NestedCommandLineApp.cpp
${FOLLY_DIR}/experimental/ProgramOptions.cpp
)
list(REMOVE_ITEM hfiles
${FOLLY_DIR}/experimental/NestedCommandLineApp.h
${FOLLY_DIR}/experimental/ProgramOptions.h
)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows") if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
list(REMOVE_ITEM files list(REMOVE_ITEM files
${FOLLY_DIR}/Poly.cpp ${FOLLY_DIR}/Poly.cpp
......
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