feat(cmake): find_package(mrdocs) - #1262
Conversation
find_package(mrdocs) was incorrect and untested. The exported configuration was an old placeholder we never updated, so a consumer find_package(mrdocs) failed. This commit implements this feature so projects can consume mrdocs as an external library to build applications, extensions, and plugins. To make the package useful, we had to bundle the private dependencies (LLVM, Clang, JerryScript, Lua) into the mrdocs library. This is so a consumer can link mrdocs without installing the exact toolchain it was built with. Otherwise, extension users would be required to build and install mrdocs and all its dependencies from source. The change required a reorganization in the src/CMakeLists.txt scripts, as many options were hard-coded and non-idiomatic in ways that don't generalize for an installed package. We remove the old data/cmake/MrDocs.cmake / add_mrdocs() helper, as it was contradictory and hasn't been necessary for the project or maintained for years. It provided no benefit over a regular CMake custom target and had to be kept in sync with the CLI. find_package now sets MRDOCS_EXECUTABLE, making it trivial to create custom targets. We also had to add an option to customize the clang-resource-dir so the installation can remain consistent with the canonical installation directory layout. We added tests/cmake, a standalone find_package(mrdocs) project that links mrdocs::mrdocs-core into a small program and runs the installed binary over its own source. It is exercised in the regular CI build and the release build.
|
| Scope | Lines Δ% | Lines Δ | Lines + | Lines - | Files Δ | Files + | Files ~ | Files ↔ | Files - |
|---|---|---|---|---|---|---|---|---|---|
| 🛠️ Source | 49% | 1015 | 540 | 475 | 23 | 2 | 20 | - | 1 |
| 🧰 Tooling | 20% | 419 | 289 | 130 | 7 | 2 | 5 | - | - |
| 📦 Other | 9% | 195 | 175 | 20 | 8 | 6 | 2 | - | - |
| 🏗️ Build | 7% | 137 | 85 | 52 | 2 | - | 2 | - | - |
| 📄 Docs | 6% | 129 | 106 | 23 | 6 | 1 | 5 | - | - |
| 📚 Examples | 5% | 111 | 75 | 36 | 10 | - | 10 | - | - |
| ⚙️ CI | 4% | 82 | 80 | 2 | 3 | - | 3 | - | - |
| Total | 100% | 2088 | 1350 | 738 | 59 | 11 | 47 | - | 1 |
Legend: Files + (added), Files ~ (modified), Files ↔ (renamed), Files - (removed)
🔝 Top Files
- src/CMakeLists.txt (Source): 372 lines Δ (+150 / -222)
- data/cmake/MrDocs.cmake (Source): 172 lines Δ (+0 / -172)
- src/mrdocs/Config/ReferenceDirectories.cpp (Source): 133 lines Δ (+133 / -0)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1262 +/- ##
========================================
Coverage 83.12% 83.12%
========================================
Files 35 35
Lines 3662 3662
Branches 844 844
========================================
Hits 3044 3044
Misses 410 410
Partials 208 208
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
An automated preview of the documentation is available at https://1262.mrdocs.prtest2.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-08-20 00:08:44 UTC |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c360c678a4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
find_package(mrdocs) was incorrect and untested. The exported configuration was an old placeholder we never updated, so a consumer find_package(mrdocs) failed. This PR, which took much longer than I predicted, implements this feature so projects can consume mrdocs as an external library to build applications, extensions, and plugins.
Changes
To make the package useful, we had to bundle the private dependencies (LLVM, Clang, JerryScript, Lua) into the mrdocs library. This is so a consumer can link mrdocs without installing the exact toolchain it was built with. Otherwise, extension users would be required to build and install mrdocs and all its dependencies from source.
The change required a reorganization in the src/CMakeLists.txt scripts, as many options were hard-coded and non-idiomatic in ways that don't generalize for an installed package. We remove the old data/cmake/MrDocs.cmake / add_mrdocs() helper, as it was contradictory and hasn't been necessary for the project or maintained for years. It provided no benefit over a regular CMake custom target and had to be kept in sync with the CLI. find_package now sets MRDOCS_EXECUTABLE, making it trivial to create custom targets. We also had to add an option to customize the clang-resource-dir so the installation can remain consistent with the canonical installation directory layout.
We also had to fix small pedantic warnings that emerged when we fixed errors in how we import LLVM.
Testing
We added tests/cmake, a standalone find_package(mrdocs) project that links mrdocs::mrdocs-core into a small program and runs the installed binary over its own source. It is exercised in the regular CI build and the release build.
Documentation
The examples for mrdocs as a library use the actual snippets from the tests that use find_package. The contributing guide is also updated to reflect the changes to the layout.