Installation¶
This page describes installation of pog and how you can integrate it into your own project.
Getting source code¶
At first, you’ll need to obtain source code. If you want the latest released version, which should always be stable, you can download one from GitHub releases page.
If you want to get the latest development version or you are intersted in the development of the library, you can also get the source code using git
. To clone the repository run:
git clone https://github.com/metthal/pog.git
Requirements¶
In order to use pog, you will need:
You can install them from your distribution repositories. For Ubuntu based distributions use:
apt-get install libfmt-dev libre2-dev
For Red Hat based distributions use:
dnf install fmt-devel re2-devel
For macOS use:
brew install fmt re2
There is also an option to download re2
or fmt
while building the project. See Compilation for more information regarding this.
Compilation¶
pog itself is header-only library but it has dependencies which are not header-only. To compile it run:
cmake -DCMAKE_BUILD_TYPE=Release [OPTIONS] ..
cmake --build . --target install
Other options you can use:
POG_DOWNLOAD_RE2
-re2
will be downloaded during build-time. It will be compiled and installed aslibpog_re2.a
(orpog_re2.lib
on Windows) together with the library. (Default:OFF
)POG_DOWNLOAD_FMT
-fmt
will be downloaded during build-time. It will be compiled and installed aslibpog_fmt.a
(orpog_fmt.lib
on Windows) together with the library. (Default:OFF
)POG_TESTS
- Build tests located intests/
folder. (Default:OFF
)POG_EXAMPLES
- Build examples located inexamples/
folder. (Default:OFF
)POG_PIC
- Build position independent code. (Default:OFF
)
Attention
Option POG_PIC
does not have any effect if you do not neither of POG_DOWNLOAD_RE2
or POG_DOWNLOAD_FMT
. Libraries installed in your system are not guaranteed to be position independent.
Usage¶
pog
will be installed together with CMake configuration files which make integration into other CMake projects much more easier. If you use CMake in your project put following lines in your CMakeLists.txt
file and that should be it.
find_package(pog REQUIRED)
target_link_libraries(<YOUR_TARGET> pog::pog)
For projects which use other build systems, you can use pkgconfig files which are installed too. To obtain which compilation flags are needed run following commands in your shell or integrate it directly into your build system.
pkg-config --cflags pog
pkg-config --libs pog
To use pog from your source code, include file <pog/pog.h>
. Everything in pog is located inside pog
namespace. Example:
#include <pog/pog.h>
int main()
{
pog::Parser<Value> parser;
// your parser definition
}