summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--cmake/NNGOptions.cmake5
-rw-r--r--src/CMakeLists.txt7
-rw-r--r--src/core/buf_size_test.c12
-rw-r--r--tests/CMakeLists.txt42
5 files changed, 44 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7fe8f712..d828d15e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,6 +96,9 @@ target_compile_definitions(nng_private INTERFACE NNG_PRIVATE)
if (NNG_ELIDE_DEPRECATED)
target_compile_definitions(nng PRIVATE NNG_ELIDE_DEPRECATED)
endif()
+if (NNG_ENABLE_COMPAT)
+ target_compile_definitions(nng PRIVATE NNG_ENABLE_COMPAT)
+endif()
# We can use rlimit to configure the stack size for systems
diff --git a/cmake/NNGOptions.cmake b/cmake/NNGOptions.cmake
index 6335fc63..abb3f03d 100644
--- a/cmake/NNGOptions.cmake
+++ b/cmake/NNGOptions.cmake
@@ -39,6 +39,11 @@ option(NNG_ENABLE_COVERAGE "Enable coverage reporting." OFF)
# for the public library.
option(NNG_ELIDE_DEPRECATED "Elide deprecated functionality." OFF)
+# Turning off the compatibility layer can save some space, and
+# compilation time, but may break legacy applications It should
+# be left enabled when building a shared library.
+option(NNG_ENABLE_COMPAT "Enable legacy nanomsg API." ON)
+
option(NNG_ENABLE_STATS "Enable statistics." ON)
mark_as_advanced(NNG_ENABLE_STATS)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 20a7bef0..ab33292d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
+# Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
# Copyright 2018 Capitar IT Group BV <info@capitar.com>
#
# This software is supplied under the terms of the MIT License, a
@@ -16,12 +16,15 @@ target_include_directories(nng_testing PRIVATE ${PROJECT_SOURCE_DIR}/src)
add_subdirectory(core)
add_subdirectory(platform)
-add_subdirectory(compat)
add_subdirectory(sp)
add_subdirectory(supplemental)
add_subdirectory(tools)
add_subdirectory(testing)
+if (NNG_ENABLE_COMPAT)
+ add_subdirectory(compat)
+endif()
+
# When building shared libraries we prefer to suppress default symbol
# visibility, so that only the symbols that should be exposed in the
# resulting library are. This is the default with Windows.
diff --git a/src/core/buf_size_test.c b/src/core/buf_size_test.c
index b8757991..78678d66 100644
--- a/src/core/buf_size_test.c
+++ b/src/core/buf_size_test.c
@@ -10,15 +10,17 @@
#include <nuts.h>
+#if NNG_ENABLE_COMPAT
#include <nng/compat/nanomsg/nn.h>
+#endif
- void
+void
test_buffer_options(void)
{
nng_socket s1;
int val;
size_t sz;
- char * opt;
+ char *opt;
char *cases[] = {
NNG_OPT_RECVBUF,
@@ -62,8 +64,9 @@ test_buffer_options(void)
void
test_buffer_legacy(void)
{
+#if NNG_ENABLE_COMPAT
nng_socket s1;
- char * opt;
+ char *opt;
char *cases[] = {
NNG_OPT_RECVBUF,
@@ -104,10 +107,13 @@ test_buffer_legacy(void)
NUTS_TRUE(nn_errno() == EINVAL);
}
NUTS_PASS(nng_close(s1));
+#endif
}
NUTS_TESTS = {
{ "buffer options", test_buffer_options },
+#if NNG_ENABLE_COMPAT
{ "buffer legacy", test_buffer_legacy },
+#endif
{ NULL, NULL },
};
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 063692cb..022fe49b 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
+# Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
# Copyright 2018 Capitar IT Group BV <info@capitar.com>
# Copyright (c) 2012 Martin Sustrik All rights reserved.
# Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
@@ -155,25 +155,27 @@ add_nng_test(reqstress 60)
# is because we don't want to make modifications to partially enable some
# of these tests. Folks minimizing the library probably don't care too
# much about these anyway.
-add_nng_compat_test(compat_block 10)
-add_nng_compat_test(compat_bug777 10)
-add_nng_compat_test(compat_bus 10)
-add_nng_compat_test(compat_cmsg 10)
-add_nng_compat_test(compat_msg 10)
-add_nng_compat_test(compat_iovec 10)
-add_nng_compat_test(compat_device 10)
-add_nng_compat_test(compat_pair 10)
-add_nng_compat_test(compat_pipeline 10)
-add_nng_compat_test(compat_poll 10)
-add_nng_compat_test(compat_reqrep 10)
-add_nng_compat_test(compat_survey 10)
-add_nng_compat_test(compat_reqttl 10)
-add_nng_compat_test(compat_shutdown 10)
-add_nng_compat_test(compat_surveyttl 10)
-
-# These are special tests for compat mode, not inherited from the
-# legacy libnanomsg suite.
-add_nng_test(compat_options 5)
+if (NNG_ENABLE_COMPAT)
+ add_nng_compat_test(compat_block 10)
+ add_nng_compat_test(compat_bug777 10)
+ add_nng_compat_test(compat_bus 10)
+ add_nng_compat_test(compat_cmsg 10)
+ add_nng_compat_test(compat_msg 10)
+ add_nng_compat_test(compat_iovec 10)
+ add_nng_compat_test(compat_device 10)
+ add_nng_compat_test(compat_pair 10)
+ add_nng_compat_test(compat_pipeline 10)
+ add_nng_compat_test(compat_poll 10)
+ add_nng_compat_test(compat_reqrep 10)
+ add_nng_compat_test(compat_survey 10)
+ add_nng_compat_test(compat_reqttl 10)
+ add_nng_compat_test(compat_shutdown 10)
+ add_nng_compat_test(compat_surveyttl 10)
+
+ # These are special tests for compat mode, not inherited from the
+ # legacy libnanomsg suite.
+ add_nng_test(compat_options 5)
+endif()
# c++ tests
add_nng_cpp_test(cplusplus_pair 5)