From ae7e3a47495efc7bf7ed6c1cd74bac0cad345699 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Wed, 29 Jul 2026 12:13:51 +0000 Subject: [PATCH] Honor BUILD_TESTS in the CMake build The getdeps manifest already passes -DBUILD_TESTS=ON/OFF, but the CMake build ignored it: GMock was unconditionally REQUIRED, the test directories were always added, and edencommon_testharness always built. That is a hard configure failure on installations whose folly does not export the Folly::folly_test_util target (which the test harness and tests link against), and pulls in a googletest dependency even when no tests are wanted -- e.g. when building edencommon purely as a dependency of watchman on minimal platforms. Add the BUILD_TESTS option (default ON, preserving current behavior) and gate the GMock discovery, enable_testing, the testharness library, and the os/ and utils/ test subdirectories on it. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_015ECmTd2wkJqqrArR8VHCDm --- CMakeLists.txt | 20 +++++++++++++++----- eden/common/os/CMakeLists.txt | 4 +++- eden/common/utils/CMakeLists.txt | 4 +++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b3a75e..0eef040 100644 --- CMakeLists.txt +++ CMakeLists.txt @@ -68,14 +68,24 @@ include_directories(${WANGLE_INCLUDE_DIR}) find_package(FBThrift CONFIG REQUIRED COMPONENTS cpp2 py) include_directories(${FBTHRIFT_INCLUDE_DIR}) -find_package(GMock MODULE REQUIRED) -include_directories(${GMOCK_INCLUDEDIR} ${LIBGMOCK_INCLUDE_DIR}) -include(GoogleTest) -enable_testing() +option(BUILD_TESTS + "If enabled, build the tests and the test harness. Requires GMock and \ + a folly installation that provides folly_test_util." + ON +) + +if(BUILD_TESTS) + find_package(GMock MODULE REQUIRED) + include_directories(${GMOCK_INCLUDEDIR} ${LIBGMOCK_INCLUDE_DIR}) + include(GoogleTest) + enable_testing() +endif() add_subdirectory(eden/common/os) add_subdirectory(eden/common/telemetry) -add_subdirectory(eden/common/testharness) +if(BUILD_TESTS) + add_subdirectory(eden/common/testharness) +endif() add_subdirectory(eden/common/utils) configure_file( diff --git a/eden/common/os/CMakeLists.txt b/eden/common/os/CMakeLists.txt index 4875a64..ca20c50 100644 --- eden/common/os/CMakeLists.txt +++ eden/common/os/CMakeLists.txt @@ -42,4 +42,6 @@ install( DESTINATION ${INCLUDE_INSTALL_DIR}/eden/common/os ) -add_subdirectory(test) +if(BUILD_TESTS) + add_subdirectory(test) +endif() diff --git a/eden/common/utils/CMakeLists.txt b/eden/common/utils/CMakeLists.txt index 82e1548..ae5a614 100644 --- eden/common/utils/CMakeLists.txt +++ eden/common/utils/CMakeLists.txt @@ -74,4 +74,6 @@ install( DESTINATION ${INCLUDE_INSTALL_DIR}/eden/common/utils/windows ) -add_subdirectory(test) +if(BUILD_TESTS) + add_subdirectory(test) +endif()