Skip to content

Commit 0e4440a

Browse files
committed
Add cmake consumption skill
1 parent 4781ddc commit 0e4440a

4 files changed

Lines changed: 53 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ npx skills add Gecode/gecode-skills --skill gecode-modeling
2323
## Available Skills
2424

2525
- `gecode-general-knowledge`
26+
- `gecode-cmake-consumption`
2627
- `gecode-modeling`
2728
- `gecode-propagator-implementation`
2829
- `gecode-brancher-implementation`
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: gecode-cmake-consumption
3+
description: "Consume Gecode from CMake using exported package config (`find_package(Gecode CONFIG)`), aggregate/component targets, version checks, and source-fetch fallback patterns. Use when integrating Gecode into downstream CMake projects or migrating custom `FindGecode.cmake` logic. Assume Gecode 6.3.0 or newer."
4+
---
5+
6+
# Gecode CMake Consumption
7+
8+
## Core
9+
- Prefer config-package consumption: `find_package(Gecode CONFIG REQUIRED)`.
10+
- Link downstream targets to `Gecode::gecode` unless explicit component granularity is required.
11+
- Require `Gecode_VERSION >= 6.3.0`; use package version checks rather than parsing `gecode/support/config.hpp`.
12+
- Hint package location with `Gecode_ROOT` or `CMAKE_PREFIX_PATH`.
13+
- Keep `cmake_minimum_required(VERSION 3.21)` or newer for parity with Gecode's build.
14+
15+
## Canonical Patterns
16+
- Minimal integration:
17+
```cmake
18+
find_package(Gecode CONFIG REQUIRED)
19+
target_link_libraries(app PRIVATE Gecode::gecode)
20+
```
21+
- Component-specific integration:
22+
```cmake
23+
find_package(Gecode CONFIG REQUIRED COMPONENTS driver)
24+
target_link_libraries(app PRIVATE Gecode::gecodedriver)
25+
```
26+
- Version guard:
27+
```cmake
28+
if(SOME_STRICT_OPTION AND Gecode_VERSION VERSION_LESS "6.3.0")
29+
message(FATAL_ERROR "Gecode >= 6.3.0 required, found ${Gecode_VERSION}")
30+
endif()
31+
```
32+
33+
## Dependency Resolution Workflow
34+
- Try installed package first via `find_package(Gecode CONFIG QUIET)` when optional discovery is desired.
35+
- If not found and project policy allows vendoring, use `FetchContent` to obtain Gecode source and call `FetchContent_MakeAvailable(...)`.
36+
- Set Gecode cache options before `FetchContent_MakeAvailable(...)` to limit dependency surface (for example disable `GECODE_ENABLE_GIST`, examples, tests, or optional modules).
37+
- Require `TARGET Gecode::gecode` after resolution; fail fast with actionable error text if absent.
38+
- Mark Gecode target as `SYSTEM` in strict-warning projects to isolate third-party headers from local warning policy.
39+
- For source-pinned fallback builds, prefer stable release tags or commits over long-lived feature branches.
40+
- For migration away from custom discovery modules, remove manual imported-target composition and library probing once package config is the baseline path.
41+
- Keep strict-version toggles if desired, but enforce them against `Gecode_VERSION`.
42+
43+
## Pitfalls
44+
- Calling `find_package(Gecode REQUIRED)` without `CONFIG` and accidentally resolving old/module-mode shims.
45+
- Assuming optional components exist without checking enabled modules in the installed build.
46+
- Mixing custom imported-target composition with package-provided targets in the same code path.
47+
- Parsing headers for version when package metadata already provides `Gecode_VERSION`.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface:
2+
display_name: "Gecode CMake Consumption"
3+
short_description: "Integrate Gecode via CMake package config"
4+
default_prompt: "Guide downstream CMake integration with Gecode package exports, version checks (>= 6.3.0), and migration from custom FindGecode logic."

skills/gecode-general-knowledge/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ description: "Core Gecode architecture and runtime model: spaces, propagators, b
66
# Gecode General Knowledge
77

88
## Related Skills
9+
- Use `gecode-cmake-consumption` for downstream CMake integration, package consumption, and migration from custom `FindGecode` logic.
910
- Use `gecode-modeling` for modeling choices, globals, branchings, symmetry handling, and search setup.
1011
- Use `gecode-propagator-implementation` for custom propagator design, posting, propagation lifecycle, and optimization.
1112
- Use `gecode-brancher-implementation` for custom branchers, choice/commit mechanics, and no-good literal support.

0 commit comments

Comments
 (0)