Skip to content

Conversation

@PacificViking
Copy link
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 -->

@PacificViking PacificViking requested a review from a team as a code owner May 26, 2025 19:03
@coderabbitai
Copy link

coderabbitai bot commented May 26, 2025

Walkthrough

This update restructures the ystdlib project’s CMake build system and installation infrastructure. It introduces new helper functions, unifies variable naming, removes Boost as a mandatory dependency, modularizes library and test target creation, and adds comprehensive CMake package configuration and installation logic. Example programs and documentation are updated to reflect the new workflow.

Changes

File(s) Change Summary
CMakeLists.txt, src/ystdlib/CMakeLists.txt, src/ystdlib/*/CMakeLists.txt Refactored to use new lowercase variable naming, modular library/test target creation via add_cpp_library and add_catch2_tests, removed explicit Boost dependency, added package installation/configuration logic, and made library inclusion list-driven.
cmake/ystdlib-helpers.cmake Added new CMake helper functions/macros for library, test, and installation management with argument validation and header-only detection.
cmake/ystdlib/ystdlib-config.cmake.in, cmake/ystdlib/libs/*-config.cmake.in Added CMake package config templates for ystdlib and its libraries, enabling proper find_package() support and dependency resolution.
README.md, examples/README.md Updated documentation to reflect new project name, installation workflow, usage via find_package(), and revised build/test instructions.
examples/CMakeLists.txt, examples/src/linking-tests.cpp Added example program and build configuration to demonstrate correct installation and linking of all ystdlib libraries.
.gersemirc, taskfile.yaml, taskfiles/lint-cmake.yaml Updated paths and patterns to match new helper/config files and settings.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CMake
    participant ystdlib-config
    participant LibraryConfig
    participant Target

    User->>CMake: find_package(ystdlib REQUIRED)
    CMake->>ystdlib-config: Load ystdlib-config.cmake
    ystdlib-config->>LibraryConfig: For each LIB in ystdlib_LIBRARIES, include libs/LIB-config.cmake
    LibraryConfig->>Target: Define or import ystdlib::LIB target
    ystdlib-config->>CMake: check_required_components(ystdlib)
    CMake-->>User: ystdlib targets available
Loading

Possibly related PRs

  • y-scope/ystdlib-cpp#45: Improves dependency linking and error handling for header-only libraries in the same helper script now refactored in this PR.
  • y-scope/ystdlib-cpp#44: Introduces argument validation and modular test linking in CMake helper functions, related to the modularization seen here.
  • y-scope/ystdlib-cpp#28: Ports the error_handling library and its unit tests into ystdlib, complementing the build and packaging refactor in this PR.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🔭 Outside diff range comments (1)
CMakeLists.txt (1)

62-67: ⚠️ Potential issue

Link to outcome is missing.

You find_package(outcome REQUIRED) but do not actually link it into ystdlib. Without:

target_link_libraries(ystdlib PUBLIC outcome::outcome)

downstream consumers will miss this dependency. Please uncomment or add the correct link command.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3fc980 and 4aa941c.

📒 Files selected for processing (2)
  • CMake/ystdlib-config.cmake.in (1 hunks)
  • CMakeLists.txt (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
CMakeLists.txt (1)
Learnt from: Bill-hbrhbr
PR: y-scope/ystdlib-cpp#32
File: CMakeLists.txt:0-0
Timestamp: 2025-02-28T05:04:33.616Z
Learning: The y-scope/ystdlib-cpp project uses the "YSTDLIB_CPP_" prefix for project-specific CMake variables, following good naming convention practices.
🔇 Additional comments (18)
CMake/ystdlib-config.cmake.in (3)

1-4: Proper initialization of CMake package config.

Including CMakeFindDependencyMacro and invoking @PACKAGE_INIT@ is exactly what downstream consumers need to locate this package.


17-20: Correctly set and verify include directory and components.

Using set_and_check and check_required_components aligns with best practices in CMakePackageConfigHelpers.


21-24: Guard for multiple inclusion of targets file.

The if(NOT TARGET ystdlib::ystdlib) wrap prevents duplicate imports—this is spot on.

CMakeLists.txt (15)

4-7: Module path and helper includes are correct.

Appending CMake/ to CMAKE_MODULE_PATH and including ystdlib-cpp-helpers, CMakePackageConfigHelpers, and GNUInstallDirs is necessary for the later package‐config steps.


16-18: Build options follow established convention.

Defining BUILD_SHARED_LIBS and YSTDLIB_CPP_BUILD_TESTING is clear and consistent.


41-46: Export of compile commands is intentional.

Enabling CMAKE_EXPORT_COMPILE_COMMANDS with FORCE is useful for IDE integration and static analysis.


48-56: Top‐level dependency settings are correct.

Conditionally including your dependency settings and CTest only when this is the top‐level project is exactly right.


58-61: Test‐enable logic is clear.

Mapping BUILD_TESTING and YSTDLIB_CPP_BUILD_TESTING to YSTDLIB_CPP_ENABLE_TESTS is straightforward.


69-90: Catch2 test setup looks good.

All testing machinery (finding Catch2, setting up unified test target) is correctly gated by YSTDLIB_CPP_ENABLE_TESTS.


93-95: Installation directory variables are well defined.

YSTDLIB_INSTALL_CONFIG_DIR and YSTDLIB_INSTALL_INCLUDE_DIR correctly map to lib/cmake/ystdlib and the chosen include directory.


123-124: Linker language explicitly set.

Specifying LINKER_LANGUAGE CXX is correct for a C++ library.


132-137: Installation of the library target is correct.

Exporting ystdlib as ystdlib-targets is aligned with CMake package guidelines.


139-146: Export namespace and destination are set properly.

Using NAMESPACE ystdlib:: ensures downstream find_package(ystdlib) works as intended.


148-157: Header installation looks good.

Copying *.h, *.hpp, and *.tpp from src/ystdlib is appropriate.


159-166: Package configuration generation is correct.

The call to configure_package_config_file with PATH_VARS YSTDLIB_INSTALL_INCLUDE_DIR matches the template.


168-172: Version file creation is correct.

Using SameMajorVersion compatibility is sensible for a 0.x library.


174-180: Config files are installed to the right location.

Installing both the config and version files under ${YSTDLIB_INSTALL_CONFIG_DIR} enables clean downstream find_package.


182-183: Verify no source duplication via add_subdirectory.

You glob all sources under src/ to create ystdlib, then add src/ystdlib again as a subdirectory. This can lead to duplicate targets or conflicting CMakeLists. Please confirm whether add_subdirectory(src/ystdlib) is still required in this context.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 662e768 and 93c4d50.

📒 Files selected for processing (1)
  • src/ystdlib/error_handling/test/test_ErrorCode.cpp (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • src/ystdlib/error_handling/test/test_ErrorCode.cpp

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (3)
CMakeLists.txt (3)

11-14: 🛠️ Refactor suggestion

Inconsistent project name vs package name
The project is declared as YSTDLIB_CPP but all install paths and the export namespace use ystdlib. This mismatch can confuse downstream users calling find_package(ystdlib). Consider renaming the project to ystdlib (or vice versa) to align naming.

Apply this diff:

- project(YSTDLIB_CPP
+ project(ystdlib
     VERSION "${YSTDLIB_CPP_VERSION}"
     LANGUAGES CXX
 )

113-115: 🛠️ Refactor suggestion

Propagate C++20 requirement to consumers
PRIVATE cxx_std_20 hides the C++ standard requirement from downstream targets. Change to PUBLIC cxx_std_20 so any project linking against ystdlib will also compile with C++20.

-target_compile_features(ystdlib
-    PRIVATE cxx_std_20
-)
+target_compile_features(ystdlib
+    PUBLIC cxx_std_20
+)

96-102: ⚠️ Potential issue

Regex for excluding test files is incorrect
The current regex ".*test_*\..*" does not properly match filenames like test_foo.cpp. Update to:

- list(FILTER SOURCE_FILES EXCLUDE REGEX ".*test_*\..*")
+ list(FILTER SOURCE_FILES EXCLUDE REGEX ".*test_.*\\..*")

This ensures any file starting with test_ is filtered out.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93c4d50 and 0a88c49.

📒 Files selected for processing (1)
  • CMakeLists.txt (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Bill-hbrhbr
PR: y-scope/ystdlib-cpp#32
File: CMakeLists.txt:0-0
Timestamp: 2025-02-28T05:04:33.616Z
Learning: The y-scope/ystdlib-cpp project uses the "YSTDLIB_CPP_" prefix for project-specific CMake variables, following good naming convention practices.
CMakeLists.txt (1)
Learnt from: Bill-hbrhbr
PR: y-scope/ystdlib-cpp#32
File: CMakeLists.txt:0-0
Timestamp: 2025-02-28T05:04:33.616Z
Learning: The y-scope/ystdlib-cpp project uses the "YSTDLIB_CPP_" prefix for project-specific CMake variables, following good naming convention practices.
🔇 Additional comments (8)
CMakeLists.txt (8)

4-7: Good addition of CMake helper modules
Appending the local CMake directory to CMAKE_MODULE_PATH and including CMakePackageConfigHelpers and GNUInstallDirs correctly equips the project for package configuration and standard install-directory variables.


104-106: Correct creation of library and alias
The add_library(ystdlib ${SOURCE_FILES}) and the subsequent alias add_library(ystdlib::ystdlib ALIAS ystdlib) properly define both the target and its public namespace.


107-112: Include directories are well defined
Using PUBLIC $<BUILD_INTERFACE:…> and PUBLIC $<INSTALL_INTERFACE:…> sets up clean include paths for both build-time and install-time usage.


126-133: Export namespace installation is correct
The install(EXPORT ystdlib-targets NAMESPACE ystdlib:: DESTINATION ${YSTDLIB_INSTALL_CONFIG_DIR}) ensures downstream find_package(ystdlib) can locate your targets.


135-144: Header installation matches expectations
Installing the src/ystdlib directory with FILES_MATCHING patterns for .h, .hpp, and .tpp correctly delivers public headers.


146-153: Package config generation is correct
The configure_package_config_file invocation properly generates ystdlib-config.cmake for downstream consumers to locate dependencies and targets.


155-159: Version file generation is correct
The write_basic_package_version_file with SameMajorVersion provides necessary version compatibility semantics.


161-167: Installation of generated config files is correct
Installing both the config and version files into ${YSTDLIB_INSTALL_CONFIG_DIR} completes the package setup for find_package.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (4)
CMakeLists.txt (4)

120-120: 🧹 Nitpick (assertive)

Specify explicit install destinations
It’s best practice to define explicit destinations for archives, shared libraries, and executables in install(TARGETS ...) to ensure consistent install layouts across platforms. For example:

 install(TARGETS ystdlib EXPORT ystdlib-targets
-)
+    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)

111-111: ⚠️ Potential issue

Propagate C++20 requirement to consumers
The current visibility is PRIVATE, which hides the C++20 requirement from downstream targets and may lead to compilation errors in client code. Change to PUBLIC so that any project linking against ystdlib also uses C++20:

- target_compile_features(ystdlib PRIVATE cxx_std_20)
+ target_compile_features(ystdlib PUBLIC  cxx_std_20)

124-135: 🛠️ Refactor suggestion

Update include install path variable
After renaming to YSTDLIB_CPP_INSTALL_INCLUDE_DIR, update the install(DIRECTORY ...) call accordingly to maintain consistency:

-    DESTINATION "${YSTDLIB_INSTALL_INCLUDE_DIR}"
+    DESTINATION "${YSTDLIB_CPP_INSTALL_INCLUDE_DIR}"

99-99: ⚠️ Potential issue

Fix test file exclusion regex
The current regex ".*test_*\..*" does not exclude files like test_foo.cpp (the * quantifier applies to _, and the \. is placed too early). Update to properly filter out any file beginning with test_. For example:

- list(FILTER SOURCE_FILES EXCLUDE REGEX ".*test_*\\..*")
+ list(FILTER SOURCE_FILES EXCLUDE REGEX ".*test_.*\\..*")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a88c49 and e4dc708.

📒 Files selected for processing (1)
  • CMakeLists.txt (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Bill-hbrhbr
PR: y-scope/ystdlib-cpp#32
File: CMakeLists.txt:0-0
Timestamp: 2025-02-28T05:04:33.616Z
Learning: The y-scope/ystdlib-cpp project uses the "YSTDLIB_CPP_" prefix for project-specific CMake variables, following good naming convention practices.
CMakeLists.txt (1)
Learnt from: Bill-hbrhbr
PR: y-scope/ystdlib-cpp#32
File: CMakeLists.txt:0-0
Timestamp: 2025-02-28T05:04:33.616Z
Learning: The y-scope/ystdlib-cpp project uses the "YSTDLIB_CPP_" prefix for project-specific CMake variables, following good naming convention practices.
🔇 Additional comments (8)
CMakeLists.txt (8)

5-6: Include modules for package configuration and standard dirs
Including CMakePackageConfigHelpers and GNUInstallDirs is correct and necessary to support configure_package_config_file, version file generation, and standard installation directory variables.


92-98: Enable reconfigure on new sources
Using CONFIGURE_DEPENDS with file(GLOB_RECURSE ...) is good practice, as it triggers CMake reconfiguration when source files are added or removed.


101-102: Define library and alias target
The add_library(ystdlib ${SOURCE_FILES}) and alias add_library(ystdlib::ystdlib ALIAS ystdlib) are correctly configured for downstream CMake consumption.


104-109: Expose include directories properly
Setting the include directories as PUBLIC with BUILD_INTERFACE and INSTALL_INTERFACE is the right approach to ensure consumers see the correct headers both in-tree and from an installed package.


122-122: Export namespace installation
Installing the export under the ystdlib:: namespace correctly aligns the build-tree and install-tree usage for find_package(ystdlib).


137-143: Configure package config file
The use of configure_package_config_file with ystdlib-config.cmake.in and specifying PATH_VARS for the include dir is correctly set up for downstream package discovery.


145-148: Write package version file
Generating the version file with SameMajorVersion compatibility ensures consumers can check version constraints appropriately.


150-155: Install package config files
Installing both ystdlib-config.cmake and ystdlib-config-version.cmake into the config directory completes the exported CMake package layout.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (2)
CMake/ystdlib-config.cmake.in (2)

7-9: Pin Catch2 version in find_dependency
Please propagate the Catch2 version to downstream by specifying:

-if(@Catch2_FOUND@)
-    find_dependency(Catch2)
+if(@Catch2_FOUND@)
+    find_dependency(Catch2 @Catch2_VERSION@ REQUIRED)
endif()

11-13: Pin outcome version in find_dependency
Similarly, include the outcome version constraint:

-if(@outcome_FOUND@)
-    find_dependency(outcome)
+if(@outcome_FOUND@)
+    find_dependency(outcome @outcome_VERSION@ REQUIRED)
endif()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4dc708 and a3bc9d5.

📒 Files selected for processing (1)
  • CMake/ystdlib-config.cmake.in (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: Bill-hbrhbr
PR: y-scope/ystdlib-cpp#32
File: CMakeLists.txt:0-0
Timestamp: 2025-02-28T05:04:33.616Z
Learning: The y-scope/ystdlib-cpp project uses the "YSTDLIB_CPP_" prefix for project-specific CMake variables, following good naming convention practices.
🔇 Additional comments (3)
CMake/ystdlib-config.cmake.in (3)

5-6: Initialise package version correctly
The @PACKAGE_INIT@ placeholder should remain directly after the include directives to load the version file and initialize the package.


17-17: Verify required components specification
Confirm that check_required_components(ystdlib) enforces the correct set of components. If your library defines named components (e.g., Core, Extras), consider listing them explicitly:

check_required_components(ystdlib Core Extras)

23-23: Re-enable gersemi linting
The # gersemi: on directive correctly resumes linting for downstream edits.

@Bill-hbrhbr Bill-hbrhbr self-requested a review June 5, 2025 10:40
@sitaowang1998
Copy link

Create a sample project to verify that the installed package actually works.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 16

🔭 Outside diff range comments (1)
examples/README.md (1)

1-10: 🛠️ Refactor suggestion

Improve documentation structure and clarity

The README has several issues that affect usability:

  1. Missing proper markdown heading structure
  2. Grammatical errors and unclear phrasing
  3. Fragmented instructions without sufficient context
+# ystdlib-cpp Examples
+
+This directory contains examples demonstrating how to use ystdlib-cpp as an installed CMake package.
+
+## Prerequisites
+
+Build and install the main ystdlib-cpp project first:
+
+```bash
+# From the project root
+mkdir build && cd build
-cmake ..
-
-Run above command from examples/build
-
-Dependencies:
-
-After building main project, cd to build and run
-
-cmake --install . --prefix=build_install to have an install location
+cmake ..
+make
+cmake --install . --prefix=../install
+```
+
+## Building the Examples
+
+```bash
+# From the examples directory  
+mkdir build && cd build
+cmake .. -DCMAKE_PREFIX_PATH=../../install
+make
+```
🧰 Tools
🪛 LanguageTool

[typographical] ~1-~1: Two consecutive dots
Context: cmake .. Run above command from examples/build ...

(DOUBLE_PUNCTUATION)


[uncategorized] ~7-~7: You might be missing the article “the” here.
Context: ...es/build Dependencies: After building main project, cd to build and run cmake --i...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


[grammar] ~9-~9: The word ‘install’ is not a noun.
Context: ...all . --prefix=build_install to have an install location

(A_INSTALL)

🪛 markdownlint-cli2 (0.17.2)

1-1: First line in a file should be a top-level heading
null

(MD041, first-line-heading, first-line-h1)

♻️ Duplicate comments (2)
CMake/ystdlib-config.cmake.in (2)

3-3: Include CMakePackageConfigHelpers for config helpers

To ensure the macros set_and_check and check_required_components are available, add

include(CMakePackageConfigHelpers)

immediately after include(CMakeFindDependencyMacro), or verify that @PACKAGE_INIT@ injects it.


9-9: Use consistent variable prefix for include directory

Based on the project convention (YSTDLIB_CPP_ prefix for CMake variables), rename ystdlib_INCLUDE_DIR to:

-set_and_check(ystdlib_INCLUDE_DIR "@PACKAGE_ystdlib_INSTALL_INCLUDE_DIR@")
+set_and_check(YSTDLIB_CPP_INCLUDE_DIR "@PACKAGE_ystdlib_INSTALL_INCLUDE_DIR@")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e54cdb and 1c44077.

📒 Files selected for processing (24)
  • CMake/ystdlib-config.cmake.in (1 hunks)
  • CMake/ystdlib-cpp-helpers.cmake (5 hunks)
  • CMakeLists.txt (4 hunks)
  • README.md (2 hunks)
  • examples/CMakeLists.txt (1 hunks)
  • examples/README.md (1 hunks)
  • examples/constants.hpp (1 hunks)
  • examples/main.cpp (1 hunks)
  • examples/types.cpp (1 hunks)
  • examples/types.hpp (1 hunks)
  • lint-requirements.txt (1 hunks)
  • src/.clang-format (1 hunks)
  • src/ystdlib/containers/test/test_Array.cpp (2 hunks)
  • src/ystdlib/error_handling/CMakeLists.txt (1 hunks)
  • src/ystdlib/error_handling/ErrorCode.hpp (1 hunks)
  • src/ystdlib/error_handling/Result.hpp (4 hunks)
  • src/ystdlib/error_handling/test/test_Result.cpp (1 hunks)
  • taskfile.yaml (1 hunks)
  • taskfiles/build.yaml (4 hunks)
  • taskfiles/deps.yaml (1 hunks)
  • taskfiles/lint-cpp.yaml (4 hunks)
  • taskfiles/lint-venv.yaml (1 hunks)
  • taskfiles/lint-yaml.yaml (1 hunks)
  • tools/yscope-dev-utils (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • examples/constants.hpp
  • src/ystdlib/error_handling/ErrorCode.hpp
  • src/ystdlib/containers/test/test_Array.cpp
  • examples/main.cpp
  • src/ystdlib/error_handling/test/test_Result.cpp
  • examples/types.cpp
  • examples/types.hpp
  • src/ystdlib/error_handling/Result.hpp
🧠 Learnings (5)
📓 Common learnings
Learnt from: Bill-hbrhbr
PR: y-scope/ystdlib-cpp#32
File: CMakeLists.txt:0-0
Timestamp: 2025-02-28T05:04:33.616Z
Learning: The y-scope/ystdlib-cpp project uses the "YSTDLIB_CPP_" prefix for project-specific CMake variables, following good naming convention practices.
taskfile.yaml (1)
Learnt from: LinZhihao-723
PR: y-scope/ystdlib-cpp#66
File: taskfile.yaml:4-4
Timestamp: 2025-05-27T22:22:47.058Z
Learning: Task (go-task) has native support for `set` and `shopt` options in Taskfile.yaml that work with the default `mvdan.cc/sh` interpreter, without requiring `interpreter: bash`. The `shopt: ["globstar"]` option will enable recursive globbing patterns like `**/*` without additional shell configuration.
CMake/ystdlib-config.cmake.in (1)
Learnt from: Bill-hbrhbr
PR: y-scope/ystdlib-cpp#32
File: CMakeLists.txt:0-0
Timestamp: 2025-02-28T05:04:33.616Z
Learning: The y-scope/ystdlib-cpp project uses the "YSTDLIB_CPP_" prefix for project-specific CMake variables, following good naming convention practices.
src/ystdlib/error_handling/Result.hpp (3)
Learnt from: anlowee
PR: y-scope/ystdlib-cpp#62
File: src/ystdlib/error_handling/Result.hpp:63-63
Timestamp: 2025-05-31T00:43:32.193Z
Learning: In Boost.Outcome, BOOST_OUTCOME_TRYV macro is universally available and doesn't need #ifdef guards, unlike BOOST_OUTCOME_TRYX which is GCC/Clang-specific and requires guarding.
Learnt from: anlowee
PR: y-scope/ystdlib-cpp#62
File: src/ystdlib/error_handling/Result.hpp:63-63
Timestamp: 2025-05-31T00:43:32.193Z
Learning: In Boost.Outcome, BOOST_OUTCOME_TRYV macro is universally available and doesn't need #ifdef guards, unlike BOOST_OUTCOME_TRYX which is GCC/Clang-specific and requires guarding.
Learnt from: anlowee
PR: y-scope/ystdlib-cpp#62
File: src/ystdlib/error_handling/Result.hpp:63-63
Timestamp: 2025-05-31T00:43:32.193Z
Learning: In Boost.Outcome, BOOST_OUTCOME_TRYV macro is universally available and doesn't need #ifdef guards, unlike BOOST_OUTCOME_TRYX which is GCC/Clang-specific and requires guarding.
CMakeLists.txt (1)
Learnt from: Bill-hbrhbr
PR: y-scope/ystdlib-cpp#32
File: CMakeLists.txt:0-0
Timestamp: 2025-02-28T05:04:33.616Z
Learning: The y-scope/ystdlib-cpp project uses the "YSTDLIB_CPP_" prefix for project-specific CMake variables, following good naming convention practices.
🪛 markdownlint-cli2 (0.17.2)
README.md

11-11: Fenced code blocks should be surrounded by blank lines
null

(MD031, blanks-around-fences)

examples/README.md

1-1: First line in a file should be a top-level heading
null

(MD041, first-line-heading, first-line-h1)

🪛 LanguageTool
examples/README.md

[typographical] ~1-~1: Two consecutive dots
Context: cmake .. Run above command from examples/build ...

(DOUBLE_PUNCTUATION)


[uncategorized] ~7-~7: You might be missing the article “the” here.
Context: ...es/build Dependencies: After building main project, cd to build and run cmake --i...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


[grammar] ~9-~9: The word ‘install’ is not a noun.
Context: ...all . --prefix=build_install to have an install location

(A_INSTALL)

🔇 Additional comments (44)
tools/yscope-dev-utils (1)

1-1: Update subproject commit reference
This bumps the tools/yscope-dev-utils subproject to commit 76aecbd6d0db6e2078005431946b5c2e716c4291, aligning it with the reorganized taskfile namespaces and paths.

lint-requirements.txt (1)

1-2: LGTM: Reasonable version constraint updates

The relaxation of version constraints from fixed minor versions to minimum version requirements allows for better tooling flexibility while maintaining compatibility.

src/ystdlib/containers/test/test_Array.cpp (1)

78-78: LGTM: Excellent type safety improvement

Converting from int to size_t for array indices and container operations is a great improvement that:

  • Eliminates signed/unsigned comparison issues
  • Aligns with standard library conventions where container sizes are size_t
  • Improves type safety and correctness

The changes are applied consistently across all affected test cases.

Also applies to: 86-89, 95-99, 105-107, 116-116

src/ystdlib/error_handling/CMakeLists.txt (1)

10-10:

✅ Verification successful

Verify consistency of dependency change across the codebase

The change from outcome::hl to Boost::headers aligns with the broader project shift to Boost libraries. Ensure that corresponding header changes (e.g., namespace updates in Result.hpp) are consistently applied throughout the codebase.


🏁 Script executed:

#!/bin/bash
# Verify that all outcome namespace references have been updated to boost::outcome
rg -n "outcome::" --type cpp --type hpp
rg -n "#include.*outcome" --type cpp --type hpp

Length of output: 145


To ensure we catch all references correctly, let’s retry without relying on built-in file-type filters:


🏁 Script executed:

#!/bin/bash
# Search for outcome:: namespace usage in all .cpp/.hpp files
rg -n "outcome::" -g '*.cpp' -g '*.hpp'

# Search for direct includes of outcome headers in all .cpp/.hpp files
rg -n "#include.*outcome" -g '*.cpp' -g '*.hpp'

# Check CMakeLists for any remaining Outcome references
rg -n "Outcome" -g 'CMakeLists.txt'

Length of output: 437


Dependency update to Boost::headers verified

All legacy outcome:: usages and includes have been replaced. In particular, src/ystdlib/error_handling/Result.hpp now uses only:

  • <boost/outcome/config.hpp>
  • <boost/outcome/std_result.hpp>
  • <boost/outcome/success_failure.hpp>
  • <boost/outcome/try.hpp>

No remaining outcome:: or non-Boost includes detected.

src/.clang-format (1)

9-9: Boost headers grouping aligns with updated dependencies
Updating the IncludeCategories regex to group Boost and Catch2 headers reflects the shift from Outcome to Boost.

README.md (2)

12-13: Correct testing option name
Switching from YSTDLIB_CPP_BUILD_TESTING to ystdlib_BUILD_TESTING aligns with the CMake option rename and ensures consistency.


70-70: Consistent casing for build-testing variable
Lowercase ystdlib_BUILD_TESTING usage matches CMake conventions and the updated option in the build scripts.

src/ystdlib/error_handling/test/test_Result.cpp (1)

109-110: Formatting adjustment only
The line break for the equality assertion improves readability without affecting logic.

taskfile.yaml (2)

3-4: Enable stricter shell options
Adding set: ["u", "pipefail"] and shopt: ["globstar"] increases robustness and supports recursive globbing per project conventions.


10-10: Update utils include path
The new path tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml matches the reorganised utilities structure.

taskfiles/lint-venv.yaml (1)

18-18: Align task references with reorganised utils namespaces
Updating task references to :utils:checksum:validate, :utils:misc:create-venv, and :utils:checksum:compute reflects the reorganised task namespaces and ensures the correct utility modules are invoked.

Also applies to: 23-23, 29-29

CMake/ystdlib-config.cmake.in (2)

7-7: Correct dependency usage for Boost

The use of find_dependency(Boost REQUIRED) aligns with the project's migration from the outcome library to Boost::outcome as mentioned in previous discussions.


14-16: Target inclusion logic is correct

The conditional check and quoted include path properly handle the target import while avoiding redefinition.

taskfiles/build.yaml (1)

13-13: Task reference updates are consistent

The systematic update from :utils:cmake-build to :utils:cmake:build pattern is consistent across all task references and aligns with the broader task namespace reorganization.

Also applies to: 24-24, 52-52, 62-62

taskfiles/lint-yaml.yaml (2)

17-18: Practical exclusion for CLion build directories

Adding exclusion for cmake-build-* directories is a sensible improvement for developers using CLion IDE.


26-36: Improved command formatting and path updates

The reformatted command structure and updated yamllint config path align with the project's structural reorganization while maintaining clarity.

src/ystdlib/error_handling/ErrorCode.hpp (1)

90-90: Improved specifier ordering

Reordering from constexpr static to static constexpr follows the conventional order where storage class specifiers precede other specifiers, improving code style consistency.

examples/main.cpp (1)

15-53: Comprehensive error handling example

The example effectively demonstrates the ErrorCode framework with thorough testing of:

  • Error code construction and conversion to std::error_code
  • Message and category validation
  • Same-category and cross-category comparisons
  • Proper assertion of expected behavior

The implementation follows good practices with proper includes, consistent style, and logical test coverage.

CMake/ystdlib-cpp-helpers.cmake (4)

31-32: Variable naming convention changes look good.

The transition from YSTDLIB_CPP_ENABLE_TESTS to ystdlib_ENABLE_TESTS aligns with the project's standardised naming conventions. The comment updates also reflect the consistent use of ystdlib throughout the project.

Also applies to: 43-43, 153-153


105-109: Install interface configuration is properly implemented.

The addition of INSTALL_INTERFACE generator expression correctly configures the include directories for installed packages using CMAKE_INSTALL_INCLUDEDIR. This enables dependent projects to find headers after installation.


138-144: Header installation logic follows CMake best practices.

The installation of public headers to ${CMAKE_INSTALL_INCLUDEDIR}/ystdlib/${arg_cpp_lib_NAME} provides a well-structured installation hierarchy that prevents header conflicts and follows standard conventions.


146-151: Explicit LINKER_LANGUAGE property setting is beneficial.

Setting the LINKER_LANGUAGE property to CXX for both library and test targets ensures proper C++ linking behaviour, especially important for header-only libraries that might not automatically detect the language.

Also applies to: 174-179

examples/constants.hpp (1)

9-15: Constant declarations follow modern C++ best practices.

The use of constexpr std::string_view and constexpr std::array with proper type deduction demonstrates excellent modern C++ practices. The naming convention with the c prefix clearly identifies these as constants.

src/ystdlib/error_handling/Result.hpp (1)

6-9: Migration to Boost.Outcome is correctly implemented.

The systematic transition from standalone outcome to Boost.Outcome is well-executed:

  • All includes updated from <outcome/...> to <boost/outcome/...>
  • Namespace references consistently changed from OUTCOME_V2_NAMESPACE to BOOST_OUTCOME_V2_NAMESPACE
  • Macro prefixes correctly updated from OUTCOME_* to BOOST_OUTCOME_*
  • Conditional compilation for BOOST_OUTCOME_TRYX is properly maintained for GCC/Clang-specific usage

Also applies to: 23-23, 29-30, 46-46, 48-48, 63-63

examples/types.cpp (2)

24-38: Template specialization implementation is correct.

The AlwaysSuccessErrorCategory specializations properly implement the required interface with appropriate error handling for unrecognized error codes.


45-55: Template specialization implementation is correct.

The BinaryErrorCategory::message() specialization correctly handles both success and failure cases with appropriate default handling.

taskfiles/deps.yaml (3)

12-18: Dependency installation approach is well-structured.

The simplified install-all task using the utility task approach provides a clean interface for dependency management while maintaining the necessary CMake settings configuration.


20-24: Parallel installation correctly targets new dependencies.

The install-all-parallel task properly reflects the migration from outcome/quickcpplib to Boost, maintaining efficient parallel installation.


38-49: Boost installation configuration is appropriate.

The Boost dependency configuration correctly specifies:

  • Specific version (1.87.0) with expected SHA256
  • Headers-only target (appropriate for Boost.Outcome usage)
  • Proper utility task usage for installation
taskfiles/lint-cpp.yaml (4)

3-4: Output directory configuration is a good addition.

The new G_LINT_CLANG_TIDY_DIR variable provides proper organization for clang-tidy output files.


32-37: Utility namespace migration is consistent.

The migration to :utils:cpp-lint:clang-format with improved variable structure (FLAGS as list, explicit INCLUDE_FILENAME_PATTERNS and ROOT_PATHS) provides better maintainability and clarity.

Also applies to: 46-51


66-73: Clang-tidy configuration improvements are well-structured.

The migration to :utils:cpp-lint:clang-tidy-find with FLAGS as a quoted string list and the addition of OUTPUT_DIR provides better organization and consistency with the utility namespace restructuring.


78-86: Configuration file paths correctly updated.

The updated paths to tools/yscope-dev-utils/exports/lint-configs align with the utility reorganization and maintain proper lint configuration management.

CMakeLists.txt (11)

5-5: Project name aligned with package.
Switching the project declaration to ystdlib now matches your exported package name and avoids confusion when users call find_package(ystdlib).


7-10: Good ordering of includes.
Adding project(...) before include(GNUInstallDirs) and appropriately appending to CMAKE_MODULE_PATH ensures no developer warnings and makes helper modules available.


13-13: Consistent testing option naming.
Using a project-scoped ystdlib_BUILD_TESTING flag is clear. Ensure it’s documented in your README.


44-44: Top-level project guard is correct.
Conditionally including dependency settings and CTest only when ystdlib_IS_TOP_LEVEL is ON prevents leaking those macros into downstream projects.


54-55: Test enabling logic is sound.
Combining BUILD_TESTING with your project-level flag yields precise control over test builds.


63-64: Catch2 dependency is correctly versioned.
Requiring Catch2 3.8.0 ensures compatibility with catch_discover_tests.


70-70: Include Catch2 module appropriately.
Calling include(Catch) inside the tests guard is needed for catch_discover_tests. Good placement.


90-90: Subdirectory inclusion is correct.
Using add_subdirectory(src/ystdlib) properly scopes your library targets for later installation.


104-104: Export installation is configured correctly.
Installing the ystdlib-targets export under the ystdlib:: namespace aligns with CMake package conventions.


114-117: Package version file generation is correct.
Using write_basic_package_version_file with SameMajorVersion compatibility is the recommended approach.


119-124: Install config files under proper directory.
The files are installed to ${ystdlib_INSTALL_CONFIG_DIR}, which matches your namespace. Good.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (7)
cmake/ystdlib-helpers.cmake (4)

11-11: Error message inaccuracy needs correction.

The error message says "Empty value for argument" but the condition NOT DEFINED ARG_${_NAME} OR ARG_${_NAME} STREQUAL "" checks for both undefined AND empty values.


24-24: Header file regex is too restrictive.

The pattern ".*\\.(h|hpp)" ignores upper-case extensions and common variants like .hh or .hxx, potentially causing header-only libraries to be treated as compiled libraries.


158-163: RUNTIME_OUTPUT_DIRECTORY not multi-config compatible.

Setting RUNTIME_OUTPUT_DIRECTORY directly breaks multi-configuration generators like Visual Studio or Xcode where per-config directories are expected.


214-214: Install command may emit warnings for INTERFACE libraries.

The install command attempts to install LIBRARY ARCHIVE RUNTIME for all targets, which will cause warnings for INTERFACE (header-only) targets that have no artifacts.

CMakeLists.txt (3)

1-1: Breaking change requires documentation in PR title.

Raising the minimum CMake version to 3.23 is a breaking change for dependent projects (e.g., CLP still supports Ubuntu Jammy). This should be indicated in the PR title.


55-55: ystdlib_IS_TOP_LEVEL may be undefined.

The guard assumes this variable is defined elsewhere. If missing, dependencies and CTest setup will be skipped.


98-102: Add PATH_VARS to configure_package_config_file.

The call is missing PATH_VARS to properly substitute install path variables instead of embedding absolute paths.

 configure_package_config_file(
     "${CMAKE_CURRENT_LIST_DIR}/cmake/${CONFIG_FILE_PREFIX}.cmake.in"
     "${CONFIG_OUTPUT_PATH}"
+    PATH_VARS ystdlib_INSTALL_CONFIG_DIR
     INSTALL_DESTINATION "${ystdlib_INSTALL_CONFIG_DIR}"
 )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9a73e0 and 9a4099c.

📒 Files selected for processing (5)
  • CMakeLists.txt (2 hunks)
  • cmake/ystdlib-config.cmake.in (1 hunks)
  • cmake/ystdlib-helpers.cmake (1 hunks)
  • examples/src/linking-tests.cpp (1 hunks)
  • src/ystdlib/error_handling/CMakeLists.txt (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • examples/src/linking-tests.cpp
🧠 Learnings (3)
📓 Common learnings
Learnt from: PacificViking
PR: y-scope/ystdlib-cpp#65
File: CMakeLists.txt:87-88
Timestamp: 2025-06-06T15:01:53.987Z
Learning: The y-scope/ystdlib-cpp project uses lowercase `ystdlib_` prefix for project-specific CMake variables (e.g., `ystdlib_VERSION`, `ystdlib_BUILD_TESTING`, `ystdlib_INSTALL_CONFIG_DIR`) following the current naming convention standards.
cmake/ystdlib-helpers.cmake (2)
Learnt from: davidlion
PR: y-scope/ystdlib-cpp#65
File: cmake/ystdlib-helpers.cmake:105-113
Timestamp: 2025-06-16T16:05:45.088Z
Learning: In CMake, using target_sources() with PUBLIC and FILE_SET HEADERS on INTERFACE targets is valid and equivalent to using INTERFACE. FILE_SET HEADERS are treated as usage requirements, not compilation sources, so they don't cause errors on INTERFACE targets in modern CMake versions like 3.31.
Learnt from: davidlion
PR: y-scope/ystdlib-cpp#65
File: cmake/ystdlib-helpers.cmake:105-113
Timestamp: 2025-06-16T16:02:19.821Z
Learning: In CMake, using target_sources() with PUBLIC and FILE_SET HEADERS on INTERFACE targets is valid and equivalent to using INTERFACE. FILE_SET HEADERS are treated as usage requirements, not compilation sources, so they don't cause errors on INTERFACE targets in modern CMake versions like 3.31.
CMakeLists.txt (1)
Learnt from: PacificViking
PR: y-scope/ystdlib-cpp#65
File: CMakeLists.txt:87-88
Timestamp: 2025-06-06T15:01:53.987Z
Learning: The y-scope/ystdlib-cpp project uses lowercase `ystdlib_` prefix for project-specific CMake variables (e.g., `ystdlib_VERSION`, `ystdlib_BUILD_TESTING`, `ystdlib_INSTALL_CONFIG_DIR`) following the current naming convention standards.
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: build-ystdlib-cpp (macos-15)
  • GitHub Check: build-ystdlib-cpp (ubuntu-22.04)
  • GitHub Check: build-ystdlib-cpp (macos-14)
  • GitHub Check: lint-check (ubuntu-24.04)
  • GitHub Check: lint-check (macos-15)
🔇 Additional comments (6)
cmake/ystdlib-config.cmake.in (1)

1-13: LGTM! Clean package configuration template.

The implementation correctly uses @ystdlib_LIBRARIES@ substitution, includes component config files only if targets don't exist, and properly calls check_required_components().

src/ystdlib/error_handling/CMakeLists.txt (2)

1-3: Good practice: Early return guard.

The target existence check prevents redundant processing when the target is already defined.


14-39: Excellent modular structure using helper functions.

The use of add_cpp_library, add_catch2_tests, and install_library provides a clean, consistent approach to library definition, testing, and installation.

examples/src/linking-tests.cpp (3)

65-68: Good practice: Function prototypes improve maintainability.

The forward declarations allow for function reordering and better code organization.


104-104: Excellent adherence to coding guidelines.

Using false == test_containers() instead of !test_containers() follows the project's coding guidelines preference.


47-62: Proper use of [[maybe_unused]] attribute.

The consistent use of [[maybe_unused]] for unreferenced parameters follows modern C++ best practices and avoids compiler warnings.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

♻️ Duplicate comments (4)
cmake/ystdlib-helpers.cmake (3)

24-24: Expand header file detection regex for better coverage.

The current regex .*\\.(h|hpp) is case-sensitive and misses common header file extensions like .hh, .hxx, and uppercase variants.


158-163: Fix multi-config generator compatibility.

Hard-coding RUNTIME_OUTPUT_DIRECTORY breaks multi-config generators like Visual Studio/Xcode where per-config directories are expected.


214-214: Handle INTERFACE libraries in install command.

The install command with LIBRARY ARCHIVE RUNTIME will emit warnings for INTERFACE targets that have no artifacts.

examples/CMakeLists.txt (1)

3-3: Consider using underscores instead of hyphens in project name.

The project name ystdlib-examples creates CMake variables with hyphens (like ystdlib-examples_IS_TOP_LEVEL on line 18), which can cause parsing issues in CMake expressions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a4099c and 1a0c6df.

📒 Files selected for processing (6)
  • CMakeLists.txt (2 hunks)
  • cmake/ystdlib-helpers.cmake (1 hunks)
  • examples/CMakeLists.txt (1 hunks)
  • examples/README.md (1 hunks)
  • examples/src/linking-tests.cpp (1 hunks)
  • src/ystdlib/error_handling/CMakeLists.txt (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • examples/src/linking-tests.cpp
🧠 Learnings (3)
📓 Common learnings
Learnt from: PacificViking
PR: y-scope/ystdlib-cpp#65
File: CMakeLists.txt:87-88
Timestamp: 2025-06-06T15:01:53.987Z
Learning: The y-scope/ystdlib-cpp project uses lowercase `ystdlib_` prefix for project-specific CMake variables (e.g., `ystdlib_VERSION`, `ystdlib_BUILD_TESTING`, `ystdlib_INSTALL_CONFIG_DIR`) following the current naming convention standards.
cmake/ystdlib-helpers.cmake (2)
Learnt from: davidlion
PR: y-scope/ystdlib-cpp#65
File: cmake/ystdlib-helpers.cmake:105-113
Timestamp: 2025-06-16T16:05:45.088Z
Learning: In CMake, using target_sources() with PUBLIC and FILE_SET HEADERS on INTERFACE targets is valid and equivalent to using INTERFACE. FILE_SET HEADERS are treated as usage requirements, not compilation sources, so they don't cause errors on INTERFACE targets in modern CMake versions like 3.31.
Learnt from: davidlion
PR: y-scope/ystdlib-cpp#65
File: cmake/ystdlib-helpers.cmake:105-113
Timestamp: 2025-06-16T16:02:19.821Z
Learning: In CMake, using target_sources() with PUBLIC and FILE_SET HEADERS on INTERFACE targets is valid and equivalent to using INTERFACE. FILE_SET HEADERS are treated as usage requirements, not compilation sources, so they don't cause errors on INTERFACE targets in modern CMake versions like 3.31.
CMakeLists.txt (1)
Learnt from: PacificViking
PR: y-scope/ystdlib-cpp#65
File: CMakeLists.txt:87-88
Timestamp: 2025-06-06T15:01:53.987Z
Learning: The y-scope/ystdlib-cpp project uses lowercase `ystdlib_` prefix for project-specific CMake variables (e.g., `ystdlib_VERSION`, `ystdlib_BUILD_TESTING`, `ystdlib_INSTALL_CONFIG_DIR`) following the current naming convention standards.
🪛 LanguageTool
examples/README.md

[uncategorized] ~11-~11: The preposition “in” seems more likely in this position.
Context: .../examples/ystdlib`. If you installed it to a different location, adjust the paths ...

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-ystdlib-cpp (ubuntu-24.04)
  • GitHub Check: build-ystdlib-cpp (macos-15)
  • GitHub Check: build-ystdlib-cpp (ubuntu-22.04)
  • GitHub Check: build-ystdlib-cpp (macos-14)
  • GitHub Check: lint-check (ubuntu-24.04)
  • GitHub Check: lint-check (macos-15)
🔇 Additional comments (14)
examples/README.md (1)

1-29: Documentation looks good after addressing past feedback.

The README has been significantly improved with better structure, clearer instructions, and proper formatting. All the major issues from previous reviews appear to have been resolved.

src/ystdlib/error_handling/CMakeLists.txt (1)

1-40: Clean refactoring using new helper functions.

The CMake configuration has been nicely refactored to use the standardized helper functions. The early return guard, Boost dependency handling, and separation of library definition from testing are all well-structured improvements.

examples/src/linking-tests.cpp (1)

70-125: Well-structured integration test demonstrating library usage.

The test implementation effectively validates all major ystdlib components with appropriate error handling and clear return codes. The code demonstrates proper usage patterns for containers, error handling, IO interfaces, and wrapped facade headers, serving as both a validation test and usage example.

CMakeLists.txt (11)

1-1: Weigh the CMake version bump as a breaking change.

Requiring CMake 3.23 will break builds on older platforms (e.g., Ubuntu Jammy). Please update the PR title, release notes, and README to call out this requirement.


3-3: Project declaration looks good.

Renaming the project to lowercase ystdlib and starting at version 0.1.0 aligns with your convention for new libraries.


5-8: Helper modules inclusion is correct.

Including CMakePackageConfigHelpers, GNUInstallDirs, and your lowercase ystdlib-helpers is consistent and in alphabetical order.


11-11: Test-build option naming is consistent.

Using ystdlib_BUILD_TESTING with a lowercase ystdlib_ prefix follows your project’s naming convention.


41-48: Library list variable definition is clear.

Defining ystdlib_LIBRARIES as a semicolon-separated CACHE STRING provides flexibility in selecting which sub-libraries to build.


50-53: Logging of selected libraries is helpful.

Emitting the list of libraries at configure time improves user feedback.


65-68: Test-enable logic is sound.

Conditionally setting ystdlib_ENABLE_TESTS based on both BUILD_TESTING and ystdlib_BUILD_TESTING correctly gates test discovery.


69-86: Unified Catch2 test target is configured correctly.

The use of Catch2::Catch2WithMain, test discovery, and private C++20 requirement on the test executable is appropriate.


91-91: Top-level library inclusion is correct.

Delegating all sub-libraries to src/ystdlib via add_subdirectory matches your modular build approach.


93-93: Package config directory is well-defined.

Setting ystdlib_INSTALL_CONFIG_DIR under ${CMAKE_INSTALL_LIBDIR}/cmake/ystdlib follows GNUInstallDirs conventions and your lowercase prefix.


106-111: Configuration file installation is correct.

Installing both the config and version files to the package config directory ensures find_package(ystdlib) will locate them.

@davidlion davidlion requested a review from kirkrodrigues June 23, 2025 04:37
CMakeLists.txt Outdated
endif()

# All libraries are required to use the same minimum version of dependencies to avoid issues.
set(MIN_BOOST_VERSION "1.81.0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about BOOST_MIN_VERSION?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

♻️ Duplicate comments (2)
cmake/ystdlib-helpers.cmake (2)

214-214: Installation command may generate warnings for INTERFACE libraries.

The install command specifies LIBRARY ARCHIVE RUNTIME for all targets, which will generate warnings for INTERFACE targets that have no artifacts to install.

Consider making the install command conditional based on target type:

-    install(TARGETS "${ARG_NAME}" EXPORT "${EXPORT_NAME}" LIBRARY ARCHIVE RUNTIME FILE_SET HEADERS)
+    get_target_property(TARGET_TYPE "${ARG_NAME}" TYPE)
+    if(TARGET_TYPE STREQUAL "INTERFACE_LIBRARY")
+        install(TARGETS "${ARG_NAME}" EXPORT "${EXPORT_NAME}" FILE_SET HEADERS)
+    else()
+        install(TARGETS "${ARG_NAME}" EXPORT "${EXPORT_NAME}" LIBRARY ARCHIVE RUNTIME FILE_SET HEADERS)
+    endif()

157-163: Consider multi-config generator compatibility.

The RUNTIME_OUTPUT_DIRECTORY property is set directly, which may not work optimally with multi-configuration generators like Visual Studio or Xcode.

Consider using generator expressions for better multi-config support:

-    set_property(
-        TARGET
-            ${UNIT_TEST_TARGET}
-        PROPERTY
-            RUNTIME_OUTPUT_DIRECTORY
-                ${CMAKE_BINARY_DIR}/testbin
-    )
+    set_target_properties(${UNIT_TEST_TARGET} PROPERTIES
+        RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/testbin"
+        RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/testbin"
+        RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/testbin"
+    )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a0c6df and ae147cd.

📒 Files selected for processing (3)
  • CMakeLists.txt (2 hunks)
  • README.md (4 hunks)
  • cmake/ystdlib-helpers.cmake (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: PacificViking
PR: y-scope/ystdlib-cpp#65
File: CMakeLists.txt:87-88
Timestamp: 2025-06-06T15:01:53.987Z
Learning: The y-scope/ystdlib-cpp project uses lowercase `ystdlib_` prefix for project-specific CMake variables (e.g., `ystdlib_VERSION`, `ystdlib_BUILD_TESTING`, `ystdlib_INSTALL_CONFIG_DIR`) following the current naming convention standards.
README.md (1)
Learnt from: PacificViking
PR: y-scope/ystdlib-cpp#65
File: CMakeLists.txt:87-88
Timestamp: 2025-06-06T15:01:53.987Z
Learning: The y-scope/ystdlib-cpp project uses lowercase `ystdlib_` prefix for project-specific CMake variables (e.g., `ystdlib_VERSION`, `ystdlib_BUILD_TESTING`, `ystdlib_INSTALL_CONFIG_DIR`) following the current naming convention standards.
cmake/ystdlib-helpers.cmake (2)
Learnt from: davidlion
PR: y-scope/ystdlib-cpp#65
File: cmake/ystdlib-helpers.cmake:105-113
Timestamp: 2025-06-16T16:05:45.088Z
Learning: In CMake, using target_sources() with PUBLIC and FILE_SET HEADERS on INTERFACE targets is valid and equivalent to using INTERFACE. FILE_SET HEADERS are treated as usage requirements, not compilation sources, so they don't cause errors on INTERFACE targets in modern CMake versions like 3.31.
Learnt from: davidlion
PR: y-scope/ystdlib-cpp#65
File: cmake/ystdlib-helpers.cmake:105-113
Timestamp: 2025-06-16T16:02:19.821Z
Learning: In CMake, using target_sources() with PUBLIC and FILE_SET HEADERS on INTERFACE targets is valid and equivalent to using INTERFACE. FILE_SET HEADERS are treated as usage requirements, not compilation sources, so they don't cause errors on INTERFACE targets in modern CMake versions like 3.31.
CMakeLists.txt (1)
Learnt from: PacificViking
PR: y-scope/ystdlib-cpp#65
File: CMakeLists.txt:87-88
Timestamp: 2025-06-06T15:01:53.987Z
Learning: The y-scope/ystdlib-cpp project uses lowercase `ystdlib_` prefix for project-specific CMake variables (e.g., `ystdlib_VERSION`, `ystdlib_BUILD_TESTING`, `ystdlib_INSTALL_CONFIG_DIR`) following the current naming convention standards.
🪛 LanguageTool
README.md

[uncategorized] ~23-~23: Loose punctuation mark.
Context: ... link options for your target. * lib_1, lib_2, ..., lib_N are the names of ...

(UNLIKELY_OPENING_PUNCTUATION)

🪛 markdownlint-cli2 (0.17.2)
README.md

5-5: Multiple top-level headings in the same document
null

(MD025, single-title, single-h1)


29-29: Blank line inside blockquote
null

(MD028, no-blanks-blockquote)


33-33: Trailing spaces
Expected: 0 or 2; Actual: 1

(MD009, no-trailing-spaces)


38-38: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


38-38: Multiple top-level headings in the same document
null

(MD025, single-title, single-h1)

🔇 Additional comments (18)
README.md (2)

7-8: Clear and accurate installation workflow instructions.

The updated instructions correctly reflect the new CMake package-based approach, requiring users to build and install ystdlib first before using find_package().


11-16: Consistent variable naming and improved CMake usage examples.

The examples correctly demonstrate the new find_package(ystdlib REQUIRED) approach and the ystdlib_LIBRARIES variable for selective library building, which aligns with the updated build system.

Also applies to: 90-97

cmake/ystdlib-helpers.cmake (4)

7-14: Well-implemented argument validation macro.

The check_required_arguments_exist macro properly validates required arguments and provides clear error messages. The implementation correctly checks for both undefined and empty values.


21-32: Header detection function works correctly.

The check_if_header_only function properly identifies header files using a standard regex pattern and correctly sets return values via PARENT_SCOPE.


106-114: FILE_SET HEADERS usage is correct for modern CMake.

Based on retrieved learnings, using PUBLIC with FILE_SET HEADERS on INTERFACE targets is valid in CMake 3.31+. The headers are treated as usage requirements, not compilation sources.


176-185: Clear and comprehensive function documentation.

The documentation accurately describes the function parameters and provides helpful default values. The parameter descriptions are clear and follow a consistent format.

CMakeLists.txt (12)

1-1: Ensure compatibility with new CMake minimum version.

Raising the minimum required CMake version to 3.23 is a breaking change for users on older platforms like Ubuntu Jammy. Please confirm this requirement is documented in the README and aligned with the PR’s breaking-change indicator in the title.


3-3: Validate initial project version.

The project version is set to 0.1.0, which aligns with the introduced public API. Ensure this aligns with your release policy and update any documentation or badges that display the version.


5-8: Confirm consistent inclusion of helper modules.

Including CMakePackageConfigHelpers, GNUInstallDirs, and ystdlib-helpers in alphabetical order under the updated cmake directory path is clear and intentional. No issues found.


11-11: Consistent CMake option naming.

Renaming the testing option to ystdlib_BUILD_TESTING follows the established lowercase prefix convention and improves consistency. No changes needed.


41-48: Introduce configurable library list.

Defining ystdlib_LIBRARIES as a semicolon-separated cache variable provides flexible control over which components to build. Implementation looks correct.


50-53: Display selected libraries.

The status messages clearly list the libraries to build, improving user feedback. No concerns here.


65-67: Enable unified testing control.

The combined BUILD_TESTING and ystdlib_BUILD_TESTING conditions correctly drive test generation and follow CTest conventions.


69-72: Update Catch2 requirement.

Specifying Catch2 3.8.0 explicitly ensures compatibility with the discovery API. The subsequent inclusion of Catch is correct. No issues.


93-93: Define package configuration install directory.

ystdlib_INSTALL_CONFIG_DIR is correctly set to ${CMAKE_INSTALL_LIBDIR}/cmake/ystdlib, aligning with standard GNUInstallDirs conventions.


95-97: Configure package config file paths.

Setting the CONFIG_FILE_PREFIX and calculating CONFIG_OUTPUT_PATH and CONFIG_VERSION_OUTPUT_PATH are straightforward and clear.


104-105: Generate version file for package.

Using write_basic_package_version_file with SameMajorVersion compatibility is correct for downstream version checks.


106-111: Install package configuration files.

Installing both the config and version files into ystdlib_INSTALL_CONFIG_DIR ensures proper find_package support. This matches CMake best practices.


An open-source C++ library developed and used at YScope.

# Usage
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix multiple H1 headings to improve document structure.

The document has multiple top-level headings which violates markdown standards (MD025). Change the secondary sections to use ## instead of #.

-# Usage
+## Usage
-# Contributing
+## Contributing

Also applies to: 38-38

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

5-5: Multiple top-level headings in the same document
null

(MD025, single-title, single-h1)

🤖 Prompt for AI Agents
In README.md at lines 5 and 38, there are multiple top-level headings (#) which
violates markdown standards. Change these headings from single # to double ## to
make them secondary headings and improve document structure.

> [!TIP]
> If ystdlib is not installed to a path that is searched by default, set `ystdlib_ROOT` to manually
> specify the location:
>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Remove trailing space.

Line 33 has a trailing space that should be removed (MD009).

-> 
+>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
>
>
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

33-33: Trailing spaces
Expected: 0 or 2; Actual: 1

(MD009, no-trailing-spaces)

🤖 Prompt for AI Agents
In README.md at line 33, there is a trailing space at the end of the line.
Remove the trailing space to comply with markdown linting rule MD009.

> [!NOTE]
> If `BUILD_TESTING` is `ON`, set `ystdlib_BUILD_TESTING` to `OFF` to skip building ystdlib's unit
> tests.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Remove blank line inside blockquote.

The blank line inside the blockquote violates markdown formatting standards (MD028).

> [!NOTE]
> If `BUILD_TESTING` is `ON`, set `ystdlib_BUILD_TESTING` to `OFF` to skip building ystdlib's unit
-> tests.
+> tests.

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

29-29: Blank line inside blockquote
null

(MD028, no-blanks-blockquote)

🤖 Prompt for AI Agents
In README.md at line 29, there is a blank line inside a blockquote which
violates markdown formatting standards (MD028). Remove the blank line so that
the blockquote content is continuous without any empty lines inside it.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (8)
src/ystdlib/wrapped_facade_headers/CMakeLists.txt (1)

5-5: Address potential system header name clash.

Installing sys/types.h under your include prefix risks shadowing the system <sys/types.h> header, which could lead to unexpected behaviour in consuming projects. Consider renaming this facade header to avoid conflicts with the POSIX standard header.

cmake/ystdlib-helpers.cmake (2)

158-164: Consider multi-config generator compatibility.

The hard-coded RUNTIME_OUTPUT_DIRECTORY may not work correctly with multi-config generators like Visual Studio or Xcode. Consider using generator expressions for better compatibility.

-        PROPERTY
-            RUNTIME_OUTPUT_DIRECTORY
-                ${CMAKE_BINARY_DIR}/testbin
+        PROPERTY
+            RUNTIME_OUTPUT_DIRECTORY
+                "${CMAKE_BINARY_DIR}/$<CONFIG>/testbin"

21-32: Header file detection could be more comprehensive.

The regex pattern .*\\.(h|hpp) may miss some common header file extensions and is case-sensitive. Consider expanding it to handle variants like .hh, .hxx, or uppercase extensions.

-        if(NOT "${SRC_FILE}" MATCHES ".*\\.(h|hpp)")
+        if(NOT "${SRC_FILE}" MATCHES ".*\\.[Hh](pp|xx|h)?$")
CMakeLists.txt (5)

14-19: Redundant compiler blocks still present
The duplicated AppleClang vs Clang version logic noted in the earlier review remains unchanged. Consolidating them into a single regex match would remove duplication and keep the minimum version in one place.


26-31: Back-slash continuation still hurts readability
Previous feedback to collapse this multi-line message(FATAL_ERROR …) into a single line hasn’t been addressed.


55-63: ystdlib_IS_TOP_LEVEL guard still uninitialised
The earlier issue—variable may be undefined when included as a sub-project—has not been fixed. Initialise it before use to avoid silently skipping dependency setup.


88-90: BOOST_MIN_VERSION is still dead code
This variable is set but never referenced (no find_package(Boost …) or comparison). Either wire it into find_package or delete it.


105-110: configure_package_config_file still missing PATH_VARS
Without PATH_VARS ystdlib_INSTALL_CONFIG_DIR, absolute build paths are baked into the generated config file—breaking relocatable installs. The prior suggestion has not been incorporated.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae147cd and 2af9ed7.

📒 Files selected for processing (11)
  • CMakeLists.txt (2 hunks)
  • cmake/ystdlib-helpers.cmake (1 hunks)
  • cmake/ystdlib/libs/containers-config.cmake.in (1 hunks)
  • cmake/ystdlib/libs/error_handling-config.cmake.in (1 hunks)
  • cmake/ystdlib/libs/io_interface-config.cmake.in (1 hunks)
  • cmake/ystdlib/libs/wrapped_facade_headers-config.cmake.in (1 hunks)
  • cmake/ystdlib/ystdlib-config.cmake.in (1 hunks)
  • src/ystdlib/containers/CMakeLists.txt (1 hunks)
  • src/ystdlib/error_handling/CMakeLists.txt (2 hunks)
  • src/ystdlib/io_interface/CMakeLists.txt (2 hunks)
  • src/ystdlib/wrapped_facade_headers/CMakeLists.txt (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
cmake/ystdlib-helpers.cmake (2)
Learnt from: davidlion
PR: y-scope/ystdlib-cpp#65
File: cmake/ystdlib-helpers.cmake:105-113
Timestamp: 2025-06-16T16:05:45.088Z
Learning: In CMake, using target_sources() with PUBLIC and FILE_SET HEADERS on INTERFACE targets is valid and equivalent to using INTERFACE. FILE_SET HEADERS are treated as usage requirements, not compilation sources, so they don't cause errors on INTERFACE targets in modern CMake versions like 3.31.
Learnt from: davidlion
PR: y-scope/ystdlib-cpp#65
File: cmake/ystdlib-helpers.cmake:105-113
Timestamp: 2025-06-16T16:02:19.821Z
Learning: In CMake, using target_sources() with PUBLIC and FILE_SET HEADERS on INTERFACE targets is valid and equivalent to using INTERFACE. FILE_SET HEADERS are treated as usage requirements, not compilation sources, so they don't cause errors on INTERFACE targets in modern CMake versions like 3.31.
CMakeLists.txt (1)
Learnt from: PacificViking
PR: y-scope/ystdlib-cpp#65
File: CMakeLists.txt:87-88
Timestamp: 2025-06-06T15:01:53.987Z
Learning: The y-scope/ystdlib-cpp project uses lowercase `ystdlib_` prefix for project-specific CMake variables (e.g., `ystdlib_VERSION`, `ystdlib_BUILD_TESTING`, `ystdlib_INSTALL_CONFIG_DIR`) following the current naming convention standards.
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-ystdlib-cpp (ubuntu-24.04)
  • GitHub Check: build-ystdlib-cpp (macos-14)
  • GitHub Check: build-ystdlib-cpp (ubuntu-22.04)
  • GitHub Check: build-ystdlib-cpp (macos-15)
  • GitHub Check: lint-check (ubuntu-24.04)
  • GitHub Check: lint-check (macos-15)
🔇 Additional comments (14)
cmake/ystdlib/libs/containers-config.cmake.in (1)

1-6: LGTM! Clean and consistent implementation.

This config file follows CMake best practices with proper target guards and modular design. The implementation correctly prevents double inclusion and includes the target-specific configuration file.

cmake/ystdlib/libs/error_handling-config.cmake.in (1)

1-7: LGTM! Proper dependency handling for Boost.

This config file correctly uses find_dependency to handle the Boost requirement, which is the standard CMake approach for package dependencies. The template variable substitution for @BOOST_FIND_PACKAGE_ARGS@ allows for flexible Boost configuration.

cmake/ystdlib/libs/wrapped_facade_headers-config.cmake.in (1)

1-6: LGTM! Consistent with established pattern.

This config file follows the same clean pattern as the containers config file, maintaining consistency across the library configuration system.

cmake/ystdlib/libs/io_interface-config.cmake.in (1)

1-10: LGTM! Good dependency management structure.

The overall structure correctly handles the dependency chain with proper target guards and includes the necessary files in the right order.

cmake/ystdlib/ystdlib-config.cmake.in (3)

1-3: LGTM! Standard CMake package initialization.

The includes and package initialization follow CMake best practices for package configuration files.


5-10: LGTM! Proper dynamic library loading.

The iteration over the library list and conditional inclusion of config files is implemented correctly. This allows for flexible library selection while ensuring each library's config is loaded only once.


12-12: LGTM! Proper component validation.

The check_required_components call ensures that all required components are properly loaded, which is essential for package configuration.

src/ystdlib/containers/CMakeLists.txt (1)

1-22: Well-structured CMake modernization.

The new structure effectively implements the standardized build pattern with appropriate guards, conditional testing, and proper installation setup. The early exit pattern prevents duplicate target creation, and the helper function usage ensures consistency across libraries.

src/ystdlib/io_interface/CMakeLists.txt (2)

5-10: Excellent dependency management pattern.

The conditional inclusion of wrapped_facade_headers based on the ystdlib_LIBRARIES list is a clean approach that prevents unnecessary builds while ensuring required dependencies are available.


12-23: Library configuration is well-structured.

The add_cpp_library call properly specifies headers, private sources, and public link libraries. The dependency on ystdlib::wrapped_facade_headers is correctly declared.

src/ystdlib/error_handling/CMakeLists.txt (2)

14-24: Library configuration follows standard pattern.

The add_cpp_library call is properly structured with appropriate public headers and Boost dependency linkage.


5-12: Verify that BOOST_MIN_VERSION variable is defined.

The code references ${BOOST_MIN_VERSION} but this variable may not be defined in the current scope. Ensure this variable is properly set in the parent CMakeLists.txt or consider using a fallback value.

#!/bin/bash
# Check if BOOST_MIN_VERSION is defined in the project
rg -A 3 -B 3 "BOOST_MIN_VERSION" --type cmake
cmake/ystdlib-helpers.cmake (1)

107-115: FILE_SET HEADERS usage is correct for modern CMake.

Based on retrieved learnings, using target_sources() with PUBLIC and FILE_SET HEADERS on INTERFACE targets is valid in CMake 3.31+ as these are treated as usage requirements rather than compilation sources.

CMakeLists.txt (1)

1-3: Document the CMake 3.23 requirement up-front
Jumping from the previous minimum (3.22.x) to 3.23 can break users on LTS distributions (e.g., Ubuntu 22.04 ships 3.22.1). Please highlight this bump in the changelog / release notes and in the README’s “Prerequisites” section so downstream projects aren’t caught off-guard.

@davidlion davidlion requested a review from kirkrodrigues June 24, 2025 02:03
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2af9ed7 and 4d81820.

📒 Files selected for processing (1)
  • cmake/ystdlib/libs/io_interface-config.cmake.in (1 hunks)
🔇 Additional comments (2)
cmake/ystdlib/libs/io_interface-config.cmake.in (2)

5-7: Dependency include path corrected—nice catch

Switching to wrapped_facade_headers-config.cmake resolves the dependency-lookup inconsistency flagged earlier. No further issues here.


9-9: Target file inclusion looks correct

Including io_interface-target.cmake after dependencies guarantees the imported target is fully populated. All good.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
src/ystdlib/io_interface/CMakeLists.txt (1)

28-28: Add safety check for UNIFIED_UNIT_TEST_TARGET variable.

The test registration relies on the UNIFIED_UNIT_TEST_TARGET variable being defined. Consider adding a fallback or sanity check to ensure this CMakeLists can be used independently without errors.

src/ystdlib/wrapped_facade_headers/CMakeLists.txt (1)

1-1: Address potential system header name clash.

Installing sys/types.h under your own include prefix risks shadowing the system <sys/types.h> on the consumer's include path. Consider renaming the facade header or adjusting the installation path to avoid collision.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 550d683 and a6d8f2b.

📒 Files selected for processing (8)
  • cmake/ystdlib/libs/containers-config.cmake.in (1 hunks)
  • cmake/ystdlib/libs/error_handling-config.cmake.in (1 hunks)
  • cmake/ystdlib/libs/io_interface-config.cmake.in (1 hunks)
  • cmake/ystdlib/libs/wrapped_facade_headers-config.cmake.in (1 hunks)
  • src/ystdlib/containers/CMakeLists.txt (1 hunks)
  • src/ystdlib/error_handling/CMakeLists.txt (2 hunks)
  • src/ystdlib/io_interface/CMakeLists.txt (2 hunks)
  • src/ystdlib/wrapped_facade_headers/CMakeLists.txt (1 hunks)
🔇 Additional comments (11)
src/ystdlib/containers/CMakeLists.txt (2)

3-11: Make test source path independent of the CMake invocation directory

test/test_Array.cpp is interpreted relative to the current build directory, which varies when consumers add this sub-directory via add_subdirectory or when packaging. Using ${CMAKE_CURRENT_SOURCE_DIR} avoids brittle include failures on some generators and external builds.

-            test/test_Array.cpp
+            ${CMAKE_CURRENT_SOURCE_DIR}/test/test_Array.cpp

Also ensure UNIFIED_UNIT_TEST_TARGET is defined in every code path where ystdlib_ENABLE_TESTS is true, otherwise configuration will fail.


13-18: Verify helper variables exist in every inclusion context

CONFIG_LIBS_DEST_DIR and CONFIG_LIBS_INPUT_DIR are referenced here but are not obviously scoped in this file. If a consumer project calls find_package(ystdlib) and brings this directory in through an installed config, these variables must still resolve or the installation step will mis-configure.

Double-check that CMake/ystdlib-helpers.cmake (or the top-level CMakeLists.txt) sets sensible defaults before any install_library() invocation.

If not, consider:

set(CONFIG_LIBS_DEST_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/ystdlib" CACHE PATH "…")
set(CONFIG_LIBS_INPUT_DIR "${PROJECT_SOURCE_DIR}/cmake"            CACHE PATH "…")
cmake/ystdlib/libs/wrapped_facade_headers-config.cmake.in (1)

1-4: Clean and consistent config file implementation.

The include guard and target inclusion pattern follows CMake best practices. The implementation is correct and consistent with the modular config system design.

cmake/ystdlib/libs/io_interface-config.cmake.in (1)

1-6: Proper dependency handling and include guard implementation.

The config file correctly uses include_guard(GLOBAL) and includes the dependency config file (wrapped_facade_headers-config.cmake) rather than the target file directly. This addresses previous review concerns and follows CMake best practices.

cmake/ystdlib/libs/containers-config.cmake.in (1)

1-4: Consistent and well-structured config file.

The implementation follows the established pattern with proper include guard and target inclusion. It's consistent with the other library config files in the project.

cmake/ystdlib/libs/error_handling-config.cmake.in (1)

1-6: Well-structured CMake package configuration template.

The implementation follows CMake best practices with proper include guard, dependency management using find_dependency, and target inclusion. The template variable substitution approach is standard and will work correctly during installation.

src/ystdlib/error_handling/CMakeLists.txt (5)

1-4: Good practice setting CMake policy for Boost configuration.

Setting CMP0167 to "NEW" correctly ensures the modern BoostConfig.cmake package configuration is preferred, which aligns well with the new build system approach.


14-24: Excellent migration to the new library helper function.

The transition from the old library creation approach to add_cpp_library is well-executed. The namespace, headers, and dependencies are properly configured for the new modular build system.


26-37: Proper conditional test setup with new helper function.

The test configuration correctly uses the new add_catch2_tests helper function and is properly guarded by the ystdlib_ENABLE_TESTS flag. Good to see the header files are no longer included in the SOURCES list, addressing the previous review concern.


39-44: Well-configured library installation setup.

The install_library call correctly specifies the namespace, configuration directories, and follows the new installation pattern established in the restructured build system.


5-12: Verify BOOST_MIN_VERSION variable is defined in parent scope.

The Boost dependency setup looks good, but ensure that BOOST_MIN_VERSION is properly defined in the root CMakeLists.txt or parent scope, as this variable name differs from previous references to MIN_BOOST_VERSION in past comments.

#!/bin/bash
# Description: Verify BOOST_MIN_VERSION variable is defined and used consistently
# Expected: Find definition of BOOST_MIN_VERSION in root CMakeLists.txt or parent files

echo "Searching for BOOST_MIN_VERSION definition:"
rg -A 3 -B 3 "BOOST_MIN_VERSION.*=" 

echo -e "\nSearching for all BOOST_MIN_VERSION usage:"
rg "BOOST_MIN_VERSION"

echo -e "\nSearching for any MIN_BOOST_VERSION references:"
rg "MIN_BOOST_VERSION"

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (3)
cmake/ystdlib-helpers.cmake (3)

24-29: Regex still too narrow & case-sensitive

The header-detection pattern only matches .h/.hpp in lowercase. Upper-case extensions and common variants like .hh, .hxx, or mixed-case names will be treated as “source” files and mark a header-only library as non-interface.

A broader, case-insensitive regex was suggested previously and remains unaddressed.


162-163: Hard-coded RUNTIME_OUTPUT_DIRECTORY breaks multi-config generators

Single-config paths work, but Visual Studio/Xcode expect RUNTIME_OUTPUT_DIRECTORY_<CONFIG>.
Wrap the path in a $<CONFIG> generator expression or set the per-config property instead.


202-203: Install rule still emits warnings for INTERFACE libraries

install(TARGETS … LIBRARY ARCHIVE RUNTIME …) is executed unconditionally.
For header-only (INTERFACE) targets this produces “no artifacts to install” warnings.
Guard the call with if(NOT TARGET_PROPERTY STREQUAL "INTERFACE_LIBRARY") or split installation logic.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a6d8f2b and f544f70.

📒 Files selected for processing (1)
  • cmake/ystdlib-helpers.cmake (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
cmake/ystdlib-helpers.cmake (2)
Learnt from: davidlion
PR: y-scope/ystdlib-cpp#65
File: cmake/ystdlib-helpers.cmake:105-113
Timestamp: 2025-06-16T16:05:45.088Z
Learning: In CMake, using target_sources() with PUBLIC and FILE_SET HEADERS on INTERFACE targets is valid and equivalent to using INTERFACE. FILE_SET HEADERS are treated as usage requirements, not compilation sources, so they don't cause errors on INTERFACE targets in modern CMake versions like 3.31.
Learnt from: davidlion
PR: y-scope/ystdlib-cpp#65
File: cmake/ystdlib-helpers.cmake:105-113
Timestamp: 2025-06-16T16:02:19.821Z
Learning: In CMake, using target_sources() with PUBLIC and FILE_SET HEADERS on INTERFACE targets is valid and equivalent to using INTERFACE. FILE_SET HEADERS are treated as usage requirements, not compilation sources, so they don't cause errors on INTERFACE targets in modern CMake versions like 3.31.

Copy link
Member

@kirkrodrigues kirkrodrigues left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, let's also not quote string literals that don't contain spaces. Up to you if you want to leave that to a future PR since it is a bit nitpick-y at this point.

Co-authored-by: kirkrodrigues <[email protected]>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (5)
CMakeLists.txt (5)

55-63: Initialise ystdlib_IS_TOP_LEVEL before evaluation

ystdlib_IS_TOP_LEVEL is referenced here without a prior set().
When this file is included as a sub-project the variable is undefined, so the branch is always skipped and CTest is never enabled, potentially masking tests and dependency logic.

+# Safely determine if we are the root project
+if(NOT DEFINED ystdlib_IS_TOP_LEVEL)
+    set(ystdlib_IS_TOP_LEVEL
+        "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
+endif()
+
 if(ystdlib_IS_TOP_LEVEL)

41-48: Expose allowed library names to CMake-GUI

Nice touch exposing ystdlib_LIBRARIES as a cache variable.
Add STRINGS so users get a drop-down in ccmake/CMake-GUI:

set_property(CACHE ystdlib_LIBRARIES PROPERTY STRINGS
    containers error_handling io_interface wrapped_facade_headers)

88-90: BOOST_MIN_VERSION is dead code

The variable is set but never referenced (Boost is not even located).
Delete it or wire it into find_package(Boost …); otherwise it only clutters the cache.

-set(BOOST_MIN_VERSION "1.81.0")

105-110: Add PATH_VARS to avoid absolute paths in generated config

Without PATH_VARS, configure_package_config_file() bakes absolute build-time paths into the installed ystdlib-config.cmake, breaking relocatability.

 configure_package_config_file(
     "${CMAKE_CURRENT_LIST_DIR}/${CONFIG_PATH_SUFFIX}/${CONFIG_FILE_PREFIX}.cmake.in"
     "${CONFIG_OUTPUT_PATH}"
+    PATH_VARS CONFIG_INSTALL_DIR
     INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}"
 )

Make sure the template refers to @CONFIG_INSTALL_DIR@.


29-31: Collapse the multiline fatal-error message

The back-slash continuation is unnecessary and hurts readability.

-    "${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION} is too low. Must be at \
-        least ${ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION}."
+    "${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION} "
+    "is too low. Must be at least ${ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION}."
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db7d25a and f13a591.

📒 Files selected for processing (1)
  • CMakeLists.txt (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
CMakeLists.txt (1)
Learnt from: PacificViking
PR: y-scope/ystdlib-cpp#65
File: CMakeLists.txt:87-88
Timestamp: 2025-06-06T15:01:53.987Z
Learning: The y-scope/ystdlib-cpp project uses lowercase `ystdlib_` prefix for project-specific CMake variables (e.g., `ystdlib_VERSION`, `ystdlib_BUILD_TESTING`, `ystdlib_INSTALL_CONFIG_DIR`) following the current naming convention standards.

Comment on lines +65 to 72
if(BUILD_TESTING AND ystdlib_BUILD_TESTING)
set(ystdlib_ENABLE_TESTS ON)
endif()

find_package(Boost REQUIRED)
if(Boost_FOUND)
message(STATUS "Found Boost ${Boost_VERSION}.")
endif()

if(YSTDLIB_CPP_ENABLE_TESTS)
if(ystdlib_ENABLE_TESTS)
find_package(Catch2 3.8.0 REQUIRED)
if(Catch2_FOUND)
message(STATUS "Found Catch2 ${Catch2_VERSION}.")
else()
message(FATAL_ERROR "Could not find libraries for Catch2.")
endif()
message(STATUS "Found Catch2 ${Catch2_VERSION}.")
include(Catch)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Guard use of BUILD_TESTING when the project is a sub-directory

BUILD_TESTING is only defined after a call to include(CTest).
If this project is embedded via add_subdirectory and ystdlib_IS_TOP_LEVEL is false, include(CTest) is never executed, making BUILD_TESTING unknown here and triggering a CMake error on some policies.

Add a default:

if(NOT DEFINED BUILD_TESTING)
    set(BUILD_TESTING OFF)
endif()

before the if(BUILD_TESTING AND ystdlib_BUILD_TESTING) check.
This keeps the logic safe in all embedding scenarios.

🤖 Prompt for AI Agents
In CMakeLists.txt around lines 65 to 72, the variable BUILD_TESTING may be
undefined if the project is included as a subdirectory without calling
include(CTest), causing CMake errors. To fix this, add a check before the
existing if statement to set BUILD_TESTING to OFF if it is not defined. This
ensures the subsequent conditional logic using BUILD_TESTING is safe in all
embedding scenarios.

@davidlion davidlion requested a review from kirkrodrigues June 25, 2025 14:38
Copy link
Member

@kirkrodrigues kirkrodrigues left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the PR title, how about:

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

@davidlion davidlion changed the title build(cmake)!: Add support for installation and usage in other CMake projects as a library; Add example CMake project to validate this case. build(cmake)!: Add support for installation and usage as a library in other CMake projects; Add example project to test this use case. Jun 25, 2025
@davidlion davidlion merged commit 0ae886c into y-scope:main Jun 25, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet