From d6f0c13355199173dd7a2957dc2bae54bb5d85c3 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 25 Jan 2024 23:34:41 -0800 Subject: New CMAKE option NNG_ENABLE_COMPAT (defaults ON) This option allows the compatibility code to be elided from the build. This saves build time, and eliminates bloat from a static library when used strictly in native NNG mode. --- src/CMakeLists.txt | 7 +++++-- src/core/buf_size_test.c | 12 +++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src') 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. +# Copyright 2024 Staysail Systems, Inc. # Copyright 2018 Capitar IT Group BV # # 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 +#if NNG_ENABLE_COMPAT #include +#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 }, }; -- cgit v1.2.3-70-g09d2