From 13875e7f20e9d681a201a081e079966a899d4605 Mon Sep 17 00:00:00 2001 From: TermeHansen Date: Sun, 10 May 2026 22:50:02 +0200 Subject: [PATCH 1/2] only build examples if defined --- CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c1c01f0..038bbf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,8 +167,12 @@ else() # Apply host configuration sendspin_configure_host(sendspin ${CMAKE_CURRENT_SOURCE_DIR}) - # Examples - add_subdirectory(examples/basic_client) - add_subdirectory(examples/tui_client) + # Examples (only build if explicitly requested) + if(NOT DEFINED BUILD_EXAMPLES OR BUILD_EXAMPLES) + add_subdirectory(examples/basic_client) + add_subdirectory(examples/tui_client) + else() + message(STATUS "Skipping sendspin-cpp examples (BUILD_EXAMPLES=OFF)") + endif() endif() From 70c0e08f9f274e2e4a6826e9624c11a79902c819 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Thu, 21 May 2026 13:19:45 -0400 Subject: [PATCH 2/2] Make `BUILD_EXAMPLES` a CMake option. It defaults to enabled only if this is the top-level project --- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 038bbf7..4f19a78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,11 +164,20 @@ else() option(ENABLE_WERROR "Treat warnings as errors" OFF) option(ENABLE_SANITIZERS "Enable AddressSanitizer and UndefinedBehaviorSanitizer" OFF) + # Examples build by default for standalone development, but not when sendspin is pulled into + # a larger project via add_subdirectory (where the consumer doesn't want the example deps, + # e.g. FTXUI). Override either way with -DBUILD_EXAMPLES=ON/OFF. + set(_sendspin_is_top_level OFF) + if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(_sendspin_is_top_level ON) + endif() + option(BUILD_EXAMPLES "Build host examples" ${_sendspin_is_top_level}) + # Apply host configuration sendspin_configure_host(sendspin ${CMAKE_CURRENT_SOURCE_DIR}) - # Examples (only build if explicitly requested) - if(NOT DEFINED BUILD_EXAMPLES OR BUILD_EXAMPLES) + # Examples + if(BUILD_EXAMPLES) add_subdirectory(examples/basic_client) add_subdirectory(examples/tui_client) else()