Repository navigation
[beman-tidy] Implement cmake.config check - #341
neatudarius wants to merge 5 commits into
Conversation
d0c75b5 to
46511c7
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds the new cmake.config Beman Standard check to validate that a project’s CMakeLists.txt contains a beman_install_library() call referencing the library name, and introduces tests/fixtures to exercise the new behavior.
Changes:
- Implement
CMakeConfigCheckand register it ascmake.config. - Add pytest coverage for valid/invalid
cmake.configscenarios. - Add an invalid
CMakeListsfixture missing thebeman_install_library()call.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
beman_tidy/lib/checks/beman_standard/cmake.py |
Adds the cmake.config check implementation and a stub fix() method. |
tests/lib/checks/beman_standard/cmake/test_cmake.py |
Adds new tests for cmake.config (valid/invalid) and a skipped fix-inplace test. |
tests/lib/checks/beman_standard/cmake/data/invalid/invalid-config-v1.txt |
Adds an invalid CMake fixture missing beman_install_library(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def fix(self): | ||
| self.log( | ||
| "Please update the CMakeLists.txt file so that it calls beman_install_library() with the library name. " | ||
| "See https://github.com/bemanproject/beman/blob/main/docs/beman_standard.md#cmakeconfig for more information." | ||
| ) |
There was a problem hiding this comment.
Not changed: fix() stays log-only, like the other cmake.* checks. Generating install logic in a project's CMakeLists.txt automatically is too invasive. Updated the description to say this PR covers the dry-run check of #292.
f5d2eff to
2587255
Compare
2587255 to
5ae30d0
Compare
…make-config # Conflicts: # tests/lib/checks/beman_standard/cmake/test_cmake.py
…ig package
Resolve ${PROJECT_NAME} and simple set() variables in beman_install_library(), match the name exactly, and accept install(EXPORT ... NAMESPACE beman::) plus an installed <library_name>-config.cmake.
There was a problem hiding this comment.
🟡 Changes recommended
The review found an issue that should be addressed before approval.
5 open issues
Raw parsing also includes commands inside uncalled functions and inactive blocks. Consequently,… · New Resolve variables at the point where each command executes, rather than using the final assignments… · New Normalize quoted CMake arguments before matching them. Parsed values retain quotes (the existing… · New Abeman::namespace alone does not establish that the package exportsbeman::<short_name>. The… · New The PR description says it “Implements #292”, butcmake.config’sfix()is still unimplemented…
1 resolved since last review
Review effort: Balanced
| commands = [ | ||
| item for item in self.get_cmake_parse_raw() if isinstance(item, Command) | ||
| ] |
| commands = [ | ||
| item for item in self.get_cmake_parse_raw() if isinstance(item, Command) | ||
| ] | ||
| variables = self._collect_variables(commands) |
| variables[command.args[0].value] = command.args[1].value | ||
| return variables | ||
|
|
||
| def _resolve(self, value, variables): |
| if keyword.upper() == "NAMESPACE" and value == "beman::": | ||
| exports_beman_namespace = True |
beman_install_library() must list the library target and keep the beman:: namespace; a hand-written package must also set EXPORT_NAME and use beman:: on the library's export set. Resolve list and CACHE/PARENT_SCOPE set() values.


Implements the check() (dry-run) part of #292. fix() stays log-only, like the other cmake.* checks.