From dbb776ba3af9a8dbcf2120346948067e85db97a7 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Mon, 2 Mar 2026 22:10:36 -0400 Subject: [PATCH] Only build tests if BUILD_TESTING is set --- CMakeLists.txt | 6 +++++- README.md | 2 +- tests/CMakeLists.txt | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3b7b6d..1be3d57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,12 @@ endif() include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CppBeSSOT.cmake") +if(NOT DEFINED BUILD_TESTING) + set(BUILD_TESTING OFF CACHE BOOL "Build cppbessot tests" FORCE) +endif() + include(CTest) if(BUILD_TESTING) - add_subdirectory(tests EXCLUDE_FROM_ALL) + add_subdirectory(tests) endif() diff --git a/README.md b/README.md index 6262155..c1a0e90 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ These tests validate that checked-in generated C++ model code can be compiled an ```bash git submodule update --init --recursive tests/googletest -cmake -S . -B build-tests -DDB_SCHEMA_DIR_TO_GENERATE=test-schema-v1.2 +cmake -S . -B build-tests -DBUILD_TESTING=ON -DDB_SCHEMA_DIR_TO_GENERATE=test-schema-v1.2 cmake --build build-tests --target cpp_serdes_test_schema_v1_2 ctest --test-dir build-tests --output-on-failure ``` diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b08ed8d..84093d0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,5 +3,5 @@ if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/googletest/CMakeLists.txt") "GoogleTest submodule is missing. Run `git submodule update --init --recursive tests/googletest` from the cppbessot repo root.") endif() -add_subdirectory(googletest EXCLUDE_FROM_ALL) -add_subdirectory(cpp-serdes EXCLUDE_FROM_ALL) +add_subdirectory(googletest) +add_subdirectory(cpp-serdes)