Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
- name: Run static and in-source unit testing checks
run: cmake -P tests/setup/test_source_testing.cmake

- name: Run generated-test timeout checks
run: cmake -P tests/setup/test_timeouts.cmake

- name: Run project version override tests
run: cmake -P tests/setup/test_version_override.cmake

Expand Down Expand Up @@ -88,6 +91,9 @@ jobs:
- name: Run static and in-source unit testing checks
run: cmake -P tests/setup/test_source_testing.cmake

- name: Run generated-test timeout checks
run: cmake -P tests/setup/test_timeouts.cmake

- name: Run project version override tests
run: cmake -P tests/setup/test_version_override.cmake

Expand Down
3 changes: 2 additions & 1 deletion .scout/memory/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
## Knowledge

- [[knowledge/architecture-overview.md|Architecture Overview]] (concept, 0.80) `architecture-overview` `cpp-library-architecture` `cpp-library-overview` `toolkit-architecture` `cmake-infrastructure-overview`
- [[knowledge/assign-generated-test-timeouts-at-registration-to-preserve-per-test-overrides.md|Assign generated-test timeouts at registration to preserve per-test overrides]] (pattern, 1.00) `ctest` `timeouts` `test-support` `deferred-configuration`
- [[knowledge/consumer-lifecycle-and-template-overwrite-controls.md|Consumer Lifecycle and Template Overwrite Controls]] (decision, 0.75) `template-initialization` `cpp-library-force-init` `project-is-top-level` `lightweight-consumer-mode` `template-copying`
- [[knowledge/deferred-install-dependency-validation-and-config-generation.md|Deferred Install Dependency Validation and Config Generation]] (pattern, 0.75) `deferred-install` `install-validation` `untracked-dependencies` `cmake-language-defer` `find-dependency`
- [[knowledge/dependency-mappings-follow-the-exported-target-s-owning-project.md|Dependency mappings follow the exported target's owning project]] (discovery, 0.99) `cmake` `dependency-mappings` `project-scope` `deferred-install`
- [[knowledge/dependency-tracking-lifecycle-and-provider-ordering.md|Dependency Tracking Lifecycle and Provider Ordering]] (observation, 0.75) `dependency-tracking` `dependency-provider` `cpp-library-enable-dependency-tracking` `cmake-project-top-level-includes` `set-dependency-provider`
- [[knowledge/documentation-setup-and-theme-integration-with-build-docs.md|Documentation Setup and Theme Integration with BUILD_DOCS]] (pattern, 0.75) `build-docs` `doxygen` `doxygen-awesome-css` `documentation-generation` `docs-target`
- [[knowledge/generated-ci-package-artifact-check.md|Generated CI package artifact check]] (decision, 0.95) `ci` `packaging` `cmake`
- [[knowledge/generated-ci-package-artifact-check.md|Generated CI package artifact check]] (decision, 0.98) `ci` `packaging` `cmake` `source-builds`
- [[knowledge/installation-supports-separately-installed-dependencies-not-mixed-source-export-workarounds.md|Installation supports separately installed dependencies, not mixed source export workarounds]] (decision, 0.99) `cmake` `installation` `cpm` `supported-boundary`
- [[knowledge/public-header-verification-must-participate-in-the-default-build.md|Public-header verification must participate in the default build]] (pattern, 0.99) `cmake` `header-verification` `testing` `file-sets`
- [[knowledge/static-and-in-source-tests-require-separate-implementation-compilations.md|Static and in-source tests require separate implementation compilations]] (decision, 0.99) `cmake` `testing` `doctest` `static-linkage` `private-components` `generated-headers`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: "Assign generated-test timeouts at registration to preserve per-test overrides"
entity_type: pattern
confidence: 1.00
created: 2026-11-21T06:03:02Z
last_accessed: 2026-11-21T06:03:09Z
last_reinforced: 2026-11-21T06:03:09Z
access_count: 2
sources:
- "cpp-library.cmake:135-150"
- "cpp-library.cmake:338-340"
- "cmake/cpp-library-testing.cmake:8-15"
- "cmake/cpp-library-testing.cmake:117-129"
- "tests/setup/test_timeouts.cmake:31-39"
tags: ["ctest", "timeouts", "test-support", "deferred-configuration"]
tier: knowledge
---

# Assign generated-test timeouts at registration to preserve per-test overrides

Generated CTest timeout policy is project-local: cpp_library_setup stores an explicit TEST_TIMEOUT in the production library target's _CPP_LIBRARY_TEST_TIMEOUT property (cpp-library.cmake:338-340). _cpp_library_set_test_timeout reads that property, defaults to 120 seconds, and sets the native test TIMEOUT property (cmake/cpp-library-testing.cmake:8-15).

Keep timeout assignment immediate at each registration site, not in deferred test-support finalization. Ordinary tests/examples and compile-fail checks are registered in cpp-library.cmake:135-150; compiled libraries also register a separate in-source runner in cmake/cpp-library-testing.cmake:117-129. All three paths must apply the same policy using the production library target, not its static unit-test implementation target. Immediate assignment lets consumers use set_tests_properties after setup without deferred work resetting their intentional exceptions; the regression overrides both ordinary and in-source tests (tests/setup/test_timeouts.cmake:31-39).

Verification: cmake -P tests/setup/test_timeouts.cmake inspects effective CTest JSON, checks generated preset metadata, and proves one-second timeout failure for runtime and WILL_FAIL compile-fail tests.
23 changes: 17 additions & 6 deletions .scout/memory/knowledge/generated-ci-package-artifact-check.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
---
title: "Generated CI package artifact check"
entity_type: decision
confidence: 0.95
confidence: 0.98
created: 2026-11-15T04:12:07Z
last_accessed: 2026-11-15T04:27:16Z
last_reinforced: 2026-11-15T04:27:16Z
access_count: 2
last_accessed: 2026-11-21T06:05:52Z
last_reinforced: 2026-11-21T06:05:52Z
access_count: 4
sources:
- "templates/.github/workflows/ci.yml.in:76-79"
- "templates/test-package.cmake.in:8-35"
- "cmake/cpp-library-ci.cmake:41-54"
tags: ["ci", "packaging", "cmake"]
- "README.md:223-265"
- "docs/installation-testing.md:3-17"
- "cmake/cpp-library-setup.cmake:187-196"
tags: ["ci", "packaging", "cmake", "source-builds"]
tier: knowledge
---

# Generated CI package artifact check

Generated consumer CI deliberately verifies only the root package's installed Config, ConfigVersion and Targets artifacts; dependency installation and downstream find_package resolution remain the consumer's responsibility. The checker requires both file existence and membership in the current CMake install manifest, so stale absolute-destination artifacts cannot pass. Absolute library destinations do not require the otherwise unused install prefix to exist. The deferred generator captures CPP_LIBRARY_ROOT when scheduled because setup may run inside a function whose scope ends before deferred calls execute. Sources: templates/.github/workflows/ci.yml.in:76-79, templates/test-package.cmake.in:8-35, cmake/cpp-library-ci.cmake:41-54.
# Generated CI package artifact check

Generated consumer CI is source-only; it no longer installs or runs package-artifact checks automatically. Source presets (default, test, docs, clang-tidy, init) disable the resolved namespace/custom installation option; install enables it. Merely removing cmake --install is insufficient: CMake validates exports at generation time, so source-built dependencies without export sets can break configuration unless installation is disabled.

Clients wanting installation testing provide their own YAML workflow that installs required dependencies separately, configures the component against those installed packages, then installs and optionally runs the generated cpp-library-test-package.cmake script. No installation-specific dependency declarations or export workarounds belong in client CMakeLists.txt. CPM_USE_LOCAL_PACKAGES is a preference, not a source-fallback prohibition.

The optional checker verifies root Config, ConfigVersion and Targets artifact existence AND membership in the install manifest, not downstream consumption or dependency closure. Keep stale-artifact and absolute-destination protections. Keep deferred generator root capture for function-scoped setup.

Presets are configured from templates/CMakePresets.json.in with @ONLY to preserve literal ${sourceDir}; preserve existing consumer files unless force initialization is requested. This updates the earlier memory that incorrectly described automatic generated-CI installation checking after PR #61.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ cpp_library_setup(
[DOCS_OPTIONS setting_list] # Additive single-line Doxygen assignments
[REQUIRES_CPP_VERSION 17|20|23] # C++ version (default: 20)
[ENABLE_THREADS ON|OFF] # Transitive thread requirements (default: ON)
[TEST_TIMEOUT seconds] # Per-test timeout in seconds (default: 120)
[INSTALL_OPTION option_name] # Independent installation control (default: uppercase NAMESPACE_INSTALL)
[LICENSE_FILES file_list] # Additional project-relative or absolute license/notice files
)
Expand Down Expand Up @@ -541,6 +542,32 @@ cpp_library_setup(
Pass `ENABLE_THREADS OFF` to skip automatic thread discovery and linkage;
this does not disable C++ thread APIs or remove thread requirements you add manually.

### Test timeouts

Generated unit tests, examples, compile-fail checks, and in-source test runners
each have a 120-second CTest `TIMEOUT`. Set `TEST_TIMEOUT` to change this
project-wide limit. Values must be whole seconds from 1 through 2147483647;
zero (unlimited), missing, fractional, and nonnumeric values fail configuration.
Manually registered tests are unchanged.

For an intentionally longer test, set a finite per-test exception after setup:

```cmake
cpp_library_setup(
DESCRIPTION "My library"
NAMESPACE mylib
HEADERS api.hpp
TESTS fast_test.cpp slow_test.cpp
TEST_TIMEOUT 120
)
set_tests_properties(slow_test PROPERTIES TIMEOUT 300)
```

These properties apply to ordinary CTest runs, generated test presets, and CI.
Inspect the effective limits with `ctest --show-only=json-v1` in your build
directory. A timeout fails the test, including compile-fail checks marked
`WILL_FAIL`.

### Documentation configuration

Keep the toolkit's Doxyfile template instead of copying it into your project.
Expand Down
10 changes: 10 additions & 0 deletions cmake/cpp-library-testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
# Provides cpp_library_copy_runtime_dlls for custom and toolkit-created executables.
# _cpp_library_setup_testing delegates to _cpp_library_setup_executables for compatibility.

# Sets a generated test's project timeout, defaulting to 120 seconds.
function(_cpp_library_set_test_timeout library_target test_name)
get_target_property(timeout "${library_target}" _CPP_LIBRARY_TEST_TIMEOUT)
if(NOT timeout)
set(timeout 120)
endif()
set_tests_properties("${test_name}" PROPERTIES TIMEOUT "${timeout}")
endfunction()

# Adds a private, always-defined function-style testing configuration.
function(_cpp_library_setup_testing_config)
cmake_parse_arguments(ARG "" "TARGET;ENABLED" "" ${ARGN})
Expand Down Expand Up @@ -115,6 +124,7 @@ function(_cpp_library_setup_test_support)
[[${ARG_TARGET}]] [[${runner}]])")
cpp_library_copy_runtime_dlls("${runner}")
add_test(NAME "${runner}" COMMAND "${runner}")
_cpp_library_set_test_timeout("${ARG_TARGET}" "${runner}")
set_tests_properties("${runner}" PROPERTIES LABELS doctest
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
Expand Down
16 changes: 15 additions & 1 deletion cpp-library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ function(_cpp_library_setup_executables)
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set_tests_properties(compile_${executable_base} PROPERTIES WILL_FAIL TRUE)
_cpp_library_set_test_timeout("${ARG_NAME}" "compile_${executable_base}")
else()
# Regular executable - build and link normally
add_executable(${executable_base} "${source_dir}/${executable}")
Expand All @@ -146,6 +147,7 @@ function(_cpp_library_setup_executables)

# Register as CTest test
add_test(NAME ${executable_base} COMMAND ${executable_base})
_cpp_library_set_test_timeout("${ARG_NAME}" "${executable_base}")

# Set test properties for better IDE integration (only for tests)
if(ARG_TYPE STREQUAL "tests")
Expand Down Expand Up @@ -184,6 +186,7 @@ function(cpp_library_setup)
NAMESPACE # Namespace (e.g., "stlab")
REQUIRES_CPP_VERSION # C++ version (default: 20)
ENABLE_THREADS # Portable thread requirements (default: ON)
TEST_TIMEOUT # Generated-test timeout in seconds (default: 120)
INSTALL_OPTION # Custom installation option name
)
set(multiValueArgs
Expand All @@ -202,14 +205,21 @@ function(cpp_library_setup)
if("INSTALL_OPTION" IN_LIST ARG_KEYWORDS_MISSING_VALUES)
message(FATAL_ERROR "cpp_library_setup: INSTALL_OPTION requires a value")
endif()
foreach(keyword DOCS_INPUTS DOCS_OPTIONS LICENSE_FILES ENABLE_THREADS)
foreach(keyword DOCS_INPUTS DOCS_OPTIONS LICENSE_FILES ENABLE_THREADS TEST_TIMEOUT)
if(keyword IN_LIST ARG_KEYWORDS_MISSING_VALUES)
message(FATAL_ERROR "cpp_library_setup: ${keyword} requires a value")
endif()
endforeach()
if(NOT DEFINED ARG_ENABLE_THREADS)
set(ARG_ENABLE_THREADS ON)
endif()
if(DEFINED ARG_TEST_TIMEOUT)
if(NOT ARG_TEST_TIMEOUT MATCHES "^[0-9]+$" OR
ARG_TEST_TIMEOUT LESS 1 OR ARG_TEST_TIMEOUT GREATER 2147483647)
message(FATAL_ERROR
"cpp_library_setup: TEST_TIMEOUT must be a positive integer in seconds (1 through 2147483647)")
endif()
endif()
set(install_args)
if(DEFINED ARG_INSTALL_OPTION)
list(APPEND install_args INSTALL_OPTION "${ARG_INSTALL_OPTION}")
Expand Down Expand Up @@ -325,6 +335,10 @@ function(cpp_library_setup)
${install_args}
)

if(DEFINED ARG_TEST_TIMEOUT)
set_property(TARGET "${ARG_NAME}" PROPERTY _CPP_LIBRARY_TEST_TIMEOUT "${ARG_TEST_TIMEOUT}")
endif()

if(ARG_ENABLE_THREADS)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
Expand Down
Loading
Loading