Building from Source¶
Bazel¶
To use ng-log within a project which uses the Bazel build
tool, add the following lines to your MODULE.bazel
file:
MODULE.bazel
bazel_dep(name = "gflags", version = "2.2.2")
bazel_dep(name = "ng-log", version = "0.8.0-rc1")
You can then add @ng-log//:ng-log
to
the deps section of a cc_binary
or
cc_library
rule, and #include <ng-log/logging.h>
to
include it in your source code.
Using ng-log in a Bazel project
Migrating from google/glog¶
The Bazel target doesn't include the glog compatibility layer, so you'll need to adjust your code as follows:
- replace
<glog/logging.h>
with<ng-log/logging.h>
and similarly for other heads (flags, log_severity, stl_logging, etc) - replace the
google::
namespace withnglog::
- replace
InitGoogleLogging
withInitializeLogging
- replace
IsGoogleLoggingInitialized
withIsLoggingInitialized
- replace
ShutdownGoogleLogging
withShutdownLogging
CMake¶
ng-log can be compiled using CMake on a wide range of platforms. The typical workflow for building ng-log on a Unix-like system with GNU Make as build tool is as follows:
- Clone the repository and change into source directory.
- Run CMake to configure the build tree.
CMake provides different generators, and by default will pick the most
relevant one to your environment. If you need a specific version of Visual
Studio, use
cmake . -G <generator-name>
, and seecmake --help
for the available generators. Also see-T <toolset-name>
, which can be used to request the native x64 toolchain with-T host=x64
. - Afterwards, generated files can be used to compile the project.
- Test the build software (optional).
- Install the built files (optional).
Once successfully built, ng-log can be integrated into own projects.