Skip to content

Commit b200fa0

Browse files
committed
feat(skill): add Gecode CMake guidance
1 parent b6fe4db commit b200fa0

4 files changed

Lines changed: 55 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ The skill routes internally to focused reference documents for:
3232
- memory management
3333
- built-in search engines
3434
- custom search engine implementation
35+
- downstream CMake consumption
3536

3637
## Contributing
3738

evals/gecode-trigger-evals.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
"query": "Can you help debug a Gecode issue where a stored choice seems invalid after recomputation? The model uses custom branchers and I suspect I'm breaking clone or commit invariants.",
1616
"should_trigger": true
1717
},
18+
{
19+
"query": "I am packaging a C++ solver that depends on Gecode 6.3+ and I want the downstream CMake project to use find_package(Gecode CONFIG) with a FetchContent fallback when it's not installed.",
20+
"should_trigger": true
21+
},
1822
{
1923
"query": "Please model this scheduling problem in Gecode with strong global constraints, sensible symmetry breaking, and a branching strategy that focuses on the cost-driving variables first.",
2024
"should_trigger": true
@@ -35,6 +39,10 @@
3539
"query": "I'm using Gecode with a mix of discrete choices and continuous tolerances. What should I watch out for when float vars are part of the model, especially compared with ordinary integer branching intuition?",
3640
"should_trigger": true
3741
},
42+
{
43+
"query": "I need to clean up a generic CMakeLists.txt for a small SDL app. There is no Gecode involved, I just want better target_link_libraries usage and install rules.",
44+
"should_trigger": false
45+
},
3846
{
3947
"query": "How would you model a nurse rostering problem in constraint programming? I'm open to any solver or even OR-Tools, I mainly want high-level CP advice.",
4048
"should_trigger": false
@@ -47,6 +55,10 @@
4755
"query": "Can you explain branch and bound versus depth-first search in general terms? I don't need implementation details for any particular library.",
4856
"should_trigger": false
4957
},
58+
{
59+
"query": "I have an old FindFoo.cmake module and want to migrate to package config usage. The library is our in-house SDK, not Gecode.",
60+
"should_trigger": false
61+
},
5062
{
5163
"query": "What are good heuristics for graph coloring in CP, and how do I think about symmetry? Solver-agnostic advice is fine.",
5264
"should_trigger": false

skills/gecode/SKILL.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: gecode
3-
description: "Gecode architecture, modeling, cookbook-style modeling patterns, set/float/scheduling guidance, propagators, branchers, memory management, search engine usage and implementation, recomputation/cloning behavior, and debugging/performance diagnosis. Use for any materially Gecode-specific task: building or refining Gecode models, implementing custom constraints or branchers, tuning DFS/BAB/RBS/PBS/LDS search, diagnosing weak propagation or search pathologies, or reasoning about set/float/resource-style models."
3+
description: "Gecode architecture, modeling, cookbook-style modeling patterns, set/float/scheduling guidance, propagators, branchers, memory management, search engine usage and implementation, recomputation/cloning behavior, debugging/performance diagnosis, and downstream CMake consumption. Use for any materially Gecode-specific task: building or refining Gecode models, implementing custom constraints or branchers, tuning DFS/BAB/RBS/PBS/LDS search, diagnosing weak propagation or search pathologies, reasoning about set/float/resource-style models, or integrating Gecode into CMake projects."
44
---
55

66
# Gecode
@@ -47,6 +47,7 @@ Use this skill as the entry point for any Gecode-specific task. Carry the univer
4747
- Read `references/memory-handling.md` for space/region/heap allocation, handles, clone footprint, and disposal obligations.
4848
- Read `references/search-engines.md` for using and tuning built-in engines such as `DFS`, `BAB`, `LDS`, restart, and portfolio search.
4949
- Read `references/search-engine-implementation.md` for custom engine orchestration, recomputation strategy, LAO, and completeness invariants.
50+
- Read `references/cmake-consumption.md` for `find_package(Gecode CONFIG)`, target usage, version checks, and vendored fallback patterns.
5051
- Read `references/general-knowledge.md` only for broad conceptual explanations, tracing/observability guidance, or staged model-improvement workflow discussion that goes beyond the always-on mental model.
5152

5253
## Operating Rules
@@ -68,3 +69,4 @@ Use this skill as the entry point for any Gecode-specific task. Carry the univer
6869
- `references/memory-handling.md`: memory areas, lazy vs eager allocation, shared/local handles, and `AP_DISPOSE` discipline.
6970
- `references/search-engines.md`: engine selection, restart/portfolio tradeoffs, no-goods, parallel semantics, and completeness caveats.
7071
- `references/search-engine-implementation.md`: custom engine state, replay/recomputation, ownership, branch-and-bound integration, and invariants.
72+
- `references/cmake-consumption.md`: package-config integration, exported targets, component selection, and fetch fallback.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Gecode CMake Consumption
2+
3+
## Core
4+
- Prefer config-package consumption: `find_package(Gecode CONFIG REQUIRED)`.
5+
- Link downstream targets to `Gecode::gecode` unless explicit component granularity is required.
6+
- Require `Gecode_VERSION >= 6.3.0` and use package version checks rather than parsing `gecode/support/config.hpp`.
7+
- Hint package location with `Gecode_ROOT` or `CMAKE_PREFIX_PATH`.
8+
- Keep `cmake_minimum_required(VERSION 3.21)` or newer for parity with Gecode's build.
9+
10+
## Key Patterns
11+
- Minimal integration:
12+
```cmake
13+
find_package(Gecode CONFIG REQUIRED)
14+
target_link_libraries(app PRIVATE Gecode::gecode)
15+
```
16+
- Component-specific integration:
17+
```cmake
18+
find_package(Gecode CONFIG REQUIRED COMPONENTS driver)
19+
target_link_libraries(app PRIVATE Gecode::gecodedriver)
20+
```
21+
- Version guard:
22+
```cmake
23+
if(SOME_STRICT_OPTION AND Gecode_VERSION VERSION_LESS "6.3.0")
24+
message(FATAL_ERROR "Gecode >= 6.3.0 required, found ${Gecode_VERSION}")
25+
endif()
26+
```
27+
- Try installed package first with `find_package(Gecode CONFIG QUIET)` when discovery is optional.
28+
- If the package is absent and project policy allows vendoring, use `FetchContent` and set Gecode cache options before `FetchContent_MakeAvailable(...)`.
29+
- Require `TARGET Gecode::gecode` after resolution and fail fast with actionable error text if it is missing.
30+
- Mark Gecode targets as `SYSTEM` in strict-warning projects to isolate third-party headers from local warning policy.
31+
- For pinned source fallbacks, prefer stable release tags or commits over long-lived feature branches.
32+
- When migrating away from custom discovery modules, remove manual imported-target composition and library probing once package config is the baseline.
33+
- Keep strict version toggles if desired, but enforce them against `Gecode_VERSION`.
34+
35+
## Pitfalls
36+
- Calling `find_package(Gecode REQUIRED)` without `CONFIG` and accidentally resolving old module-mode shims.
37+
- Assuming optional components exist without checking enabled modules in the installed build.
38+
- Mixing custom imported-target composition with package-provided targets in the same code path.
39+
- Parsing headers for version when package metadata already provides `Gecode_VERSION`.

0 commit comments

Comments
 (0)