Skip to content

build(cmake)!: Add support for installation and usage as a library in other CMake projects; Add example project to test this use case.#65

Merged
davidlion merged 108 commits into
y-scope:mainfrom
PacificViking:main
Jun 25, 2025
Merged

build(cmake)!: Add support for installation and usage as a library in other CMake projects; Add example project to test this use case.#65
davidlion merged 108 commits into
y-scope:mainfrom
PacificViking:main

Conversation

@PacificViking
Copy link
Copy Markdown
Contributor

@PacificViking PacificViking commented May 26, 2025

Description

Previously, users of ystdlib needed to use it through add_subdirectory. This PR updates ystdlib to allow installing selected ystdlib libraries and using them through find_package.

When building ystdlib the user can define the CMake variable ystdlib_LIBRARIES with a semicolon separated list of ystdlib library names to build (if omitted all libraries are built). Then when cmake --install is run all built libraries will be installed and configured to work with find_package.

For ystdlib_LIBRARIES, if a user lists a ystdlib library that depends on another ystdlib not listed that dependent library will be added to the list and built.

This PR also adds an examples/ directory containing an example CMake project to:

  1. show users how to use ystdlib in their CMake project.
  2. test a CMake project can successfully use an installation of ystdlib.

Support for using COMPONENTS with find_package to selectively depend on (installed) libraries is deferred to a future PR.

This PR sets the minimum version of CMake to 3.23 to add support for FILE_SETS.

Checklist

  • The PR satisfies the [contribution guidelines][yscope-contrib-guidelines].
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Test cases still pass. Example builds and passes by manually running the following commands:

cmake -S . -B build/
cmake --build build/
cmake --install "./build" --prefix "./build/examples/ystdlib
cmake -S "./examples" -B "./build/examples" -Dystdlib_ROOT="./build/examples/ystdlib"
cmake --build build/examples/
./build/examples/linking-tests


[yscope-contrib-guidelines]: https://docs.yscope.com/dev-guide/contrib-guides-overview.html


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
	- Added example programs and documentation demonstrating how to link and use all ystdlib library components.
	- Introduced comprehensive CMake installation and package configuration support, enabling `find_package(ystdlib)` integration.
	- Added new CMake helper scripts for streamlined library creation, testing, and installation.

- **Enhancements**
	- Unified build and variable naming conventions across CMake files for consistency.
	- Made the set of libraries to build configurable via a single variable.
	- Improved modularity and clarity in build configuration for all library components.
	- Updated minimum CMake version requirement to 3.23.
	- Replaced Boost dependency handling with refined package find commands.

- **Bug Fixes**
	- Prevented duplicate target definitions in build scripts.

- **Documentation**
	- Updated and expanded README files with installation, usage, and testing instructions.

- **Chores**
	- Updated build, lint, and task configuration files to reflect new structure and naming.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants