From e50ad48dac7110d57a6d4ca949a519674e00f039 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Mon, 17 Aug 2026 12:21:50 -0700 Subject: [PATCH 1/2] Added CMake option rmqcpp_ENABLE_TESTING to control whether tests are built Signed-off-by: Noah Oblath --- CMakeLists.txt | 6 +++++- examples/CMakeLists.txt | 4 +++- src/CMakeLists.txt | 10 +++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ecc1048a..38cbcd17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,11 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") option(ENABLE_COMPRESSION "Enable zstd compression support" ON) set(CMAKE_EXPORT_COMPILE_COMMANDS 1) -enable_testing() + +option(rmqcpp_ENABLE_TESTING "Enable testing" ON) +if(rmqcpp_ENABLE_TESTING) + enable_testing() +endif() set(CMAKE_POSITION_INDEPENDENT_CODE ON) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 563a8320..311844f2 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,4 +1,6 @@ -add_subdirectory(rmqperftest) +if(rmqcpp_ENABLE_TESTING) + add_subdirectory(rmqperftest) +endif() if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "XL")) # The examples don't need to work on these platforms diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 262b14d7..3954e4be 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,11 +6,15 @@ endif() find_package(Boost REQUIRED) set(OPENSSL_USE_STATIC_LIBS TRUE) find_package(OpenSSL REQUIRED) -find_package(GTest REQUIRED) +if(rmqcpp_ENABLE_TESTING) + find_package(GTest REQUIRED) +endif() # BDE-required subpackages find_package(bal REQUIRED) add_subdirectory(rmq) -add_subdirectory(rmqtestmocks) -add_subdirectory(tests) +if(rmqcpp_ENABLE_TESTING) + add_subdirectory(rmqtestmocks) + add_subdirectory(tests) +endif() From 3d30657c68f65e6f158145225362249fd5204d6f Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Mon, 17 Aug 2026 13:38:50 -0700 Subject: [PATCH 2/2] Move the installation of GTest to a feature in the vcpkg manifest; default is still on. Tie vcpkg manifest setting to the CMake setting. Signed-off-by: Noah Oblath --- CMakeLists.txt | 7 ++++++- vcpkg.json | 12 +++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38cbcd17..9eb4a6d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,12 @@ option(ENABLE_COMPRESSION "Enable zstd compression support" ON) set(CMAKE_EXPORT_COMPILE_COMMANDS 1) -option(rmqcpp_ENABLE_TESTING "Enable testing" ON) +# Derive the default for enabling testing from the selected vcpkg features +set(rmqcpp_ENABLE_TESTING_DEFAULT ON) +if(VCPKG_MANIFEST_MODE AND VCPKG_MANIFEST_NO_DEFAULT_FEATURES AND NOT "tests" IN_LIST VCPKG_MANIFEST_FEATURES) + set(rmqcpp_ENABLE_TESTING_DEFAULT OFF) +endif() +option(rmqcpp_ENABLE_TESTING "Enable testing (requires GTest)" ${rmqcpp_ENABLE_TESTING_DEFAULT}) if(rmqcpp_ENABLE_TESTING) enable_testing() endif() diff --git a/vcpkg.json b/vcpkg.json index 8e0774d6..10840f06 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -5,9 +5,19 @@ "dependencies": [ "boost-asio", "openssl", - "gtest", "bde", "pcre2", "zstd" + ], + "features": { + "tests": { + "description": "Build the rmqcpp unit and integration tests", + "dependencies": [ + "gtest" + ] + } + }, + "default-features": [ + "tests" ] }