Fix CMake consumption: install support, generator expressions, standa…#167
Fix CMake consumption: install support, generator expressions, standa…#167sgerbino merged 1 commit intocppalliance:developfrom
Conversation
…lone builds - Add boost_install() for superproject builds and standalone install with CMakePackageConfigHelpers when deps are pre-installed - Use BUILD_INTERFACE/INSTALL_INTERFACE generator expressions for include directories - Set EXPORT_NAME on all targets (corosio, corosio_wolfssl, corosio_openssl) - Add cmake/boost_corosio-config.cmake.in with find_dependency for Threads, boost_capy, and conditional OpenSSL/WolfSSL - Replace hardcoded GIT_TAG master with dynamic branch matching for capy FetchContent, falling back to develop - Separate capy resolution from Boost: find_package(boost_capy) or FetchContent for capy alone, Boost no longer fetched for builds - Remove BOOST_SRC_DIR resolution chain, stale Boost::core test dep, unused BOOST_COROSIO_BUILD_DOCS option, BOOST_COROSIO_DEPENDENCIES indirection, and set(__ignore__) workaround - Delete CMakePresets.json - Remove ASCII-art section dividers - Update README quickstart to match capy's pattern
📝 WalkthroughWalkthroughThe pull request refactors CMake configuration to simplify Boost/CAPY bootstrap logic, remove standalone presets, introduce branch-aware capy fetching via FetchContent, add explicit BUILD_INTERFACE/INSTALL_INTERFACE directives for include directories, and establish new target export names and dependency discovery configuration. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
An automated preview of the documentation is available at https://167.corosio.prtest3.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-02-23 23:03:35 UTC |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CMakeLists.txt`:
- Around line 30-74: When CMake < 3.14 the command FetchContent_MakeAvailable
may be unavailable and currently will break configuration when Boost::capy isn't
installed; update the block that calls FetchContent_MakeAvailable to check for
the command and fall back to FetchContent_Populate + add_subdirectory of the
populated source dir. Specifically, keep the existing FetchContent_Declare(...)
and then replace the unconditional FetchContent_MakeAvailable(capy) call with:
if(COMMAND FetchContent_MakeAvailable) FetchContent_MakeAvailable(capy) else
FetchContent_Populate(capy) add_subdirectory(${capy_SOURCE_DIR}
${capy_BINARY_DIR}) endif(), ensuring the earlier cached vars
(BOOST_COROSIO_CAPY_TAG, BOOST_CAPY_BUILD_TESTS, BOOST_CAPY_BUILD_EXAMPLES)
remain set before the fetch.
In `@README.md`:
- Around line 37-41: Change the "## Requirements" block into a checklist format
and wrap each tool/version in inline code; specifically update the existing
items ("CMake 3.8 or later", "C++20 compiler (GCC 12+, Clang 17+, MSVC 14.34+)",
"Ninja (recommended) or other CMake generator") to bullet checklist lines like
"- [ ] `CMake` >= `3.8`", "- [ ] `C++20` compiler: `GCC` >= `12`, `Clang` >=
`17`, or `MSVC` >= `14.34`", and "- [ ] `Ninja` (recommended) or another `CMake`
generator", ensuring tool names, versions and recommendations use inline code
formatting consistently.
- Around line 12-35: Rewrite the "Standalone build" and "Consume via CMake"
blocks into numbered gerund steps with a brief introductory sentence, add a
one-line gerund title before each code block (e.g., "Cloning the repository",
"Configuring and building", "Adding corosio via FetchContent"), and follow each
block with 1–2 sentences explaining what the commands do and why they’re needed;
in the CMake section explicitly call out which values must be customized (e.g.,
GIT_TAG, target names passed to target_link_libraries), mention that the build
type and generator can be changed, and keep the same example commands and
symbols (cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release, cmake --build
build, FetchContent_Declare, FetchContent_MakeAvailable, target_link_libraries
Boost::corosio) so readers can locate the exact snippets to update.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
test/unit/CMakeLists.txtis excluded by!**/test/**
📒 Files selected for processing (4)
CMakeLists.txtCMakePresets.jsonREADME.mdcmake/boost_corosio-config.cmake.in
💤 Files with no reviewable changes (1)
- CMakePresets.json
| if(NOT TARGET Boost::capy) | ||
| find_package(boost_capy QUIET) | ||
| endif() | ||
| if(NOT TARGET Boost::capy) | ||
| include(FetchContent) | ||
|
|
||
| # Fetch capy from cppalliance/capy (not part of Boost) | ||
| message(STATUS "Fetching capy...") | ||
| set(BOOST_CAPY_BUILD_TESTS OFF CACHE BOOL "" FORCE) | ||
| set(BOOST_CAPY_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) | ||
| FetchContent_MakeAvailable(capy) | ||
| # Match capy branch to corosio's current branch when possible | ||
| if(NOT DEFINED CACHE{BOOST_COROSIO_CAPY_TAG}) | ||
| execute_process( | ||
| COMMAND git rev-parse --abbrev-ref HEAD | ||
| WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
| OUTPUT_VARIABLE _corosio_branch | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ERROR_QUIET | ||
| RESULT_VARIABLE _git_result) | ||
| if(_git_result EQUAL 0 AND _corosio_branch) | ||
| execute_process( | ||
| COMMAND git ls-remote --heads | ||
| https://github.com/cppalliance/capy.git | ||
| ${_corosio_branch} | ||
| OUTPUT_VARIABLE _capy_has_branch | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ERROR_QUIET) | ||
| if(_capy_has_branch) | ||
| set(_default_capy_tag "${_corosio_branch}") | ||
| endif() | ||
| endif() | ||
| if(NOT DEFINED _default_capy_tag) | ||
| set(_default_capy_tag "develop") | ||
| endif() | ||
| endif() | ||
| set(BOOST_COROSIO_CAPY_TAG "${_default_capy_tag}" CACHE STRING | ||
| "Git tag/branch for capy when fetching via FetchContent") | ||
|
|
||
| set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${boost_SOURCE_DIR}/tools/cmake/include") | ||
| endif () | ||
| endif () | ||
| unset(CMAKE_FOLDER) | ||
| endif () | ||
| message(STATUS "Fetching capy...") | ||
| set(BOOST_CAPY_BUILD_TESTS OFF CACHE BOOL "" FORCE) | ||
| set(BOOST_CAPY_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) | ||
| FetchContent_Declare( | ||
| capy | ||
| GIT_REPOSITORY https://github.com/cppalliance/capy.git | ||
| GIT_TAG ${BOOST_COROSIO_CAPY_TAG} | ||
| GIT_SHALLOW TRUE | ||
| ) | ||
| FetchContent_MakeAvailable(capy) | ||
| endif() |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
CMake FetchContent_MakeAvailable version requirement when introduced
💡 Result:
FetchContent_MakeAvailable() was added in CMake 3.14, so using it requires CMake ≥ 3.14 (typically expressed as cmake_minimum_required(VERSION 3.14) or newer). [1] [2]
Sources:
[1] CMake FetchContent module docs (“FetchContent_MakeAvailable … Added in version 3.14.”) (cmake.org)
[2] CMake 3.14 release notes (FetchContent gained FetchContent_MakeAvailable()) (cmake.org)
Citations:
- 1: https://cmake.org/cmake/help/git-stage/module/FetchContent.html
- 2: https://cmake.org/cmake/help/latest/release/3.14.html?utm_source=openai
🏁 Script executed:
# Check the actual cmake_minimum_required version in the CMakeLists.txt
fd CMakeLists.txt --type f | head -1 | xargs cat -n | head -20Repository: cppalliance/corosio
Length of output: 894
Guard FetchContent_MakeAvailable for CMake < 3.14.
FetchContent_MakeAvailable was added in CMake 3.14, but the project declares cmake_minimum_required(VERSION 3.8...3.31). This causes configuration to fail on CMake 3.8–3.13 whenever Boost::capy is not preinstalled. Add a version guard, provide a fallback, or raise the minimum version.
🔧 Minimal guard example
if(NOT TARGET Boost::capy)
include(FetchContent)
+ if(CMAKE_VERSION VERSION_LESS 3.14)
+ message(FATAL_ERROR
+ "FetchContent_MakeAvailable requires CMake 3.14+ when boost_capy is not preinstalled.")
+ endif()📝 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.
| if(NOT TARGET Boost::capy) | |
| find_package(boost_capy QUIET) | |
| endif() | |
| if(NOT TARGET Boost::capy) | |
| include(FetchContent) | |
| # Fetch capy from cppalliance/capy (not part of Boost) | |
| message(STATUS "Fetching capy...") | |
| set(BOOST_CAPY_BUILD_TESTS OFF CACHE BOOL "" FORCE) | |
| set(BOOST_CAPY_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) | |
| FetchContent_MakeAvailable(capy) | |
| # Match capy branch to corosio's current branch when possible | |
| if(NOT DEFINED CACHE{BOOST_COROSIO_CAPY_TAG}) | |
| execute_process( | |
| COMMAND git rev-parse --abbrev-ref HEAD | |
| WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
| OUTPUT_VARIABLE _corosio_branch | |
| OUTPUT_STRIP_TRAILING_WHITESPACE | |
| ERROR_QUIET | |
| RESULT_VARIABLE _git_result) | |
| if(_git_result EQUAL 0 AND _corosio_branch) | |
| execute_process( | |
| COMMAND git ls-remote --heads | |
| https://github.com/cppalliance/capy.git | |
| ${_corosio_branch} | |
| OUTPUT_VARIABLE _capy_has_branch | |
| OUTPUT_STRIP_TRAILING_WHITESPACE | |
| ERROR_QUIET) | |
| if(_capy_has_branch) | |
| set(_default_capy_tag "${_corosio_branch}") | |
| endif() | |
| endif() | |
| if(NOT DEFINED _default_capy_tag) | |
| set(_default_capy_tag "develop") | |
| endif() | |
| endif() | |
| set(BOOST_COROSIO_CAPY_TAG "${_default_capy_tag}" CACHE STRING | |
| "Git tag/branch for capy when fetching via FetchContent") | |
| set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${boost_SOURCE_DIR}/tools/cmake/include") | |
| endif () | |
| endif () | |
| unset(CMAKE_FOLDER) | |
| endif () | |
| message(STATUS "Fetching capy...") | |
| set(BOOST_CAPY_BUILD_TESTS OFF CACHE BOOL "" FORCE) | |
| set(BOOST_CAPY_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) | |
| FetchContent_Declare( | |
| capy | |
| GIT_REPOSITORY https://github.com/cppalliance/capy.git | |
| GIT_TAG ${BOOST_COROSIO_CAPY_TAG} | |
| GIT_SHALLOW TRUE | |
| ) | |
| FetchContent_MakeAvailable(capy) | |
| endif() | |
| if(NOT TARGET Boost::capy) | |
| find_package(boost_capy QUIET) | |
| endif() | |
| if(NOT TARGET Boost::capy) | |
| include(FetchContent) | |
| if(CMAKE_VERSION VERSION_LESS 3.14) | |
| message(FATAL_ERROR | |
| "FetchContent_MakeAvailable requires CMake 3.14+ when boost_capy is not preinstalled.") | |
| endif() | |
| # Match capy branch to corosio's current branch when possible | |
| if(NOT DEFINED CACHE{BOOST_COROSIO_CAPY_TAG}) | |
| execute_process( | |
| COMMAND git rev-parse --abbrev-ref HEAD | |
| WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
| OUTPUT_VARIABLE _corosio_branch | |
| OUTPUT_STRIP_TRAILING_WHITESPACE | |
| ERROR_QUIET | |
| RESULT_VARIABLE _git_result) | |
| if(_git_result EQUAL 0 AND _corosio_branch) | |
| execute_process( | |
| COMMAND git ls-remote --heads | |
| https://github.com/cppalliance/capy.git | |
| ${_corosio_branch} | |
| OUTPUT_VARIABLE _capy_has_branch | |
| OUTPUT_STRIP_TRAILING_WHITESPACE | |
| ERROR_QUIET) | |
| if(_capy_has_branch) | |
| set(_default_capy_tag "${_corosio_branch}") | |
| endif() | |
| endif() | |
| if(NOT DEFINED _default_capy_tag) | |
| set(_default_capy_tag "develop") | |
| endif() | |
| endif() | |
| set(BOOST_COROSIO_CAPY_TAG "${_default_capy_tag}" CACHE STRING | |
| "Git tag/branch for capy when fetching via FetchContent") | |
| message(STATUS "Fetching capy...") | |
| set(BOOST_CAPY_BUILD_TESTS OFF CACHE BOOL "" FORCE) | |
| set(BOOST_CAPY_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) | |
| FetchContent_Declare( | |
| capy | |
| GIT_REPOSITORY https://github.com/cppalliance/capy.git | |
| GIT_TAG ${BOOST_COROSIO_CAPY_TAG} | |
| GIT_SHALLOW TRUE | |
| ) | |
| FetchContent_MakeAvailable(capy) | |
| endif() |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@CMakeLists.txt` around lines 30 - 74, When CMake < 3.14 the command
FetchContent_MakeAvailable may be unavailable and currently will break
configuration when Boost::capy isn't installed; update the block that calls
FetchContent_MakeAvailable to check for the command and fall back to
FetchContent_Populate + add_subdirectory of the populated source dir.
Specifically, keep the existing FetchContent_Declare(...) and then replace the
unconditional FetchContent_MakeAvailable(capy) call with: if(COMMAND
FetchContent_MakeAvailable) FetchContent_MakeAvailable(capy) else
FetchContent_Populate(capy) add_subdirectory(${capy_SOURCE_DIR}
${capy_BINARY_DIR}) endif(), ensuring the earlier cached vars
(BOOST_COROSIO_CAPY_TAG, BOOST_CAPY_BUILD_TESTS, BOOST_CAPY_BUILD_EXAMPLES)
remain set before the fetch.
| ### Standalone build | ||
|
|
||
| ```bash | ||
| git clone https://github.com/cppalliance/corosio.git | ||
| cd corosio | ||
| cmake --preset standalone | ||
| cmake --build --preset standalone | ||
| cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release | ||
| cmake --build build | ||
| ``` | ||
|
|
||
| This downloads Boost 1.90 and Capy automatically. The library is built to `out/standalone/`. | ||
| ### Consume via CMake | ||
|
|
||
| Use `FetchContent` or `add_subdirectory` to add corosio to your project, | ||
| then link against `Boost::corosio`: | ||
|
|
||
| ```cmake | ||
| include(FetchContent) | ||
| FetchContent_Declare(corosio | ||
| GIT_REPOSITORY https://github.com/cppalliance/corosio.git | ||
| GIT_TAG develop | ||
| GIT_SHALLOW TRUE) | ||
| FetchContent_MakeAvailable(corosio) | ||
|
|
||
| target_link_libraries(my_app Boost::corosio) | ||
| ``` |
There was a problem hiding this comment.
Add step framing and command/code explanations in Quick Start.
The new sections list commands/snippets without step titles in gerund form, intro/transition sentences, or explanations before/after each block. Also call out what readers must customize (e.g., GIT_TAG). Please restructure into steps and explain what each command/snippet does and why.
💡 Example structure (apply similarly to the rest of the section)
-### Standalone build
+### Step 1 — Building a standalone library
+Start by cloning the repository so you can configure it locally.
```bash
git clone https://github.com/cppalliance/corosio.git
cd corosio
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build+This sequence clones corosio, configures a Release build in build/ with the Ninja generator, and compiles the library. In the next step, you will consume the built targets from your project.
</details>
As per coding guidelines, “Use gerund phrases (-ing words) for step titles in documentation to describe what readers will accomplish,” “Provide technically detailed and correct documentation where every command includes detailed explanation, and every code block is followed by prose explaining what it does and why,” and “In documentation, highlight items the reader must change (example URLs, version numbers, modified lines) and make clear what needs customization.”
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against the current code and only fix it if needed.
In @README.md around lines 12 - 35, Rewrite the "Standalone build" and "Consume
via CMake" blocks into numbered gerund steps with a brief introductory sentence,
add a one-line gerund title before each code block (e.g., "Cloning the
repository", "Configuring and building", "Adding corosio via FetchContent"), and
follow each block with 1–2 sentences explaining what the commands do and why
they’re needed; in the CMake section explicitly call out which values must be
customized (e.g., GIT_TAG, target names passed to target_link_libraries),
mention that the build type and generator can be changed, and keep the same
example commands and symbols (cmake -B build -G Ninja
-DCMAKE_BUILD_TYPE=Release, cmake --build build, FetchContent_Declare,
FetchContent_MakeAvailable, target_link_libraries Boost::corosio) so readers can
locate the exact snippets to update.
</details>
<!-- fingerprinting:phantom:medusa:eagle -->
<!-- This is an auto-generated comment by CodeRabbit -->
| ## Requirements | ||
|
|
||
| - CMake 3.25 or later | ||
| - CMake 3.8 or later | ||
| - C++20 compiler (GCC 12+, Clang 17+, MSVC 14.34+) | ||
| - Ninja (recommended) or other CMake generator |
There was a problem hiding this comment.
Format Requirements as a checklist and use inline code for tools/versions.
Convert the prerequisites to a checklist and wrap tool names/versions in inline code for consistency and clarity.
✅ Suggested formatting
-## Requirements
-
-- CMake 3.8 or later
-- C++20 compiler (GCC 12+, Clang 17+, MSVC 14.34+)
-- Ninja (recommended) or other CMake generator
+## Requirements
+
+- [ ] `CMake` `3.8` or later
+- [ ] A `C++20` compiler such as `GCC` `12+`, `Clang` `17+`, or `MSVC` `14.34+`
+- [ ] `Ninja` (recommended) or another CMake generatorAs per coding guidelines, “Format prerequisites in documentation as a checklist with specific information” and “Use inline code formatting in documentation for command names, package names, file names and paths, example URLs, ports, and key presses.”
📝 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.
| ## Requirements | |
| - CMake 3.25 or later | |
| - CMake 3.8 or later | |
| - C++20 compiler (GCC 12+, Clang 17+, MSVC 14.34+) | |
| - Ninja (recommended) or other CMake generator | |
| ## Requirements | |
| - [ ] `CMake` `3.8` or later | |
| - [ ] A `C++20` compiler such as `GCC` `12+`, `Clang` `17+`, or `MSVC` `14.34+` | |
| - [ ] `Ninja` (recommended) or another CMake generator |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@README.md` around lines 37 - 41, Change the "## Requirements" block into a
checklist format and wrap each tool/version in inline code; specifically update
the existing items ("CMake 3.8 or later", "C++20 compiler (GCC 12+, Clang 17+,
MSVC 14.34+)", "Ninja (recommended) or other CMake generator") to bullet
checklist lines like "- [ ] `CMake` >= `3.8`", "- [ ] `C++20` compiler: `GCC` >=
`12`, `Clang` >= `17`, or `MSVC` >= `14.34`", and "- [ ] `Ninja` (recommended)
or another `CMake` generator", ensuring tool names, versions and recommendations
use inline code formatting consistently.
|
GCOVR code coverage report https://167.corosio.prtest3.cppalliance.org/gcovr/index.html Build time: 2026-02-23 23:05:54 UTC |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #167 +/- ##
===========================================
- Coverage 82.28% 82.06% -0.23%
===========================================
Files 70 70
Lines 5876 5876
===========================================
- Hits 4835 4822 -13
- Misses 1041 1054 +13 see 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
…lone builds
Resolves #161.
Summary by CodeRabbit
Documentation
Chores