From 3313e60a2d1d2cf3b2f57ad3e2dfac8335972516 Mon Sep 17 00:00:00 2001 From: Josh Cudby Date: Wed, 12 Aug 2026 15:18:46 +0000 Subject: [PATCH] fix(cmake): :bug: enable_testing() before add_subdirectory(cpp) for root ctest enable_testing()/include(CTest) lived in cpp/CMakeLists.txt, called after the root CMakeLists.txt had already run add_subdirectory(cpp). CTest's enabled-ness does not propagate back up to an already-processed parent directory, so the root build tree never got a CTestTestfile.cmake and `ctest --test-dir build/editable/Release` (the documented entry point) reported "No tests were found!!!" even though the suite itself passed. Assisted-by: ClaudeCode:claude-sonnet-5 --- CMakeLists.txt | 7 +++++++ cpp/CMakeLists.txt | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65a033ad..2c4bd4f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,5 +110,12 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) add_library(monoprop-objs OBJECT "") add_library(monoprop SHARED $) +# must run before add_subdirectory(cpp): CTest's enabled-ness does not propagate +# back up to a parent directory that has already been added as a subdirectory. +if(monoprop_ENABLE_CXX_UNIT_TESTS) + enable_testing() + include(CTest) +endif() + add_subdirectory(cpp) add_subdirectory(src/monoprop/bindings) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index a90e6349..361e4531 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -51,7 +51,5 @@ install( ) if(monoprop_ENABLE_CXX_UNIT_TESTS) - enable_testing() - include(CTest) add_subdirectory(tests) endif()