Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. CMake
  3. package-example

package-example

CMake

Example project demonstrating CMake's find_package config mode for building and consuming libraries with different build types.

GitHubGitHub
406 stars56 forks0 contributors

What is package-example?

Package Example is a demonstration project that shows how to properly use CMake's `find_package` command in config mode. It provides working examples of creating installable libraries with Debug and Release variants, generating CMake package configuration files, and consuming those libraries in downstream projects. The project solves the problem of understanding how to structure CMake projects for proper package distribution and consumption.

Target Audience

CMake users and C++ developers who need to create reusable libraries or consume third-party libraries with proper build variant support. This is particularly useful for developers working on multi-configuration build systems or distributing libraries to other teams.

Value Proposition

Developers choose this project because it provides clear, working examples of complex CMake package management concepts that are often poorly documented. It demonstrates best practices for handling build variants, version compatibility, and package discovery in real-world scenarios.

Overview

CMake: config mode of find_package command (examples)

Use Cases

Best For

  • Learning how CMake's find_package config mode works
  • Creating installable libraries with Debug and Release variants
  • Understanding CMake package configuration file generation
  • Setting up proper dependency management between CMake projects
  • Implementing version compatibility checks for CMake packages
  • Debugging issues with multi-configuration library consumption

Not Ideal For

  • Teams using non-CMake build systems like Bazel or Meson
  • Projects requiring a full-featured package manager with automatic dependency fetching
  • Developers who need extensive tutorials or GUI tools for CMake beginners
  • Large-scale applications with complex, cross-platform dependency chains

Pros & Cons

Pros

Clear Build Variant Handling

Demonstrates precise installation of Debug and Release libraries with proper naming conventions (e.g., libbar.a vs libbard.a) and configuration files, as shown in the step-by-step commands.

Automatic Dependency Resolution

Shows how find_package automatically sets include directories, defines (like FOO_BAR_DEBUG), and links the correct library based on build type, reducing manual CMake scripting.

Version Compatibility Checks

Includes examples of version validation via FooConfigVersion.cmake, which rejects incompatible requests (e.g., version 2.0 when 1.2.3 is installed), ensuring package integrity.

Flexible Package Discovery

Illustrates multiple ways to locate packages using CMAKE_INSTALL_PREFIX, CMAKE_PREFIX_PATH, or Foo_DIR, providing adaptability for different development environments.

Cons

Limited Real-World Coverage

As a demonstration project, it focuses on basic scenarios and omits advanced topics like cross-compilation, shared libraries beyond monolithic builds, or integration with CI/CD pipelines beyond simple scripts.

Assumes CMake Proficiency

The README lacks explanations for CMake novices, assuming familiarity with command-line flags (e.g., -H, -B) and concepts, which can be a barrier for learners.

No Production-Ready Tooling

It doesn't provide a packaged solution or ecosystem support; users must adapt the examples manually, which can be time-consuming for complex projects compared to using dedicated package managers.

Frequently Asked Questions

Quick Stats

Stars406
Forks56
Contributors0
Open Issues0
Last commit5 years ago
CreatedSince 2014

Tags

#library-management#example-project#dependency-management#example#cmake#build-system#cplusplus#package-management

Built With

C
CMake
M
Makefile

Included in

CMake5.4k
Auto-fetched 8 hours ago

Related Projects

cmake-examplescmake-examples

Useful CMake Examples

Stars13,072
Forks2,527
Last commit2 years ago
ModernCppStarterModernCppStarter

🚀 Kick-start your C++! A template for modern C++ projects using CMake, CI, code coverage, clang-format, reproducible dependency management and much more.

Stars5,382
Forks492
Last commit1 month ago
cmake-cookbookcmake-cookbook

CMake Cookbook recipes.

Stars2,850
Forks713
Last commit5 years ago
pitchforkpitchfork

Pitchfork is a Set of C++ Project Conventions

Stars1,255
Forks64
Last commit2 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub