xref: /aosp_15_r20/external/gflags/INSTALL.md (revision 08ab5237c114d5c0eac1090c56f941d3f639d7d3)
1*08ab5237SOystein EftevaagInstalling a binary distribution package
2*08ab5237SOystein Eftevaag========================================
3*08ab5237SOystein Eftevaag
4*08ab5237SOystein EftevaagNo official binary distribution packages are provided by the gflags developers.
5*08ab5237SOystein EftevaagThere may, however, be binary packages available for your OS. Please consult
6*08ab5237SOystein Eftevaagalso the package repositories of your Linux distribution.
7*08ab5237SOystein Eftevaag
8*08ab5237SOystein EftevaagFor example on Debian/Ubuntu Linux, gflags can be installed using the
9*08ab5237SOystein Eftevaagfollowing command:
10*08ab5237SOystein Eftevaag
11*08ab5237SOystein Eftevaag    sudo apt-get install libgflags-dev
12*08ab5237SOystein Eftevaag
13*08ab5237SOystein Eftevaag
14*08ab5237SOystein EftevaagCompiling the source code with CMake
15*08ab5237SOystein Eftevaag=========================
16*08ab5237SOystein Eftevaag
17*08ab5237SOystein EftevaagThe build system of gflags is since version 2.1 based on [CMake](http://cmake.org).
18*08ab5237SOystein EftevaagThe common steps to build, test, and install software are therefore:
19*08ab5237SOystein Eftevaag
20*08ab5237SOystein Eftevaag1. Extract source files.
21*08ab5237SOystein Eftevaag2. Create build directory and change to it.
22*08ab5237SOystein Eftevaag3. Run CMake to configure the build tree.
23*08ab5237SOystein Eftevaag4. Build the software using selected build tool.
24*08ab5237SOystein Eftevaag5. Test the built software.
25*08ab5237SOystein Eftevaag6. Install the built files.
26*08ab5237SOystein Eftevaag
27*08ab5237SOystein EftevaagOn Unix-like systems with GNU Make as build tool, these build steps can be
28*08ab5237SOystein Eftevaagsummarized by the following sequence of commands executed in a shell,
29*08ab5237SOystein Eftevaagwhere ```$package``` and ```$version``` are shell variables which represent
30*08ab5237SOystein Eftevaagthe name of this package and the obtained version of the software.
31*08ab5237SOystein Eftevaag
32*08ab5237SOystein Eftevaag    $ tar xzf gflags-$version-source.tar.gz
33*08ab5237SOystein Eftevaag    $ cd gflags-$version
34*08ab5237SOystein Eftevaag    $ mkdir build && cd build
35*08ab5237SOystein Eftevaag    $ ccmake ..
36*08ab5237SOystein Eftevaag
37*08ab5237SOystein Eftevaag      - Press 'c' to configure the build system and 'e' to ignore warnings.
38*08ab5237SOystein Eftevaag      - Set CMAKE_INSTALL_PREFIX and other CMake variables and options.
39*08ab5237SOystein Eftevaag      - Continue pressing 'c' until the option 'g' is available.
40*08ab5237SOystein Eftevaag      - Then press 'g' to generate the configuration files for GNU Make.
41*08ab5237SOystein Eftevaag
42*08ab5237SOystein Eftevaag    $ make
43*08ab5237SOystein Eftevaag    $ make test    (optional)
44*08ab5237SOystein Eftevaag    $ make install (optional)
45*08ab5237SOystein Eftevaag
46*08ab5237SOystein EftevaagIn the following, only gflags-specific CMake settings available to
47*08ab5237SOystein Eftevaagconfigure the build and installation are documented. Note that most of these
48*08ab5237SOystein Eftevaagvariables are for advanced users and binary package maintainers only.
49*08ab5237SOystein EftevaagThey usually do not have to be modified.
50*08ab5237SOystein Eftevaag
51*08ab5237SOystein Eftevaag
52*08ab5237SOystein EftevaagCMake Option                | Description
53*08ab5237SOystein Eftevaag--------------------------- | -------------------------------------------------------
54*08ab5237SOystein EftevaagCMAKE_INSTALL_PREFIX        | Installation directory, e.g., "/usr/local" on Unix and "C:\Program Files\gflags" on Windows.
55*08ab5237SOystein EftevaagBUILD_SHARED_LIBS           | Request build of dynamic link libraries.
56*08ab5237SOystein EftevaagBUILD_STATIC_LIBS           | Request build of static link libraries. Implied if BUILD_SHARED_LIBS is OFF.
57*08ab5237SOystein EftevaagBUILD_PACKAGING             | Enable binary package generation using CPack.
58*08ab5237SOystein EftevaagBUILD_TESTING               | Build tests for execution by CTest.
59*08ab5237SOystein EftevaagBUILD_NC_TESTS              | Request inclusion of negative compilation tests (requires Python).
60*08ab5237SOystein EftevaagBUILD_CONFIG_TESTS          | Request inclusion of package configuration tests (requires Python).
61*08ab5237SOystein EftevaagBUILD_gflags_LIBS           | Request build of multi-threaded gflags libraries (if threading library found).
62*08ab5237SOystein EftevaagBUILD_gflags_nothreads_LIBS | Request build of single-threaded gflags libraries.
63*08ab5237SOystein EftevaagGFLAGS_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".
64*08ab5237SOystein EftevaagGFLAGS_INTTYPES_FORMAT      | String identifying format of built-in integer types.
65*08ab5237SOystein EftevaagGFLAGS_INCLUDE_DIR          | Name of headers installation directory relative to CMAKE_INSTALL_PREFIX.
66*08ab5237SOystein EftevaagLIBRARY_INSTALL_DIR         | Name of library installation directory relative to CMAKE_INSTALL_PREFIX.
67*08ab5237SOystein EftevaagINSTALL_HEADERS             | Request installation of public header files.
68*08ab5237SOystein Eftevaag
69*08ab5237SOystein EftevaagUsing gflags with [Bazel](http://bazel.io)
70*08ab5237SOystein Eftevaag=========================
71*08ab5237SOystein Eftevaag
72*08ab5237SOystein EftevaagTo use gflags in a Bazel project, map it in as an external dependency by editing
73*08ab5237SOystein Eftevaagyour WORKSPACE file:
74*08ab5237SOystein Eftevaag
75*08ab5237SOystein Eftevaag    git_repository(
76*08ab5237SOystein Eftevaag        name = "com_github_gflags_gflags",
77*08ab5237SOystein Eftevaag        commit = "<INSERT COMMIT SHA HERE>",
78*08ab5237SOystein Eftevaag        remote = "https://github.com/gflags/gflags.git",
79*08ab5237SOystein Eftevaag    )
80*08ab5237SOystein Eftevaag
81*08ab5237SOystein EftevaagYou can then add `@com_github_gflags_gflags//:gflags` to the `deps` section of a
82*08ab5237SOystein Eftevaag`cc_binary` or `cc_library` rule, and `#include <gflags/gflags.h>` to include it
83*08ab5237SOystein Eftevaagin your source code.
84