diff --git a/CMakeLists.txt b/CMakeLists.txt index c1c01f0..4f19a78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,11 +164,24 @@ 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 - add_subdirectory(examples/basic_client) - add_subdirectory(examples/tui_client) + if(BUILD_EXAMPLES) + add_subdirectory(examples/basic_client) + add_subdirectory(examples/tui_client) + else() + message(STATUS "Skipping sendspin-cpp examples (BUILD_EXAMPLES=OFF)") + endif() endif()