aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-07-21 16:11:16 -0700
committerGarrett D'Amore <garrett@damore.org>2017-09-26 13:26:18 -0700
commit86a96e5bf1b207a8b1aa925e1d9f73ce834505b8 (patch)
tree53e7d9042cf8d72c723767cf31ef950594cbf736 /CMakeLists.txt
parent52118e4dcbc105d2b83c774e001926aceb978488 (diff)
downloadnng-86a96e5bf1b207a8b1aa925e1d9f73ce834505b8.tar.gz
nng-86a96e5bf1b207a8b1aa925e1d9f73ce834505b8.tar.bz2
nng-86a96e5bf1b207a8b1aa925e1d9f73ce834505b8.zip
ZeroTier transport implementation (work funded by Capitar IT Group BV)
The ZeroTier transport is experimental at this point, and not enabled by default. It does not work with Windows yet (the Windows platform needs UDP support first.) Configure with -DNNG_ENABLE_ZEROTIER=yes -DNNG_ZEROTIER_SOUCE=<path> The <path> must point to a dev branch of the ZeroTierOne source tree, checked out, and built with a libzerotiercore.a in the top directory, and a ZeroTierOne.h header located at include. The build will add -lc++ to the compile, as the ZeroTier core functionality is written in C++ and needs some runtime support (e.g. new, delete, etc.)
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt40
1 files changed, 39 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d95206c5..c2815ca3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,6 @@
#
+# Copyright 2017 Garrett D'Amore <garrett@damore.org>
+# Copyright 2017 Capitar IT Group BV <info@capitar.com>
# Copyright (c) 2012 Martin Sustrik All rights reserved.
# Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
# Copyright (c) 2015-2016 Jack R. Dunaway. All rights reserved.
@@ -91,7 +93,8 @@ option (NNG_TESTS "Build and run tests" ON)
option (NNG_TOOLS "Build extra tools" OFF)
option (NNG_ENABLE_NNGCAT "Enable building nngcat utility." ${NNG_TOOLS})
option (NNG_ENABLE_COVERAGE "Enable coverage reporting." OFF)
-
+option (NNG_ENABLE_ZEROTIER "Enable ZeroTier transport (requires libzerotiercore)." OFF)
+set (NNG_ZEROTIER_SOURCE "" CACHE PATH "Location of ZeroTier source tree.")
# Enable access to private APIs for our own use.
add_definitions (-DNNG_PRIVATE)
@@ -244,6 +247,39 @@ nng_check_sym (strlcat string.h NNG_HAVE_STRLCAT)
nng_check_sym (strlcpy string.h NNG_HAVE_STRLCPY)
nng_check_sym (strnlen string.h NNG_HAVE_STRNLEN)
+# Search for ZeroTier
+# We use the libzerotiercore.a library, which is unfortunately a C++ object
+# even though it exposes only public C symbols. It would be extremely
+# helpful if libzerotiercore didn't make us carry the whole C++ runtime
+# behind us. The user must specify the location of the ZeroTier source
+# tree (dev branch for now, and already compiled please) by setting the
+# NNG_ZEROTIER_SOURCE macro.
+# NB: This needs to be the zerotierone tree, not the libzt library.
+# This is because we don't access the API, but instead use the low
+# level zerotiercore functionality directly.
+# NB: As we wind up linking libzerotiercore.a into the application,
+# this means that your application will *also* need to either be licensed
+# under the GPLv3, or you will need to have a commercial license from
+# ZeroTier permitting its use elsewhere.
+if (NNG_ENABLE_ZEROTIER)
+ enable_language(CXX)
+ find_library(NNG_LIBZTCORE zerotiercore PATHS ${NNG_ZEROTIER_SOURCE})
+ if (NNG_LIBZTCORE)
+ set(CMAKE_REQUIRED_INCLUDES ${NNG_ZEROTIER_SOURCE}/include)
+# set(CMAKE_REQUIRED_LIBRARIES ${NNG_LIBZTCORE} c++)
+# set(NNG_REQUIRED_LIBRARIES ${NNG_REQUIRED_LIBRARIES} ${NNG_LIBZTCORE} c++)
+ message(STATUS "C++ ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}")
+ set(CMAKE_REQUIRED_LIBRARIES ${NNG_LIBZTCORE} ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES})
+ set(NNG_REQUIRED_LIBRARIES ${NNG_REQUIRED_LIBRARIES} ${NNG_LIBZTCORE} ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES})
+ set(NNG_REQUIRED_INCLUDES ${NNG_REQUIRED_INCLUDES} ${NNG_ZEROTIER_SOURCE}/include)
+ nng_check_sym(ZT_Node_join ZeroTierOne.h NNG_HAVE_ZEROTIER)
+ endif()
+ if (NOT NNG_HAVE_ZEROTIER)
+ message (FATAL_ERROR "Cannot find ZeroTier components")
+ endif()
+ message(STATUS "Found ZeroTier at ${NNG_LIBZTCORE}")
+endif()
+
add_subdirectory (src)
if (NNG_TESTS)
@@ -253,6 +289,7 @@ if (NNG_TESTS)
add_subdirectory (perf)
endif()
+
# Build the tools
if (NNG_ENABLE_NNGCAT)
@@ -270,6 +307,7 @@ if (NNG_ENABLE_DOC)
endif ()
endif ()
+
# Build the documenation
if (NNG_ENABLE_DOC)