From 9d06773e793e3517cb6bbdcb46c34cbf953ba5e5 Mon Sep 17 00:00:00 2001 From: Pranjal Raihan Date: Tue, 10 Sep 2024 15:50:43 -0700 Subject: [PATCH] Gate GFlag usage in ProgramOptions behind availability Reviewed By: yfeldblum Differential Revision: D62261372 fbshipit-source-id: 86bef57db3fe62332fccad926a6e0e19fd82273c --- folly/cli/NestedCommandLineApp.h | 2 ++ folly/cli/ProgramOptions.cpp | 2 ++ folly/cli/ProgramOptions.h | 2 ++ 3 files changed, 6 insertions(+) diff --git a/folly/cli/NestedCommandLineApp.h b/folly/cli/NestedCommandLineApp.h index d0cefa1776e..4187dedeee7 100644 --- a/folly/cli/NestedCommandLineApp.h +++ b/folly/cli/NestedCommandLineApp.h @@ -91,12 +91,14 @@ class NestedCommandLineApp { std::string programHelpFooter = std::string(), InitFunction initFunction = InitFunction()); +#if FOLLY_HAVE_LIBGFLAGS && __has_include() /** * Add GFlags to the list of supported options with the given style. */ void addGFlags(ProgramOptionsStyle style = ProgramOptionsStyle::GNU) { globalOptions_.add(getGFlags(style)); } +#endif /** * Return the global options object, so you can add options. diff --git a/folly/cli/ProgramOptions.cpp b/folly/cli/ProgramOptions.cpp index d053c1e3e3f..5c7b8b5ee25 100644 --- a/folly/cli/ProgramOptions.cpp +++ b/folly/cli/ProgramOptions.cpp @@ -34,6 +34,7 @@ namespace po = ::boost::program_options; namespace folly { +#if FOLLY_HAVE_LIBGFLAGS && __has_include() namespace { // Information about one GFlag. Handled via shared_ptr, as, in the case @@ -285,6 +286,7 @@ po::options_description getGFlags(ProgramOptionsStyle style) { return desc; } +#endif namespace { diff --git a/folly/cli/ProgramOptions.h b/folly/cli/ProgramOptions.h index 5a06c90033a..4cf5819bafe 100644 --- a/folly/cli/ProgramOptions.h +++ b/folly/cli/ProgramOptions.h @@ -23,6 +23,7 @@ namespace folly { +#if FOLLY_HAVE_LIBGFLAGS && __has_include() enum class ProgramOptionsStyle { GFLAGS, GNU, @@ -55,6 +56,7 @@ enum class ProgramOptionsStyle { // and "--flying_pigs=false" are not allowed, to prevent ambiguity. boost::program_options::options_description getGFlags( ProgramOptionsStyle style = ProgramOptionsStyle::GNU); +#endif // Helper when parsing nested command lines: //