bobluppes / bobluppes/graaf

Add CMake package config files for find_package(Graaf CONFIG) support

Open
#329 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
413
Forks
67
Avg merge
7h 24m
Merged PRs (30d)
53

Description

## Summary

Graaf can currently be consumed via `FetchContent`, but there is no installed CMake package config (`GraafConfig.cmake` / `GraafConfigVersion.cmake`), so `find_package(Graaf CONFIG REQUIRED)` does not work against an installed copy of the library.

## Current state

Looking at [CMakeLists.txt](../blob/main/CMakeLists.txt):

- The interface target `Graaf::Graaf` is only defined via `add_library(... INTERFACE)` + `ALIAS`, and is exported for in-tree/`FetchContent` use, but there is no `install(TARGETS ... EXPORT ...)` / `install(EXPORT ...)` step.
- `install()` only copies the `include/` directory and generates a `graaf.pc` pkg-config file (`packaging/graaf.pc.in`).
- There is no `GraafConfig.cmake.in`, no `write_basic_package_version_file()` call, and no versioned `GraafConfigVersion.cmake`.

As a result, once Graaf is installed system-wide (e.g. via a package manager, `cmake --install`, or a Conan/vcpkg-style port), downstream projects that use `find_package(Graaf CONFIG REQUIRED)` and `target_link_libraries(app PRIVATE Graaf::Graaf)` — the idiomatic modern-CMake pattern — will fail to locate the package, even though the pkg-config file works for non-CMake or pkg-config-based consumers.

## Why this matters

Modern C++ build systems (CMake package managers, internal artifact repositories, vcpkg/Conan integrations) rely on `find_package()` with proper CMake config packages rather than pkg-config alone. Without this, integrating Graaf into an existing CMake-based build — especially in larger, multi-dependency projects — requires extra glue code or falls back to manually setting include paths.

## Suggested resolution

- Add a `GraafConfig.cmake.in` template and use `configure_package_config_file()` (from `CMakePackageConfigHelpers`).
- Generate a `GraafConfigVersion.cmake` with `write_basic_package_version_file()`, using semantic version compatibility (see also the related versioning issue).
- Add `install(TARGETS ${GRAAF_LIB_TARGET_NAME} EXPORT GraafTargets)` and `install(EXPORT GraafTargets ... NAMESPACE Graaf:: ...)`.
- Verify with a small integration test/example that does `find_package(Graaf CONFIG REQUIRED)` against a `cmake --install`'d tree.

## Acceptance criteria

- [ ] `cmake --install` produces a package that can be located via `find_package(Graaf CONFIG REQUIRED)`.
- [ ] `Graaf::Graaf` remains usable as the link target after install, matching current `FetchContent` behavior.
- [ ] Installation docs are updated to document this consumption method alongside the existing `FetchContent` and manual-copy instructions.

Contributor guide

Open the contributing guide

Research direction

The main CMakeLists.txt file defines the interface target Graaf::Graaf. Start by reading CMake's documentation on install(EXPORT) and configure_package_config_file. Create a GraafConfig.cmake.in template and integrate the package config helpers. Test by building, installing, and then using find_package in a separate test project to verify the target is found and works.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.