docs: cleanup

This commit is contained in:
Sergiu Deitsch 2024-01-04 15:02:54 +01:00
parent cafba580ec
commit 39df0545e7
No known key found for this signature in database

View File

@ -39,20 +39,52 @@ particular `severity level <#severity-levels>`__>), e.g.,
} }
For a detailed overview of glog features and their usage, please refer The library can be installed using various package managers or compiled from
to the `user guide <#user-guide>`__. `source <#building-from-source>`__. For a detailed overview of glog features and
their usage, please refer to the `user guide <#user-guide>`__.
.. pull-quote::
[!IMPORTANT]
The above example requires further Bazel or CMake setup for
`use in own projects <#usage-in-projects>`__.
.. contents:: Table of Contents .. contents:: Table of Contents
Building from Source Usage in Projects
-------------------- ~~~~~~~~~~~~~~~~~
glog supports multiple build systems for compiling the project from Assuming that glog was previously `built glog using CMake <#cmake>`__ or
source: `Bazel <#bazel>`__, `CMake <#cmake>`__, `vcpkg <#vcpkg>`__, and `conan <#conan>`__. installed using a package manager, you can use the CMake command
:cmake:`find_package` to build against glog in your CMake project as follows:
.. code:: cmake
cmake_minimum_required (VERSION 3.16)
project (myproj VERSION 1.0)
find_package (glog 0.6.0 REQUIRED)
add_executable (myapp main.cpp)
target_link_libraries (myapp glog::glog)
Compile definitions and options will be added automatically to your
target as needed.
Alternatively, glog can be incorporated into using the CMake command
:cmake:`add_subdirectory` to include glog directly from a subdirectory of your
project by replacing the :cmake:`find_package` call from the previous snippet by
:cmake:`add_subdirectory`. The :cmake:`glog::glog` target is in this case an
:cmake:`ALIAS` library target for the ``glog`` library target.
Building from Source
~~~~~~~~~~~~~~~~~~~~
Bazel Bazel
~~~~~ ^^^^^
To use glog within a project which uses the To use glog within a project which uses the
`Bazel <https://bazel.build/>`__ build tool, add the following lines to `Bazel <https://bazel.build/>`__ build tool, add the following lines to
@ -77,8 +109,8 @@ your ``WORKSPACE`` file:
) )
You can then add :bazel:`@com_github_google_glog//:glog` to the deps section You can then add :bazel:`@com_github_google_glog//:glog` to the deps section
of a :bazel:`cc_binary` or :bazel:`cc_library` rule, and :code:`#include of a :bazel:`cc_binary` or :bazel:`cc_library` rule, and :code:`#include <glog/logging.h>`
<glog/logging.h>` to include it in your source code. Heres a simple example: to include it in your source code. Heres a simple example:
.. code:: bazel .. code:: bazel
@ -89,25 +121,13 @@ of a :bazel:`cc_binary` or :bazel:`cc_library` rule, and :code:`#include
) )
CMake CMake
~~~~~ ^^^^^
glog also supports CMake that can be used to build the project on a wide glog can be compiled using `CMake <http://www.cmake.org>`__ on a wide range of
range of platforms. If you dont have CMake installed already, you can platforms. The typical workflow for building glog on a Unix-like system with
download it for from CMakes `official GNU Make as build tool is as follows:
website <http://www.cmake.org>`__.
CMake works by generating native makefiles or build projects that can be 1. Clone the repository and change into source directory.
used in the compiler environment of your choice. You can either build
glog with CMake as a standalone project or it can be incorporated into
an existing CMake build for another project.
Building glog with CMake
^^^^^^^^^^^^^^^^^^^^^^^^
When building glog as a standalone project, on Unix-like systems with
GNU Make as build tool, the typical workflow is:
1. Get the source code and change to it. e.g., cloning with git:
.. code:: bash .. code:: bash
@ -144,36 +164,26 @@ GNU Make as build tool, the typical workflow is:
cmake --build build --target install cmake --build build --target install
Consuming glog in a CMake Project
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If you have glog installed in your system, you can use the CMake command Once successfully built, glog can be
:cmake:`find_package` to build against glog in your CMake Project as follows: `integrated into own projects <#usage-in-projects>`__.
.. code:: cmake
cmake_minimum_required (VERSION 3.16) conan
project (myproj VERSION 1.0) ~~~~~
find_package (glog 0.6.0 REQUIRED) You can download and install glog using the `conan
<https://conan.io>`__ package manager:
add_executable (myapp main.cpp) .. code:: bash
target_link_libraries (myapp glog::glog)
Compile definitions and options will be added automatically to your pip install conan
target as needed. conan install -r conancenter glog/<glog-version>@
Incorporating glog into a CMake Project The glog recipe in conan center is kept up to date by conan center index community
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ contributors. If the version is out of date, please create an
issue or pull request on the `conan-center-index
You can also use the CMake command :cmake:`add_subdirectory` to include glog <https://github.com/conan-io/conan-center-index>`__ repository.
directly from a subdirectory of your project by replacing the
:cmake:`find_package` call from the previous example by
:cmake:`add_subdirectory`. The :cmake:`glog::glog` target is in this case an
:cmake:`ALIAS` library target for the ``glog`` library target.
Again, compile definitions and options will be added automatically to
your target as needed.
vcpkg vcpkg
~~~~~ ~~~~~
@ -193,22 +203,6 @@ The glog port in vcpkg is kept up to date by Microsoft team members and
community contributors. If the version is out of date, please create an community contributors. If the version is out of date, please create an
issue or pull request on the vcpkg repository. issue or pull request on the vcpkg repository.
conan
~~~~~
You can download and install glog using the `conan
<https://conan.io>`__ package manager:
.. code:: bash
pip install conan
conan install -r conancenter glog/<glog-version>@
The glog recipe in conan center is kept up to date by conan center index community
contributors. If the version is out of date, please create an
issue or pull request on the `conan-center-index
<https://github.com/conan-io/conan-center-index>`__ repository.
User Guide User Guide
---------- ----------