Skip to content

Instantly share code, notes, and snippets.

@neur1n
Last active September 5, 2022 06:53
Show Gist options
  • Select an option

  • Save neur1n/1840bb836bd9b99ba37eb91a8ee63dc7 to your computer and use it in GitHub Desktop.

Select an option

Save neur1n/1840bb836bd9b99ba37eb91a8ee63dc7 to your computer and use it in GitHub Desktop.
embed nng from source
OPTION(NNG_TESTS "Build and run tests." OFF)
OPTION(NNG_TOOLS "Build extra tools." OFF)
OPTION(NNG_ELIDE_DEPRECATED "Elide deprecated functionality." OFF)
OPTION(NNG_ENABLE_COVERAGE "Enable coverage reporting." OFF)
OPTION(NNG_ENABLE_NNGCAT "Enable building nngcat utility." OFF)
OPTION(NNG_ENABLE_STATS "Enable statistics." OFF)
# Protocols.
OPTION(NNG_PROTO_REQ0 "Enable REQv0 protocol." ON)
OPTION(NNG_PROTO_REP0 "Enable REPv0 protocol." ON)
OPTION(NNG_PROTO_BUS0 "Enable BUSv0 protocol." OFF)
OPTION(NNG_PROTO_PAIR0 "Enable PAIRv0 protocol." OFF)
OPTION(NNG_PROTO_PAIR1 "Enable PAIRv1 protocol." OFF)
OPTION(NNG_PROTO_PUSH0 "Enable PUSHv0 protocol." OFF)
OPTION(NNG_PROTO_PULL0 "Enable PULLv0 protocol." OFF)
OPTION(NNG_PROTO_PUB0 "Enable PUBv0 protocol." OFF)
OPTION(NNG_PROTO_SUB0 "Enable SUBv0 protocol." OFF)
OPTION(NNG_PROTO_RESPONDENT0 "Enable RESPONDENTv0 protocol." OFF)
OPTION(NNG_PROTO_SURVEYOR0 "Enable SURVEYORv0 protocol." OFF)
OPTION(NNG_ENABLE_HTTP "Enable HTTP API." OFF)
OPTION(NNG_ENABLE_TLS "Enable TLS support." OFF)
# Transport Options.
OPTION(NNG_TRANSPORT_TCP "Enable TCP transport." ON)
OPTION(NNG_TRANSPORT_INPROC "Enable inproc transport." OFF)
OPTION(NNG_TRANSPORT_IPC "Enable IPC transport." OFF)
OPTION(NNG_TRANSPORT_TLS "Enable TLS transport." OFF)
OPTION(NNG_TRANSPORT_WS "Enable WebSocket transport." OFF)
OPTION(NNG_TRANSPORT_ZEROTIER "Enable ZeroTier transport (requires libzerotiercore)." OFF)
ADD_COMPILE_DEFINITIONS(NNG_TRANSPORT_TCP)
SET(NNG_DIR ${PROJECT_SOURCE_DIR}/thirdparty/nng-1.5.2)
SET(NNG_CORE_SRC
${NNG_DIR}/src/core/defs.h
${NNG_DIR}/src/core/platform.h
${NNG_DIR}/src/core/sockimpl.h
${NNG_DIR}/src/core/aio.h
${NNG_DIR}/src/core/device.h
${NNG_DIR}/src/core/dialer.h
${NNG_DIR}/src/core/file.h
${NNG_DIR}/src/core/idhash.h
${NNG_DIR}/src/core/init.h
${NNG_DIR}/src/core/list.h
${NNG_DIR}/src/core/listener.h
${NNG_DIR}/src/core/lmq.h
${NNG_DIR}/src/core/message.h
${NNG_DIR}/src/core/msgqueue.h
${NNG_DIR}/src/core/options.h
${NNG_DIR}/src/core/panic.h
${NNG_DIR}/src/core/pipe.h
${NNG_DIR}/src/core/pollable.h
${NNG_DIR}/src/core/protocol.h
${NNG_DIR}/src/core/reap.h
${NNG_DIR}/src/core/socket.h
${NNG_DIR}/src/core/stats.h
${NNG_DIR}/src/core/stream.h
${NNG_DIR}/src/core/strs.h
${NNG_DIR}/src/core/taskq.h
${NNG_DIR}/src/core/tcp.h
${NNG_DIR}/src/core/thread.h
${NNG_DIR}/src/core/timer.h
${NNG_DIR}/src/core/url.h
${NNG_DIR}/src/core/aio.c
${NNG_DIR}/src/core/device.c
${NNG_DIR}/src/core/dialer.c
${NNG_DIR}/src/core/file.c
${NNG_DIR}/src/core/idhash.c
${NNG_DIR}/src/core/init.c
${NNG_DIR}/src/core/list.c
${NNG_DIR}/src/core/listener.c
${NNG_DIR}/src/core/lmq.c
${NNG_DIR}/src/core/message.c
${NNG_DIR}/src/core/msgqueue.c
${NNG_DIR}/src/core/options.c
${NNG_DIR}/src/core/panic.c
${NNG_DIR}/src/core/pipe.c
${NNG_DIR}/src/core/pollable.c
${NNG_DIR}/src/core/protocol.c
${NNG_DIR}/src/core/reap.c
${NNG_DIR}/src/core/socket.c
${NNG_DIR}/src/core/stats.c
${NNG_DIR}/src/core/stream.c
${NNG_DIR}/src/core/strs.c
${NNG_DIR}/src/core/taskq.c
${NNG_DIR}/src/core/tcp.c
${NNG_DIR}/src/core/thread.c
${NNG_DIR}/src/core/timer.c
${NNG_DIR}/src/core/url.c
)
IF(CMAKE_HOST_UNIX)
ADD_COMPILE_DEFINITIONS(NNG_PLATFORM_POSIX)
ADD_COMPILE_DEFINITIONS(NNG_PLATFORM_LINUX)
ADD_COMPILE_DEFINITIONS(NNG_USE_EVENTFD)
ADD_COMPILE_DEFINITIONS(NNG_HAVE_ABSTRACT_SOCKETS)
SET(NNG_PLATFORM_POSIX ON)
SET(NNG_PLATFORM_SRC
${NNG_DIR}/src/platform/posix/posix_aio.h
${NNG_DIR}/src/platform/posix/posix_config.h
${NNG_DIR}/src/platform/posix/posix_impl.h
${NNG_DIR}/src/platform/posix/posix_ipc.h
${NNG_DIR}/src/platform/posix/posix_pullq.h
${NNG_DIR}/src/platform/posix/posix_tcp.h
${NNG_DIR}/src/platform/posix/posix_alloc.c
${NNG_DIR}/src/platform/posix/posix_atomic.c
${NNG_DIR}/src/platform/posix/posix_clock.c
${NNG_DIR}/src/platform/posix/posix_debug.c
${NNG_DIR}/src/platform/posix/posix_file.c
${NNG_DIR}/src/platform/posix/posix_ipcconn.c
${NNG_DIR}/src/platform/posix/posix_ipcdial.c
${NNG_DIR}/src/platform/posix/posix_ipclisten.c
${NNG_DIR}/src/platform/posix/posix_pipe.c
${NNG_DIR}/src/platform/posix/posix_pollq_epoll.c
${NNG_DIR}/src/platform/posix/posix_pollq_kqueue.c
${NNG_DIR}/src/platform/posix/posix_pollq_poll.c
${NNG_DIR}/src/platform/posix/posix_pollq_port.c
${NNG_DIR}/src/platform/posix/posix_rand_arc4random.c
${NNG_DIR}/src/platform/posix/posix_rand_getrandom.c
${NNG_DIR}/src/platform/posix/posix_rand_urandom.c
${NNG_DIR}/src/platform/posix/posix_resolv_gai.c
${NNG_DIR}/src/platform/posix/posix_sockaddr.c
${NNG_DIR}/src/platform/posix/posix_tcpconn.c
${NNG_DIR}/src/platform/posix/posix_tcpdial.c
${NNG_DIR}/src/platform/posix/posix_tcplisten.c
${NNG_DIR}/src/platform/posix/posix_thread.c
${NNG_DIR}/src/platform/posix/posix_udp.c
)
ELSE()
ADD_COMPILE_DEFINITIONS(NNG_PLATFORM_WINDOWS)
ADD_COMPILE_DEFINITIONS(_CRT_RAND_S)
SET(NNG_PLATFORM_WINDOWS ON)
SET(NNG_PLATFORM_SRC
${NNG_DIR}/src/platform/windows/win_impl.h
${NNG_DIR}/src/platform/windows/win_ipc.h
${NNG_DIR}/src/platform/windows/win_tcp.h
${NNG_DIR}/src/platform/windows/win_clock.c
${NNG_DIR}/src/platform/windows/win_debug.c
${NNG_DIR}/src/platform/windows/win_file.c
${NNG_DIR}/src/platform/windows/win_io.c
${NNG_DIR}/src/platform/windows/win_ipcconn.c
${NNG_DIR}/src/platform/windows/win_ipcdial.c
${NNG_DIR}/src/platform/windows/win_ipclisten.c
${NNG_DIR}/src/platform/windows/win_pipe.c
${NNG_DIR}/src/platform/windows/win_rand.c
${NNG_DIR}/src/platform/windows/win_resolv.c
${NNG_DIR}/src/platform/windows/win_sockaddr.c
${NNG_DIR}/src/platform/windows/win_tcp.c
${NNG_DIR}/src/platform/windows/win_tcpconn.c
${NNG_DIR}/src/platform/windows/win_tcpdial.c
${NNG_DIR}/src/platform/windows/win_tcplisten.c
${NNG_DIR}/src/platform/windows/win_thread.c
${NNG_DIR}/src/platform/windows/win_udp.c
)
ENDIF()
SET(NNG_SP_SRC
# ${NNG_DIR}/src/sp/protocol/bus0/bus.c
# ${NNG_DIR}/src/sp/protocol/pair0/pair.c
# ${NNG_DIR}/src/sp/protocol/pair1/pair.c
# ${NNG_DIR}/src/sp/protocol/pair1/pair1_poly.c
# ${NNG_DIR}/src/sp/protocol/pipeline0/pull.c
# ${NNG_DIR}/src/sp/protocol/pipeline0/push.c
# ${NNG_DIR}/src/sp/protocol/pubsub0/pub.c
# ${NNG_DIR}/src/sp/protocol/pubsub0/sub.c
# ${NNG_DIR}/src/sp/protocol/pubsub0/xsub.c
${NNG_DIR}/src/sp/protocol/reqrep0/rep.c
${NNG_DIR}/src/sp/protocol/reqrep0/req.c
${NNG_DIR}/src/sp/protocol/reqrep0/xrep.c
${NNG_DIR}/src/sp/protocol/reqrep0/xreq.c
# ${NNG_DIR}/src/sp/protocol/survey0/respond.c
# ${NNG_DIR}/src/sp/protocol/survey0/survey.c
# ${NNG_DIR}/src/sp/protocol/survey0/xrespond.c
# ${NNG_DIR}/src/sp/protocol/survey0/xsurvey.c
${NNG_DIR}/src/sp/transport.c
# ${NNG_DIR}/src/sp/transport/inproc/inproc.c
# ${NNG_DIR}/src/sp/transport/ipc/ipc.c
${NNG_DIR}/src/sp/transport/tcp/tcp.c
${NNG_DIR}/src/sp/transport/tls/tls.c
${NNG_DIR}/src/sp/transport/ws/websocket.c
)
SET(NNG_SUPPLEMENTAL_SRC
# ${NNG_DIR}/src/supplemental/base64/base64.h
# ${NNG_DIR}/src/supplemental/base64/base64.c
# ${NNG_DIR}/src/supplemental/http/http_api.h
# ${NNG_DIR}/src/supplemental/http/http_chunk.c
# ${NNG_DIR}/src/supplemental/http/http_client.c
# ${NNG_DIR}/src/supplemental/http/http_conn.c
# ${NNG_DIR}/src/supplemental/http/http_msg.c
# ${NNG_DIR}/src/supplemental/http/http_public.c
# ${NNG_DIR}/src/supplemental/http/http_schemes.c
# ${NNG_DIR}/src/supplemental/http/http_server.c
# ${NNG_DIR}/src/supplemental/sha1/sha1.h
# ${NNG_DIR}/src/supplemental/sha1/sha1.c
${NNG_DIR}/src/supplemental/tls/tls_api.h
${NNG_DIR}/src/supplemental/tls/tls_common.c
${NNG_DIR}/src/supplemental/util/options.c
${NNG_DIR}/src/supplemental/util/platform.c
${NNG_DIR}/src/supplemental/websocket/stub.c
)
SET(NNG_SRC
${NNG_DIR}/src/nng.c
${NNG_CORE_SRC}
${NNG_PLATFORM_SRC}
${NNG_SP_SRC}
${NNG_SUPPLEMENTAL_SRC}
)
SET(NNG_INCLUDE_DIRS ${NNG_DIR}/include ${NNG_DIR}/src)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment