diff --git a/README.md b/README.md index 140f294..70d6616 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ The skill routes internally to focused reference documents for: - memory management - built-in search engines - custom search engine implementation +- downstream CMake consumption ## Contributing diff --git a/evals/gecode-trigger-evals.json b/evals/gecode-trigger-evals.json index f2931dd..664b4ad 100644 --- a/evals/gecode-trigger-evals.json +++ b/evals/gecode-trigger-evals.json @@ -15,6 +15,10 @@ "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.", "should_trigger": true }, + { + "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.", + "should_trigger": true + }, { "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.", "should_trigger": true @@ -35,6 +39,10 @@ "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?", "should_trigger": true }, + { + "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.", + "should_trigger": false + }, { "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.", "should_trigger": false @@ -47,6 +55,10 @@ "query": "Can you explain branch and bound versus depth-first search in general terms? I don't need implementation details for any particular library.", "should_trigger": false }, + { + "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.", + "should_trigger": false + }, { "query": "What are good heuristics for graph coloring in CP, and how do I think about symmetry? Solver-agnostic advice is fine.", "should_trigger": false diff --git a/skills/gecode/SKILL.md b/skills/gecode/SKILL.md index 464f6bc..a792f20 100644 --- a/skills/gecode/SKILL.md +++ b/skills/gecode/SKILL.md @@ -1,6 +1,6 @@ --- name: gecode -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." +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." --- # Gecode @@ -47,6 +47,7 @@ Use this skill as the entry point for any Gecode-specific task. Carry the univer - Read `references/memory-handling.md` for space/region/heap allocation, handles, clone footprint, and disposal obligations. - Read `references/search-engines.md` for using and tuning built-in engines such as `DFS`, `BAB`, `LDS`, restart, and portfolio search. - Read `references/search-engine-implementation.md` for custom engine orchestration, recomputation strategy, LAO, and completeness invariants. +- Read `references/cmake-consumption.md` for `find_package(Gecode CONFIG)`, target usage, version checks, and vendored fallback patterns. - 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. ## Operating Rules @@ -68,3 +69,4 @@ Use this skill as the entry point for any Gecode-specific task. Carry the univer - `references/memory-handling.md`: memory areas, lazy vs eager allocation, shared/local handles, and `AP_DISPOSE` discipline. - `references/search-engines.md`: engine selection, restart/portfolio tradeoffs, no-goods, parallel semantics, and completeness caveats. - `references/search-engine-implementation.md`: custom engine state, replay/recomputation, ownership, branch-and-bound integration, and invariants. +- `references/cmake-consumption.md`: package-config integration, exported targets, component selection, and fetch fallback. diff --git a/skills/gecode/references/cmake-consumption.md b/skills/gecode/references/cmake-consumption.md new file mode 100644 index 0000000..6e59642 --- /dev/null +++ b/skills/gecode/references/cmake-consumption.md @@ -0,0 +1,39 @@ +# Gecode CMake Consumption + +## Core +- Prefer config-package consumption: `find_package(Gecode CONFIG REQUIRED)`. +- Link downstream targets to `Gecode::gecode` unless explicit component granularity is required. +- Require `Gecode_VERSION >= 6.3.0` and use package version checks rather than parsing `gecode/support/config.hpp`. +- Hint package location with `Gecode_ROOT` or `CMAKE_PREFIX_PATH`. +- Keep `cmake_minimum_required(VERSION 3.21)` or newer for parity with Gecode's build. + +## Key Patterns +- Minimal integration: + ```cmake + find_package(Gecode CONFIG REQUIRED) + target_link_libraries(app PRIVATE Gecode::gecode) + ``` +- Component-specific integration: + ```cmake + find_package(Gecode CONFIG REQUIRED COMPONENTS driver) + target_link_libraries(app PRIVATE Gecode::gecodedriver) + ``` +- Version guard: + ```cmake + if(SOME_STRICT_OPTION AND Gecode_VERSION VERSION_LESS "6.3.0") + message(FATAL_ERROR "Gecode >= 6.3.0 required, found ${Gecode_VERSION}") + endif() + ``` +- Try installed package first with `find_package(Gecode CONFIG QUIET)` when discovery is optional. +- If the package is absent and project policy allows vendoring, use `FetchContent` and set Gecode cache options before `FetchContent_MakeAvailable(...)`. +- Require `TARGET Gecode::gecode` after resolution and fail fast with actionable error text if it is missing. +- Mark Gecode targets as `SYSTEM` in strict-warning projects to isolate third-party headers from local warning policy. +- For pinned source fallbacks, prefer stable release tags or commits over long-lived feature branches. +- When migrating away from custom discovery modules, remove manual imported-target composition and library probing once package config is the baseline. +- Keep strict version toggles if desired, but enforce them against `Gecode_VERSION`. + +## Pitfalls +- Calling `find_package(Gecode REQUIRED)` without `CONFIG` and accidentally resolving old module-mode shims. +- Assuming optional components exist without checking enabled modules in the installed build. +- Mixing custom imported-target composition with package-provided targets in the same code path. +- Parsing headers for version when package metadata already provides `Gecode_VERSION`.