diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-11-05 13:54:40 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-11-05 16:20:23 -0800 |
| commit | 77984b14a65c0a7387c97f3d36f947dd17358744 (patch) | |
| tree | d95ad88933c9fe8853cbc74fe8dc1492d60ad443 /src | |
| parent | db92342b43d429b8b07244cc003a8589a1b1c542 (diff) | |
| download | nng-77984b14a65c0a7387c97f3d36f947dd17358744.tar.gz nng-77984b14a65c0a7387c97f3d36f947dd17358744.tar.bz2 nng-77984b14a65c0a7387c97f3d36f947dd17358744.zip | |
fixes #577 target library dependencies should be public
This is a significant refactor of the library configuration.
We use the modern package configuration helper, with a template
script that also does the find_package dance for any of our
dependencies.
We also have restructured the code so that most protocols and
transports have their configuration isolated to their own CMakeLists
file, reducing the size of the global CMakeLists file.
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 96 | ||||
| -rw-r--r-- | src/compat/nanomsg/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/protocol/bus0/CMakeLists.txt | 14 | ||||
| -rw-r--r-- | src/protocol/pair0/CMakeLists.txt | 14 | ||||
| -rw-r--r-- | src/protocol/pair1/CMakeLists.txt | 14 | ||||
| -rw-r--r-- | src/protocol/pipeline0/CMakeLists.txt | 26 | ||||
| -rw-r--r-- | src/protocol/pubsub0/CMakeLists.txt | 24 | ||||
| -rw-r--r-- | src/protocol/reqrep0/CMakeLists.txt | 30 | ||||
| -rw-r--r-- | src/protocol/survey0/CMakeLists.txt | 30 | ||||
| -rw-r--r-- | src/supplemental/base64/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | src/supplemental/http/CMakeLists.txt | 30 | ||||
| -rw-r--r-- | src/supplemental/sha1/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | src/supplemental/tls/CMakeLists.txt | 40 | ||||
| -rw-r--r-- | src/supplemental/util/CMakeLists.txt | 8 | ||||
| -rw-r--r-- | src/supplemental/websocket/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | src/transport/inproc/CMakeLists.txt | 14 | ||||
| -rw-r--r-- | src/transport/ipc/CMakeLists.txt | 14 | ||||
| -rw-r--r-- | src/transport/tcp/CMakeLists.txt | 14 | ||||
| -rw-r--r-- | src/transport/tls/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | src/transport/ws/CMakeLists.txt | 30 | ||||
| -rw-r--r-- | src/transport/zerotier/CMakeLists.txt | 21 |
21 files changed, 299 insertions, 157 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d58f0b2e..428fb56d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,7 +24,8 @@ # IN THE SOFTWARE. # -set (NNG_SOURCES +set (NNG_HDRS nng.h) +set (NNG_SRCS nng.c nng.h @@ -87,7 +88,10 @@ set (NNG_SOURCES ) if (NNG_PLATFORM_POSIX) - set (NNG_SOURCES ${NNG_SOURCES} + find_package (Threads REQUIRED) + set(NNG_LIBS Threads::Threads) + + set (NNG_SRCS ${NNG_SRCS} platform/posix/posix_impl.h platform/posix/posix_ipc.h platform/posix/posix_config.h @@ -114,26 +118,26 @@ if (NNG_PLATFORM_POSIX) ) if (NNG_HAVE_PORT_CREATE) - set (NNG_SOURCES ${NNG_SOURCES} + set (NNG_SRCS ${NNG_SRCS} platform/posix/posix_pollq_port.c ) elseif (NNG_HAVE_KQUEUE) - set (NNG_SOURCES ${NNG_SOURCES} + set (NNG_SRCS ${NNG_SRCS} platform/posix/posix_pollq_kqueue.c ) elseif (NNG_HAVE_EPOLL AND NNG_HAVE_EVENTFD) - set (NNG_SOURCES ${NNG_SOURCES} + set (NNG_SRCS ${NNG_SRCS} platform/posix/posix_pollq_epoll.c ) else() - set (NNG_SOURCES ${NNG_SOURCES} + set (NNG_SRCS ${NNG_SRCS} platform/posix/posix_pollq_poll.c ) endif() endif() if (NNG_PLATFORM_WINDOWS) - set (NNG_SOURCES ${NNG_SOURCES} + set (NNG_SRCS ${NNG_SRCS} platform/windows/win_impl.h platform/windows/win_ipc.h platform/windows/win_tcp.h @@ -158,17 +162,9 @@ if (NNG_PLATFORM_WINDOWS) ) endif() -set (NNG_HEADERS nng.h) add_subdirectory(compat/nanomsg) -add_subdirectory(supplemental/base64) -add_subdirectory(supplemental/http) -add_subdirectory(supplemental/sha1) -add_subdirectory(supplemental/tls) -add_subdirectory(supplemental/util) -add_subdirectory(supplemental/websocket) - add_subdirectory(protocol/bus0) add_subdirectory(protocol/pair0) add_subdirectory(protocol/pair1) @@ -184,14 +180,24 @@ add_subdirectory(transport/tls) add_subdirectory(transport/ws) add_subdirectory(transport/zerotier) -include_directories(AFTER SYSTEM ${PROJECT_SOURCE_DIR}/src - ${NNG_REQUIRED_INCLUDES}) +add_subdirectory(supplemental/base64) +add_subdirectory(supplemental/http) +add_subdirectory(supplemental/sha1) +add_subdirectory(supplemental/tls) +add_subdirectory(supplemental/util) +add_subdirectory(supplemental/websocket) + +include_directories(AFTER SYSTEM ${PROJECT_SOURCE_DIR}/src ${NNG_INCS}) + +add_definitions(${NNG_DEFS}) -add_definitions(${NNG_DEFINES}) +foreach(_PKG IN ITEMS ${NNG_PKGS}) + find_package(${_PKG} REQUIRED) +endforeach () # Provide same folder structure in IDE as on disk # XXX: Consider replacing this with source_group(TREE...) -foreach (f ${NNG_SOURCES}) +foreach (f ${NNG_SRCS}) # Get the path of the file relative to source directory if (IS_ABSOLUTE "${f}") file (RELATIVE_PATH f ${CMAKE_CURRENT_SOURCE_DIR} ${f}) @@ -207,8 +213,9 @@ foreach (f ${NNG_SOURCES}) source_group ("${SRC_GROUP}" FILES ${f}) endforeach () + # Library -add_library (${PROJECT_NAME} ${NNG_SOURCES}) +add_library (${PROJECT_NAME} ${NNG_SRCS}) # When building shared libraries we prefer to suppress default symbol # visibility, so that only the symbols that should be exposed in the @@ -237,33 +244,62 @@ set_target_properties (${PROJECT_NAME} set_target_properties (${PROJECT_NAME} ${PROJECT_NAME} PROPERTIES FRAMEWORK OFF) -target_link_libraries (${PROJECT_NAME} PRIVATE ${NNG_REQUIRED_LIBRARIES}) -target_link_libraries (${PROJECT_NAME} PRIVATE Threads::Threads) +target_link_libraries (${PROJECT_NAME} PRIVATE ${NNG_LIBS}) target_include_directories (${PROJECT_NAME} INTERFACE $<INSTALL_INTERFACE:include>) install (TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-target - FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT tools + FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Library + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Library + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Library + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Tools ) install (EXPORT ${PROJECT_NAME}-target - FILE ${PROJECT_NAME}-config.cmake + FILE ${PROJECT_NAME}-targets.cmake NAMESPACE nng:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} + COMPONENT Library ) # Install the header files. It would be much better if we could use # the PUBLIC_HEADER facility, but it stupidly flattens the directories. -foreach (f ${NNG_HEADERS}) +foreach (f ${NNG_HDRS}) get_filename_component(d ${f} DIRECTORY) install(FILES ${f} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nng/${d} - COMPONENT headers) + COMPONENT Headers) endforeach() # Promote settings to parent -set(NNG_REQUIRED_LIBRARIES ${NNG_REQUIRED_LIBRARIES} PARENT_SCOPE) +set(NNG_LIBS ${NNG_LIBS} PARENT_SCOPE) +set(NNG_PKGS ${NNG_PKGS} PARENT_SCOPE) +set(NNG_DEFS ${NNG_DEFS} PARENT_SCOPE) + +# These are promoted for testing +set(NNG_SUPP_BASE64 ${NNG_SUPP_BASE64} PARENT_SCOPE) +set(NNG_SUPP_HTTP ${NNG_SUPP_HTTP} PARENT_SCOPE) +set(NNG_SUPP_SHA1 ${NNG_SUPP_SHA1} PARENT_SCOPE) +set(NNG_SUPP_TLS ${NNG_SUPP_TLS} PARENT_SCOPE) +set(NNG_SUPP_WEBSOCKET ${NNG_SUPP_WEBSOCKET} PARENT_SCOPE) + +# Configure files + +set(INCLUDE_INSTALL_DIRS "${CMAKE_INSTALL_INCLUDEDIR}/nng") + +include(CMakePackageConfigHelpers) +set(version_config "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake") +set(project_config "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake") + +write_basic_package_version_file("${version_config}" + VERSION ${NNG_PACKAGE_VERSION} + COMPATIBILITY SameMajorVersion +) +configure_package_config_file(${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in "${project_config}" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" + PATH_VARS INCLUDE_INSTALL_DIRS) + +install(FILES "${project_config}" "${version_config}" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" + COMPONENT Library) diff --git a/src/compat/nanomsg/CMakeLists.txt b/src/compat/nanomsg/CMakeLists.txt index 9bac8ede..cdd6fb01 100644 --- a/src/compat/nanomsg/CMakeLists.txt +++ b/src/compat/nanomsg/CMakeLists.txt @@ -22,5 +22,5 @@ set(COMPAT_HEADERS compat/nanomsg/nn.h compat/nanomsg/ws.h ) -set(NNG_SOURCES ${NNG_SOURCES} ${COMPAT_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${COMPAT_HEADERS} PARENT_SCOPE) +set(NNG_SRCS ${NNG_SRCS} ${COMPAT_SOURCES} PARENT_SCOPE) +set(NNG_HDRS ${NNG_HDRS} ${COMPAT_HEADERS} PARENT_SCOPE) diff --git a/src/protocol/bus0/CMakeLists.txt b/src/protocol/bus0/CMakeLists.txt index 06c44111..73acdf11 100644 --- a/src/protocol/bus0/CMakeLists.txt +++ b/src/protocol/bus0/CMakeLists.txt @@ -9,11 +9,15 @@ # # Bus protocol +option (NNG_PROTO_BUS0 "Enable BUSv0 protocol." ON) +mark_as_advanced(NNG_PROTO_BUS0) if (NNG_PROTO_BUS0) - set(BUS0_SOURCES protocol/bus0/bus.c protocol/bus0/bus.h) - set(BUS0_HEADERS protocol/bus0/bus.h) -endif() + set(_DEFS -DNNG_HAVE_BUS0) + set(_SRCS protocol/bus0/bus.c protocol/bus0/bus.h) + set(_HDRS protocol/bus0/bus.h) -set(NNG_SOURCES ${NNG_SOURCES} ${BUS0_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${BUS0_HEADERS} PARENT_SCOPE) + set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) + set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) + set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) +endif() diff --git a/src/protocol/pair0/CMakeLists.txt b/src/protocol/pair0/CMakeLists.txt index 2ba8d374..c453b07f 100644 --- a/src/protocol/pair0/CMakeLists.txt +++ b/src/protocol/pair0/CMakeLists.txt @@ -9,11 +9,15 @@ # # PAIRv0 protocol +option (NNG_PROTO_PAIR0 "Enable PAIRv0 protocol." ON) +mark_as_advanced(NNG_PROTO_PAIR0) if (NNG_PROTO_PAIR0) - set(PAIR0_SOURCES protocol/pair0/pair.c protocol/pair0/pair.h) - set(PAIR0_HEADERS protocol/pair0/pair.h) -endif() + set(_DEFS -DNNG_HAVE_PAIR0) + set(_SRCS protocol/pair0/pair.c protocol/pair0/pair.h) + set(_HDRS protocol/pair0/pair.h) -set(NNG_SOURCES ${NNG_SOURCES} ${PAIR0_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${PAIR0_HEADERS} PARENT_SCOPE) + set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) + set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) + set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) +endif() diff --git a/src/protocol/pair1/CMakeLists.txt b/src/protocol/pair1/CMakeLists.txt index 9c0ca09f..5c8813bf 100644 --- a/src/protocol/pair1/CMakeLists.txt +++ b/src/protocol/pair1/CMakeLists.txt @@ -9,11 +9,15 @@ # # PAIRv1 protocol +option (NNG_PROTO_PAIR1 "Enable PAIRv1 protocol." ON) +mark_as_advanced(NNG_PROTO_PAIR1) if (NNG_PROTO_PAIR1) - set(PAIR1_SOURCES protocol/pair1/pair.c protocol/pair1/pair.h) - set(PAIR1_HEADERS protocol/pair1/pair.h) -endif() + set(_DEFS -DNNG_HAVE_PAIR1) + set(_SRCS protocol/pair1/pair.c protocol/pair1/pair.h) + set(_HDRS protocol/pair1/pair.h) -set(NNG_SOURCES ${NNG_SOURCES} ${PAIR1_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${PAIR1_HEADERS} PARENT_SCOPE) + set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) + set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) + set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) +endif() diff --git a/src/protocol/pipeline0/CMakeLists.txt b/src/protocol/pipeline0/CMakeLists.txt index 669fb9dc..675cb961 100644 --- a/src/protocol/pipeline0/CMakeLists.txt +++ b/src/protocol/pipeline0/CMakeLists.txt @@ -8,17 +8,29 @@ # found online at https://opensource.org/licenses/MIT. # -# Pub/Sub protocol +# Pipeline protocol +option (NNG_PROTO_PUSH0 "Enable PUSHv0 protocol." ON) +mark_as_advanced(NNG_PROTO_PUSH0) + +option (NNG_PROTO_PULL0 "Enable PULLv0 protocol." ON) +mark_as_advanced(NNG_PROTO_PULL0) + +set(_DEFS) +set(_HDRS) +set(_SRCS) if (NNG_PROTO_PUSH0) - set(PUSH0_SOURCES protocol/pipeline0/push.c protocol/pipeline0/push.h) - set(PUSH0_HEADERS protocol/pipeline0/push.h) + list(APPEND _SRCS protocol/pipeline0/push.c protocol/pipeline0/push.h) + list(APPEND _HDRS protocol/pipeline0/push.h) + list(APPEND _DEFS -DNNG_HAVE_PUSH0) endif() if (NNG_PROTO_PULL0) - set(PULL0_SOURCES protocol/pipeline0/pull.c protocol/pipeline0/pull.h) - set(PULL0_HEADERS protocol/pipeline0/pull.h) + list(APPEND _SRCS protocol/pipeline0/pull.c protocol/pipeline0/pull.h) + list(APPEND _HDRS protocol/pipeline0/pull.h) + list(APPEND _DEFS -DNNG_HAVE_PULL0) endif() -set(NNG_SOURCES ${NNG_SOURCES} ${PUSH0_SOURCES} ${PULL0_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${PUSH0_HEADERS} ${PULL0_HEADERS} PARENT_SCOPE) +set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) +set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) +set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) diff --git a/src/protocol/pubsub0/CMakeLists.txt b/src/protocol/pubsub0/CMakeLists.txt index 49ec8913..29f64049 100644 --- a/src/protocol/pubsub0/CMakeLists.txt +++ b/src/protocol/pubsub0/CMakeLists.txt @@ -9,16 +9,28 @@ # # Pub/Sub protocol +option (NNG_PROTO_PUB0 "Enable PUBv0 protocol." ON) +mark_as_advanced(NNG_PROTO_PUB0) + +option (NNG_PROTO_SUB0 "Enable SUBv0 protocol." ON) +mark_as_advanced(NNG_PROTO_SUB0) + +set(_DEFS) +set(_SRCS) +set(_HDRS) if (NNG_PROTO_PUB0) - set(PUB0_SOURCES protocol/pubsub0/pub.c protocol/pubsub0/pub.h) - set(PUB0_HEADERS protocol/pubsub0/pub.h) + list(APPEND _DEFS -DNNG_HAVE_PUB0) + list(APPEND _SRCS protocol/pubsub0/pub.c protocol/pubsub0/pub.h) + list(APPEND _HDRS protocol/pubsub0/pub.h) endif() if (NNG_PROTO_SUB0) - set(SUB0_SOURCES protocol/pubsub0/sub.c protocol/pubsub0/sub.h) - set(SUB0_HEADERS protocol/pubsub0/sub.h) + list(APPEND _DEFS -DNNG_HAVE_SUB0) + list(APPEND _SRCS protocol/pubsub0/sub.c protocol/pubsub0/sub.h) + list(APPEND _HDRS protocol/pubsub0/sub.h) endif() -set(NNG_SOURCES ${NNG_SOURCES} ${PUB0_SOURCES} ${SUB0_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${PUB0_HEADERS} ${SUB0_HEADERS} PARENT_SCOPE) +set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) +set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) +set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) diff --git a/src/protocol/reqrep0/CMakeLists.txt b/src/protocol/reqrep0/CMakeLists.txt index 071c28f1..70c075c1 100644 --- a/src/protocol/reqrep0/CMakeLists.txt +++ b/src/protocol/reqrep0/CMakeLists.txt @@ -9,18 +9,32 @@ # # Req/Rep protocol +option (NNG_PROTO_REQ0 "Enable REQv0 protocol." ON) +mark_as_advanced(NNG_PROTO_REQ0) + +option (NNG_PROTO_REP0 "Enable REPv0 protocol." ON) +mark_as_advanced(NNG_PROTO_REP0) + +set(_DEFS) +set(_SRCS) +set(_HDRS) if (NNG_PROTO_REQ0) - set(REQ0_SOURCES protocol/reqrep0/req.c protocol/reqrep0/xreq.c - protocol/reqrep0/req.h) - set(REQ0_HEADERS protocol/reqrep0/req.h) + list(APPEND _DEFS -DNNG_HAVE_REQ0) + list(APPEND _SRCS + protocol/reqrep0/req.c protocol/reqrep0/xreq.c + protocol/reqrep0/req.h) + list(APPEND _HDRS protocol/reqrep0/req.h) endif() if (NNG_PROTO_REP0) - set(REP0_SOURCES protocol/reqrep0/rep.c protocol/reqrep0/xrep.c - protocol/reqrep0/rep.h) - set(REP0_HEADERS protocol/reqrep0/rep.h) + list(APPEND _DEFS -DNNG_HAVE_REP0) + list(APPEND _SRCS + protocol/reqrep0/rep.c protocol/reqrep0/xrep.c + protocol/reqrep0/rep.h) + list(APPEND _HDRS protocol/reqrep0/rep.h) endif() -set(NNG_SOURCES ${NNG_SOURCES} ${REQ0_SOURCES} ${REP0_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${REQ0_HEADERS} ${REP0_HEADERS} PARENT_SCOPE) +set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) +set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) +set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) diff --git a/src/protocol/survey0/CMakeLists.txt b/src/protocol/survey0/CMakeLists.txt index 0a82463c..b6104a54 100644 --- a/src/protocol/survey0/CMakeLists.txt +++ b/src/protocol/survey0/CMakeLists.txt @@ -9,18 +9,32 @@ # # Surveyor/Respondent protocol +option (NNG_PROTO_RESPONDENT0 "Enable RESPONDENTv0 protocol." ON) +mark_as_advanced(NNG_PROTO_RESPONDENT0) + +option (NNG_PROTO_SURVEYOR0 "Enable SURVEYORv0 protocol." ON) +mark_as_advanced(NNG_PROTO_SURVEYOR0) + +set(_DEFS) +set(_HDRS) +set(_SRCS) if (NNG_PROTO_SURVEYOR0) - set(SURV0_SOURCES protocol/survey0/survey.c protocol/survey0/xsurvey.c - protocol/survey0/survey.h) - set(SURV0_HEADERS protocol/survey0/survey.h) + list(APPEND _DEFS -DNNG_HAVE_SURVEYOR0) + list(APPEND _SRCS + protocol/survey0/survey.c protocol/survey0/xsurvey.c + protocol/survey0/survey.h) + list(APPEND _HDRS protocol/survey0/survey.h) endif() if (NNG_PROTO_RESPONDENT0) - set(RESP0_SOURCES protocol/survey0/respond.c protocol/survey0/xrespond.c - protocol/survey0/respond.h) - set(RESP0_HEADERS protocol/survey0/respond.h) + list(APPEND _DEFS -DNNG_HAVE_RESPONDENT0) + list(APPEND _SRCS + protocol/survey0/respond.c protocol/survey0/xrespond.c + protocol/survey0/respond.h) + list(APPEND _HDRS protocol/survey0/respond.h) endif() -set(NNG_SOURCES ${NNG_SOURCES} ${SURV0_SOURCES} ${RESP0_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${SURV0_HEADERS} ${RESP0_HEADERS} PARENT_SCOPE) +set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) +set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) +set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) diff --git a/src/supplemental/base64/CMakeLists.txt b/src/supplemental/base64/CMakeLists.txt index 297a5478..83740c83 100644 --- a/src/supplemental/base64/CMakeLists.txt +++ b/src/supplemental/base64/CMakeLists.txt @@ -1,6 +1,6 @@ # # Copyright 2017 Capitar IT Group BV <info@capitar.com> -# Copyright 2017 Staysail Systems, Inc. <info@staysail.tech> +# Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> # # This software is supplied under the terms of the MIT License, a # copy of which should be located in the distribution where this @@ -9,8 +9,8 @@ # if (NNG_SUPP_BASE64) - set(BASE64_SOURCES + set(_SRCS supplemental/base64/base64.c supplemental/base64/base64.h) + set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) endif() -set(NNG_SOURCES ${NNG_SOURCES} ${BASE64_SOURCES} PARENT_SCOPE) diff --git a/src/supplemental/http/CMakeLists.txt b/src/supplemental/http/CMakeLists.txt index ed7d5ae2..0fe9e7c5 100644 --- a/src/supplemental/http/CMakeLists.txt +++ b/src/supplemental/http/CMakeLists.txt @@ -8,28 +8,26 @@ # found online at https://opensource.org/licenses/MIT. # +option (NNG_ENABLE_HTTP "Enable HTTP API" ON) +if (NNG_ENABLE_HTTP) + set(NNG_SUPP_HTTP ON) +endif() +mark_as_advanced(NNG_ENABLE_HTTP) + +set(_HDRS supplemental/http/http.h) +set(_SRCS ${_HDRS} supplemental/http/http_public.c supplemental/http/http_api.h) + if (NNG_SUPP_HTTP) - set(HTTP_DEFINES -DNNG_SUPP_HTTP) - set(HTTP_HEADERS - supplemental/http/http.h) - set(HTTP_SOURCES - supplemental/http/http.h - supplemental/http/http_api.h + set(_DEFS -DNNG_SUPP_HTTP) + list(APPEND _SRCS supplemental/http/http_client.c supplemental/http/http_chunk.c supplemental/http/http_conn.c supplemental/http/http_msg.c supplemental/http/http_public.c supplemental/http/http_server.c) -else() - set(HTTP_SOURCES - supplemental/http/http.h - supplemental/http/http_api.h - supplemental/http/http_public.c) - set(HTTP_HEADERS - supplemental/http/http.h) endif() -set(NNG_DEFINES ${NNG_DEFINES} ${HTTP_DEFINES} PARENT_SCOPE) -set(NNG_SOURCES ${NNG_SOURCES} ${HTTP_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${HTTP_HEADERS} PARENT_SCOPE) +set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) +set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) +set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) diff --git a/src/supplemental/sha1/CMakeLists.txt b/src/supplemental/sha1/CMakeLists.txt index 9600a268..370dc7c2 100644 --- a/src/supplemental/sha1/CMakeLists.txt +++ b/src/supplemental/sha1/CMakeLists.txt @@ -1,6 +1,6 @@ # # Copyright 2017 Capitar IT Group BV <info@capitar.com> -# Copyright 2017 Staysail Systems, Inc. <info@staysail.tech> +# Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> # # This software is supplied under the terms of the MIT License, a # copy of which should be located in the distribution where this @@ -9,8 +9,8 @@ # if (NNG_SUPP_SHA1) - set(SHA1_SOURCES + set(_SRCS supplemental/sha1/sha1.c supplemental/sha1/sha1.h) + set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) endif() -set(NNG_SOURCES ${NNG_SOURCES} ${SHA1_SOURCES} PARENT_SCOPE) diff --git a/src/supplemental/tls/CMakeLists.txt b/src/supplemental/tls/CMakeLists.txt index a16745bd..3d1e6d02 100644 --- a/src/supplemental/tls/CMakeLists.txt +++ b/src/supplemental/tls/CMakeLists.txt @@ -10,36 +10,32 @@ if (NNG_SUPP_TLS) set(NNG_SUPP_TLS_MBEDTLS ON) - set(TLS_DEFINES -DNNG_SUPP_TLS) + set(_DEFS -DNNG_SUPP_TLS) endif() -set(TLS_SOURCES supplemental/tls/tls.h) + +set(_SRCS supplemental/tls/tls.h) +set(_HDRS supplemental/tls/tls.h) # For now we only support the ARM mbedTLS library. if (NNG_SUPP_TLS_MBEDTLS) Find_Package(mbedTLS REQUIRED) + set(_LIBS ${MBEDTLS_LIBRARIES}) + set(_INCS ${MBEDTLS_INCLUDE_DIR}) + list(APPEND _SRCS supplemental/tls/mbedtls/tls.c) - # If it isn't already in the link list, add the TLS libraries there. - # or something, so we take care not to duplicate it). - list(FIND NNG_REQUIRED_LIBRARIES ${MBEDTLS_TLS_LIBRARY} _index) - if (_index EQUAL -1) - set(NNG_REQUIRED_LIBRARIES ${NNG_REQUIRED_LIBRARIES} ${MBEDTLS_LIBRARIES}) - set(NNG_REQUIRED_LIBRARIES ${NNG_REQUIRED_LIBRARIES} PARENT_SCOPE) - endif() - - # Likewise for the include search path. - list(FIND NNG_REQUIRED_INCLUDES ${MBEDTLS_INCLUDE_DIR} _index) - if (_index EQUAL -1) - set(NNG_REQUIRED_INCLUDES ${NNG_REQUIRED_INCLUDES} ${MBEDTLS_INCLUDE_DIR}) - set(NNG_REQUIRED_INCLUDES ${NNG_REQUIRED_INCLUDES} PARENT_SCOPE) - endif() - set(TLS_SOURCES ${TLS_SOURCES} supplemental/tls/mbedtls/tls.c) else() - set(TLS_SOURCES ${TLS_SOURCES} supplemental/tls/none/tls.c) + list(APPEND _SRCS supplemental/tls/none/tls.c) endif() -set(TLS_HEADERS supplemental/tls/tls.h) +list(APPEND NNG_DEFS ${_DEFS}) +list(APPEND NNG_SRCS ${_SRCS}) +list(APPEND NNG_HDRS ${_HDRS}) +list(APPEND NNG_LIBS ${_LIBS}) +list(APPEND NNG_INCS ${_INCS}) -set(NNG_DEFINES ${NNG_DEFINES} ${TLS_DEFINES} PARENT_SCOPE) -set(NNG_SOURCES ${NNG_SOURCES} ${TLS_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${TLS_HEADERS} PARENT_SCOPE) +set(NNG_DEFS ${NNG_DEFS} PARENT_SCOPE) +set(NNG_SRCS ${NNG_SRCS} PARENT_SCOPE) +set(NNG_HDRS ${NNG_HDRS} PARENT_SCOPE) +set(NNG_LIBS ${NNG_LIBS} PARENT_SCOPE) +set(NNG_INCS ${NNG_INCS} PARENT_SCOPE) diff --git a/src/supplemental/util/CMakeLists.txt b/src/supplemental/util/CMakeLists.txt index f94e2b45..c61d8a09 100644 --- a/src/supplemental/util/CMakeLists.txt +++ b/src/supplemental/util/CMakeLists.txt @@ -8,8 +8,8 @@ # found online at https://opensource.org/licenses/MIT. # -set(SUPP_UTIL_SOURCES supplemental/util/options.c supplemental/util/platform.c) -set(SUPP_UTIL_HEADERS supplemental/util/options.h supplemental/util/platform.h) +set(_SRCS supplemental/util/options.c supplemental/util/platform.c) +set(_HDRS supplemental/util/options.h supplemental/util/platform.h) -set(NNG_SOURCES ${NNG_SOURCES} ${SUPP_UTIL_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${SUPP_UTIL_HEADERS} PARENT_SCOPE) +set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) +set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) diff --git a/src/supplemental/websocket/CMakeLists.txt b/src/supplemental/websocket/CMakeLists.txt index 5ddd6cb1..22ee955d 100644 --- a/src/supplemental/websocket/CMakeLists.txt +++ b/src/supplemental/websocket/CMakeLists.txt @@ -1,6 +1,6 @@ # # Copyright 2017 Capitar IT Group BV <info@capitar.com> -# Copyright 2017 Staysail Systems, Inc. <info@staysail.tech> +# Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> # # This software is supplied under the terms of the MIT License, a # copy of which should be located in the distribution where this @@ -9,8 +9,8 @@ # if (NNG_SUPP_WEBSOCKET) - set(WEBSOCKET_SOURCES + set(_SRCS supplemental/websocket/websocket.c supplemental/websocket/websocket.h) endif() -set(NNG_SOURCES ${NNG_SOURCES} ${WEBSOCKET_SOURCES} PARENT_SCOPE) +set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) diff --git a/src/transport/inproc/CMakeLists.txt b/src/transport/inproc/CMakeLists.txt index 7c016bce..79264253 100644 --- a/src/transport/inproc/CMakeLists.txt +++ b/src/transport/inproc/CMakeLists.txt @@ -9,11 +9,15 @@ # # inproc protocol +option (NNG_TRANSPORT_INPROC "Enable inproc transport." ON) +mark_as_advanced(NNG_TRANSPORT_INPROC) if (NNG_TRANSPORT_INPROC) - set(INPROC_SOURCES transport/inproc/inproc.c transport/inproc/inproc.h) - set(INPROC_HEADERS transport/inproc/inproc.h) -endif() + set(_SRCS transport/inproc/inproc.c transport/inproc/inproc.h) + set(_HDRS transport/inproc/inproc.h) + set(_DEFS -DNNG_TRANSPORT_INPROC) -set(NNG_SOURCES ${NNG_SOURCES} ${INPROC_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${INPROC_HEADERS} PARENT_SCOPE) + set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) + set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) + set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) +endif() diff --git a/src/transport/ipc/CMakeLists.txt b/src/transport/ipc/CMakeLists.txt index fbae69ef..885b62b6 100644 --- a/src/transport/ipc/CMakeLists.txt +++ b/src/transport/ipc/CMakeLists.txt @@ -9,11 +9,15 @@ # # ipc protocol +option (NNG_TRANSPORT_IPC "Enable IPC transport." ON) +mark_as_advanced(NNG_TRANSPORT_IPC) if (NNG_TRANSPORT_IPC) - set(IPC_SOURCES transport/ipc/ipc.c transport/ipc/ipc.h) - set(IPC_HEADERS transport/ipc/ipc.h) -endif() + set(_DEFS -DNNG_TRANSPORT_IPC) + set(_SRCS transport/ipc/ipc.c transport/ipc/ipc.h) + set(_HDRS transport/ipc/ipc.h) -set(NNG_SOURCES ${NNG_SOURCES} ${IPC_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${IPC_HEADERS} PARENT_SCOPE) + set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) + set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) + set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) +endif() diff --git a/src/transport/tcp/CMakeLists.txt b/src/transport/tcp/CMakeLists.txt index 27b62e10..9390c048 100644 --- a/src/transport/tcp/CMakeLists.txt +++ b/src/transport/tcp/CMakeLists.txt @@ -9,11 +9,15 @@ # # TCP protocol +option (NNG_TRANSPORT_TCP "Enable TCP transport." ON) +mark_as_advanced(NNG_TRANSPORT_TCP) if (NNG_TRANSPORT_TCP) - set(TCP_SOURCES transport/tcp/tcp.c transport/tcp/tcp.h) - set(TCP_HEADERS transport/tcp/tcp.h) -endif() + set(_DEFS -DNNG_TRANSPORT_TCP) + set(_SRCS transport/tcp/tcp.c transport/tcp/tcp.h) + set(_HDRS transport/tcp/tcp.h) -set(NNG_SOURCES ${NNG_SOURCES} ${TCP_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${TCP_HEADERS} PARENT_SCOPE) + set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) + set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) + set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) +endif() diff --git a/src/transport/tls/CMakeLists.txt b/src/transport/tls/CMakeLists.txt index d55a9e92..80bc60af 100644 --- a/src/transport/tls/CMakeLists.txt +++ b/src/transport/tls/CMakeLists.txt @@ -9,11 +9,16 @@ # # TLS transport +CMAKE_DEPENDENT_OPTION(NNG_TRANSPORT_TLS "Enable TLS transport" ON + "NNG_ENABLE_TLS" OFF) +mark_as_advanced(NNG_TRANSPORT_TLS) if (NNG_TRANSPORT_TLS) - set(TLS_SOURCES transport/tls/tls.c transport/tls/tls.h) - set(TLS_HEADERS transport/tls/tls.h) -endif() + set(_DEFS -DNNG_TRANSPORT_TLS) + set(_SRCS transport/tls/tls.c transport/tls/tls.h) + set(_HDRS transport/tls/tls.h) -set(NNG_SOURCES ${NNG_SOURCES} ${TLS_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${TLS_HEADERS} PARENT_SCOPE) + set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) + set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) + set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) +endif() diff --git a/src/transport/ws/CMakeLists.txt b/src/transport/ws/CMakeLists.txt index 71e2aefa..8104d83c 100644 --- a/src/transport/ws/CMakeLists.txt +++ b/src/transport/ws/CMakeLists.txt @@ -9,11 +9,33 @@ # # WebSocket transport +option (NNG_TRANSPORT_WS "Enable WebSocket transport." ON) +mark_as_advanced(NNG_TRANSPORT_WS) + +CMAKE_DEPENDENT_OPTION(NNG_TRANSPORT_WSS "Enable WSS transport" ON + "NNG_ENABLE_TLS" OFF) +mark_as_advanced(NNG_TRANSPORT_WSS) + +set(_DEFS) if (NNG_TRANSPORT_WS) - set(WS_SOURCES transport/ws/websocket.c transport/ws/websocket.h) - set(WS_HEADERS transport/ws/websocket.h) + list(APPEND _DEFS -DNNG_TRANSPORT_WS) +endif() +if (NNG_TRANSPORT_WSS) + list(APPEND _DEFS -DNNG_TRANSPORT_WSS) endif() -set(NNG_SOURCES ${NNG_SOURCES} ${WS_SOURCES} PARENT_SCOPE) -set(NNG_HEADERS ${NNG_HEADERS} ${WS_HEADERS} PARENT_SCOPE) +if (NNG_TRANSPORT_WS OR NNG_TRANSPORT_WSS) + + # Make sure things we *MUST* have are enabled. + set(NNG_SUPP_WEBSOCKET ON PARENT_SCOPE) + set(NNG_SUPP_HTTP ON PARENT_SCOPE) + set(NNG_SUPP_BASE64 ON PARENT_SCOPE) + set(NNG_SUPP_SHA1 ON PARENT_SCOPE) + + set(_SRCS transport/ws/websocket.c transport/ws/websocket.h) + set(_HDRS transport/ws/websocket.h) + set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) + set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) + set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) +endif() diff --git a/src/transport/zerotier/CMakeLists.txt b/src/transport/zerotier/CMakeLists.txt index d8dbb566..686a0a8a 100644 --- a/src/transport/zerotier/CMakeLists.txt +++ b/src/transport/zerotier/CMakeLists.txt @@ -10,6 +10,9 @@ # ZeroTier protocol +option (NNG_TRANSPORT_ZEROTIER "Enable ZeroTier transport (requires libzerotiercore)." OFF) +mark_as_advanced(NNG_TRANSPORT_ZEROTIER) + if (NNG_TRANSPORT_ZEROTIER) # The zerotiercore project will have been found at the top level @@ -27,12 +30,18 @@ if (NNG_TRANSPORT_ZEROTIER) Consult a lawyer and the license files for details. ************************************************************") - set(NNG_REQUIRED_LIBRARIES ${NNG_REQUIRED_LIBRARIES} zerotiercore::zerotiercore) - set(NNG_REQUIRED_LIBRARIES ${NNG_REQUIRED_LIBRARIES} PARENT_SCOPE) + find_package(zerotiercore REQUIRED) + set(_PKGS zerotiercore) + set(_LIBS zerotiercore::zerotiercore) + set(_DEFS -DNNG_TRANSPORT_ZEROTIER) + + set(_SRCS transport/zerotier/zerotier.c transport/zerotier/zerotier.h) + set(_HDRS transport/zerotier/zerotier.h) - set(ZT_SOURCES transport/zerotier/zerotier.c transport/zerotier/zerotier.h) - set(ZT_HEADERS transport/zerotier/zerotier.h) + set(NNG_DEFS ${NNG_DEFS} ${_DEFS} PARENT_SCOPE) + set(NNG_LIBS ${NNG_LIBS} ${_LIBS} PARENT_SCOPE) + set(NNG_PKGS ${NNG_PKGS} ${_PKGS} PARENT_SCOPE) + set(NNG_SRCS ${NNG_SRCS} ${_SRCS} PARENT_SCOPE) + set(NNG_HDRS ${NNG_HDRS} ${_HDRS} PARENT_SCOPE) - set(NNG_SOURCES ${NNG_SOURCES} ${ZT_SOURCES} PARENT_SCOPE) - set(NNG_HEADERS ${NNG_HEADERS} ${ZT_HEADERS} PARENT_SCOPE) endif() |
