1Installing a binary distribution package 2======================================== 3 4No official binary distribution packages are provided by the gflags developers. 5There may, however, be binary packages available for your OS. Please consult 6also the package repositories of your Linux distribution. 7 8For example on Debian/Ubuntu Linux, gflags can be installed using the 9following command: 10 11 sudo apt-get install libgflags-dev 12 13 14Compiling the source code with CMake 15========================= 16 17The build system of gflags is since version 2.1 based on [CMake](http://cmake.org). 18The common steps to build, test, and install software are therefore: 19 201. Extract source files. 212. Create build directory and change to it. 223. Run CMake to configure the build tree. 234. Build the software using selected build tool. 245. Test the built software. 256. Install the built files. 26 27On Unix-like systems with GNU Make as build tool, these build steps can be 28summarized by the following sequence of commands executed in a shell, 29where ```$package``` and ```$version``` are shell variables which represent 30the name of this package and the obtained version of the software. 31 32 $ tar xzf gflags-$version-source.tar.gz 33 $ cd gflags-$version 34 $ mkdir build && cd build 35 $ ccmake .. 36 37 - Press 'c' to configure the build system and 'e' to ignore warnings. 38 - Set CMAKE_INSTALL_PREFIX and other CMake variables and options. 39 - Continue pressing 'c' until the option 'g' is available. 40 - Then press 'g' to generate the configuration files for GNU Make. 41 42 $ make 43 $ make test (optional) 44 $ make install (optional) 45 46In the following, only gflags-specific CMake settings available to 47configure the build and installation are documented. Note that most of these 48variables are for advanced users and binary package maintainers only. 49They usually do not have to be modified. 50 51 52CMake Option | Description 53--------------------------- | ------------------------------------------------------- 54CMAKE_INSTALL_PREFIX | Installation directory, e.g., "/usr/local" on Unix and "C:\Program Files\gflags" on Windows. 55BUILD_SHARED_LIBS | Request build of dynamic link libraries. 56BUILD_STATIC_LIBS | Request build of static link libraries. Implied if BUILD_SHARED_LIBS is OFF. 57BUILD_PACKAGING | Enable binary package generation using CPack. 58BUILD_TESTING | Build tests for execution by CTest. 59BUILD_NC_TESTS | Request inclusion of negative compilation tests (requires Python). 60BUILD_CONFIG_TESTS | Request inclusion of package configuration tests (requires Python). 61BUILD_gflags_LIBS | Request build of multi-threaded gflags libraries (if threading library found). 62BUILD_gflags_nothreads_LIBS | Request build of single-threaded gflags libraries. 63GFLAGS_NAMESPACE | Name of the C++ namespace to be used by the gflags library. Note that the public source header files are installed in a subdirectory named after this namespace. To maintain backwards compatibility with the Google Commandline Flags, set this variable to "google". The default is "gflags". 64GFLAGS_INTTYPES_FORMAT | String identifying format of built-in integer types. 65GFLAGS_INCLUDE_DIR | Name of headers installation directory relative to CMAKE_INSTALL_PREFIX. 66LIBRARY_INSTALL_DIR | Name of library installation directory relative to CMAKE_INSTALL_PREFIX. 67INSTALL_HEADERS | Request installation of public header files. 68 69Using gflags with [Bazel](http://bazel.io) 70========================= 71 72To use gflags in a Bazel project, map it in as an external dependency by editing 73your WORKSPACE file: 74 75 git_repository( 76 name = "com_github_gflags_gflags", 77 commit = "<INSERT COMMIT SHA HERE>", 78 remote = "https://github.com/gflags/gflags.git", 79 ) 80 81You can then add `@com_github_gflags_gflags//:gflags` to the `deps` section of a 82`cc_binary` or `cc_library` rule, and `#include <gflags/gflags.h>` to include it 83in your source code. 84