diff --git a/CMakeLists.txt b/CMakeLists.txt index b57c853..d414827 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,6 +149,13 @@ file (TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX) # ---------------------------------------------------------------------------- # options +OPTION(GFLAGS_STRIP_INTERNAL_FLAG_HELP "Hide help from GFLAGS modules" OFF) +IF(GFLAGS_STRIP_INTERNAL_FLAG_HELP) + SET(STRIP_INTERNAL_FLAG_HELP 1) +ELSE(GFLAGS_STRIP_INTERNAL_FLAG_HELP) + SET(STRIP_INTERNAL_FLAG_HELP 0) +ENDIF(GFLAGS_STRIP_INTERNAL_FLAG_HELP) + # maintain binary backwards compatibility with gflags library version <= 2.0, # but at the same time enable the use of the preferred new "gflags" namespace gflags_define (STRING NAMESPACE "Name(s) of library namespace (separate multiple options by semicolon)" "google;${PACKAGE_NAME}" "${PACKAGE_NAME}") diff --git a/src/defines.h.in b/src/defines.h.in index dfb214e..d638a08 100644 --- a/src/defines.h.in +++ b/src/defines.h.in @@ -44,5 +44,6 @@ // Define if your pthread library defines the type pthread_rwlock_t #cmakedefine HAVE_RWLOCK +#cmakedefine STRIP_INTERNAL_FLAG_HELP #endif // GFLAGS_DEFINES_H_ diff --git a/src/gflags.cc b/src/gflags.cc index 04d0f9b..ddfaf5c 100644 --- a/src/gflags.cc +++ b/src/gflags.cc @@ -88,6 +88,11 @@ // are, similarly, mostly hooks into the functionality described above. #include "config.h" + +#ifdef STRIP_INTERNAL_FLAG_HELP +# define STRIP_FLAG_HELP 1 +#endif + #include "gflags/gflags.h" #include diff --git a/src/gflags_completions.cc b/src/gflags_completions.cc index 4f7bb78..5111176 100644 --- a/src/gflags_completions.cc +++ b/src/gflags_completions.cc @@ -56,6 +56,11 @@ #include #include "config.h" + +#ifdef STRIP_INTERNAL_FLAG_HELP +# define STRIP_FLAG_HELP 1 +#endif + #include "gflags/gflags.h" #include "gflags/gflags_completions.h" #include "util.h" diff --git a/src/gflags_reporting.cc b/src/gflags_reporting.cc index db05303..93f4e63 100644 --- a/src/gflags_reporting.cc +++ b/src/gflags_reporting.cc @@ -56,6 +56,11 @@ #include #include "config.h" + +#ifdef STRIP_INTERNAL_FLAG_HELP +# define STRIP_FLAG_HELP 1 +#endif + #include "gflags/gflags.h" #include "gflags/gflags_completions.h" #include "util.h" @@ -118,7 +123,7 @@ static string PrintStringFlagsWithQuotes(const CommandLineFlagInfo& flag, // Goes to some trouble to make pretty line breaks. string DescribeOneFlag(const CommandLineFlagInfo& flag) { string main_part; - SStringPrintf(&main_part, " -%s (%s)", + SStringPrintf(&main_part, " --%s (%s)", flag.name.c_str(), flag.description.c_str()); const char* c_string = main_part.c_str(); @@ -284,7 +289,9 @@ static void ShowUsageWithFlagsMatching(const char *argv0, fprintf(stdout, "\n\n"); // put blank lines between directories first_directory = false; } +#ifndef STRIP_INTERNAL_FLAG_HELP fprintf(stdout, "\n Flags from %s:\n", flag->filename.c_str()); +#endif // STRIP_INTERNAL_FLAG_HELP last_filename = flag->filename; } // Now print this flag @@ -346,9 +353,6 @@ static void ShowVersion() { } else { fprintf(stdout, "%s\n", ProgramInvocationShortName()); } -# if !defined(NDEBUG) - fprintf(stdout, "Debug build (NDEBUG not #defined)\n"); -# endif } static void AppendPrognameStrings(vector* substrings,