ifdef::env-github[]
:important-caption: :heavy_exclamation_mark:
endif::[]

= Building for ZeroTier Support

If you want to include support for the experimental ZeroTier
transport (`zt://` URLs), you should follow these directions.

Staysail has created a package that builds a clean CMake project
that you can import.
Download this from https://github.com/staysail/libzerotiercore[GitHub].


IMPORTANT: ZeroTierOne is licensed under different terms than NNG.
You are responsible for reading those license terms, and ensuring that
your use conforms to them.

IMPORTANT: The ZeroTier transport, and these build instructions,
are experimental.
We expect both to change over time as ZeroTier and the NNG `zt://` transport
both mature.
As always, _caveat emptor_.

== Building libzerotiercore

Using "CMake", you can build libzerotiercore
using any normal CMake generator.
You should install it as well.
Normally it will install into `/usr/local` on
Linux and UNIX systems.

== Configuring NNG with ZT

You will need to enable ZeroTier within NNG using the CMake option `NNG_TRANSPORT_ZEROTIER=ON`.
If you have installed the libzerotiercore in
one of the default locations, then that should be all
that is needed.

If you have specified a different location, you will
need to inform CMake of this by setting the CMake
variable `-Dzerotier_DIR=<where you installed it>`

== Example

The following example would work on either Linux or macOS, and assumes
that we have checked out github source trees into `$HOME/work`.

[source, sh]
----
$ export NNGDIR=$HOME/work/nng
$ export ZTDIR=$HOME/work/libzerotiercore
$ git clone https://github.com/staysail/libzerotiercore $ZTDIR
$ cd $ZTDIR
$ mkdir build
$ cd build
$ cmake ..

   ... (lots of lines of output from cmake...)

$ make

   ... (lots of lines of output from make...)

$ make install
$ cd $NNGDIR
$ mkdir build
$ cd build
$ cmake -DNNG_TRANSPORT_ZEROTIER=ON ..

   ... (lots of lines of output from cmake...)

$ make

   ... (lots of lines of output from make...)

$ ./tests/zt

ok      ./tests/zt                                            22.837s
----
