Skip to content

Allow system name reinit#4

Merged
koudis merged 5 commits intomainfrom
allow_system_name_reinit
Jan 10, 2026
Merged

Allow system name reinit#4
koudis merged 5 commits intomainfrom
allow_system_name_reinit

Conversation

@koudis
Copy link
Member

@koudis koudis commented Jan 10, 2026

Summary by CodeRabbit

  • New Features

    • Configurable system-name override: option to allow or prevent changing the system name after initial setup; when allowed, overrides emit a warning and same-name re-initialization is permitted silently.
  • Installation

    • Installer now enforces the override policy and will stop with an error if override behavior is disallowed during install.
  • Documentation

    • Added Configuration Variables section with usage examples.
  • Tests

    • Added tests covering override and re-initialization scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 10, 2026

Warning

Rate limit exceeded

@koudis has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 32 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 540cec6 and b674ff0.

📒 Files selected for processing (4)
  • CMCONF.cmake
  • README.md
  • test/CMakeLists.txt
  • test/test_cases/fail/uninstall_with_override_allowed/CMakeLists.txt

Walkthrough

Adds a new public cache option CMCONF_SYSTEM_NAME_OVERRIDE_ALLOWED to allow system-name overrides when enabled; when disabled attempts to change the system name remain fatal. Propagates the setting into installation and adds tests and README docs reflecting the new behavior.

Changes

Cohort / File(s) Summary
Core Configuration
CMCONF.cmake, resource/CMakeLists.txt.in
Adds CMCONF_SYSTEM_NAME_OVERRIDE_ALLOWED (CACHE BOOL OFF). Alters system-name set flow to warn-and-allow when ON, keep fatal when OFF. Installation template checks and propagates the option into the install invocation.
Documentation
README.md
Adds "Configuration Variables" section and a table documenting CMCONF_INSTALL_AS_SYMLINK, CMCONF_UNINSTALL, CMCONF_SYSTEM_NAME_OVERRIDE_ALLOWED, CMCONF_SYSTEM_NAME with examples.
Test Registry
test/CMakeLists.txt
Registers three new tests: system_name_override_allowed, system_name_reinit_same, and install_with_override_allowed (fail case).
Tests — Override Allowed
test/test_cases/pass/system_name_override_allowed/CMakeLists.txt, test/test_cases/pass/system_name_override_allowed/test_config/CMakeLists.txt
New passing test exercising override path with CMCONF_SYSTEM_NAME_OVERRIDE_ALLOWED=ON, asserting a warning and final name equals overridden value.
Tests — Reinit Same Name
test/test_cases/pass/system_name_reinit_same/CMakeLists.txt
New passing test calling CMCONF_INIT_SYSTEM multiple times (including identical names) and asserting final system name is unchanged.
Tests — Install Override Blocked
test/test_cases/fail/install_with_override_allowed/CMakeLists.txt
New failing test ensuring installation aborts/errors when override is attempted during install (validates error message).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hop through CMake fields so bright,

A flag lets names switch day to night.
Install keeps watch, forbids the sly,
But if you ask, a warning's nigh.
Hooray for tests that prove it's right! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Allow system name reinit' is partially related to the changeset. While reinitializing the system name is one aspect of the change, the primary feature is introducing the CMCONF_SYSTEM_NAME_OVERRIDE_ALLOWED configuration option that controls override behavior. The title understates the main contribution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch allow_system_name_reinit

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@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

🤖 Fix all issues with AI agents
In @README.md:
- Around line 84-103: Fix the typo and clarify
CMCONF_SYSTEM_NAME_OVERRIDE_ALLOWED behavior: change "occure" to "occurs" and
update the description for CMCONF_SYSTEM_NAME_OVERRIDE_ALLOWED to state that
when set during a normal CMake project configure it allows changing the system
name and emits a warning, but when used during installation via the example
config script (e.g., running CMCONF_EXAMPLEConfig.cmake with -P or with
CMCONF_INSTALL_AS_SYMLINK/CMCONF_UNINSTALL) it results in a configuration error;
reference the symbols CMCONF_SYSTEM_NAME_OVERRIDE_ALLOWED,
CMCONF_INSTALL_AS_SYMLINK, CMCONF_UNINSTALL, and CMCONF_SYSTEM_NAME in the
revised sentence.
- Line 101: Clarify the placeholder in the example command by replacing
`<CMakeProjectPath>` with a more descriptive label and short note; update the
example `cmake -DCMCONF_SYSTEM_NAME_OVERRIDE_ALLOWED=ON
-DCMCONF_SYSTEM_NAME=MY_EXAMPLE <CMakeProjectPath>` to use
`<path-to-cmake-project>` (or similar) and add a one-line parenthetical
explaining it refers to the directory containing the CMakeLists.txt / project
root to be configured (not the CMake binary or installation).
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81cb8ef and 2351f15.

📒 Files selected for processing (8)
  • CMCONF.cmake
  • README.md
  • resource/CMakeLists.txt.in
  • test/CMakeLists.txt
  • test/test_cases/fail/install_with_override_allowed/CMakeLists.txt
  • test/test_cases/pass/system_name_override_allowed/CMakeLists.txt
  • test/test_cases/pass/system_name_override_allowed/test_config/CMakeLists.txt
  • test/test_cases/pass/system_name_reinit_same/CMakeLists.txt
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-02T17:36:23.478Z
Learnt from: koudis
Repo: cmakelib/cmakelib-component-cmconf PR: 1
File: test/test_cases/fail/variable_not_defined/CMakeLists.txt:17-23
Timestamp: 2025-08-02T17:36:23.478Z
Learning: The cmake_language(DEFER) construct is not available in CMake script mode, only in project mode, making it unsuitable for tests that need to run in both modes.

Applied to files:

  • test/test_cases/fail/install_with_override_allowed/CMakeLists.txt
  • test/test_cases/pass/system_name_override_allowed/CMakeLists.txt
  • test/test_cases/pass/system_name_override_allowed/test_config/CMakeLists.txt
🔇 Additional comments (10)
test/test_cases/pass/system_name_override_allowed/test_config/CMakeLists.txt (1)

1-19: LGTM!

The test configuration correctly validates the override behavior: enabling CMCONF_SYSTEM_NAME_OVERRIDE_ALLOWED, initializing with two different system names, and verifying that the second name takes effect. The parent test file handles verifying the warning message output.

test/CMakeLists.txt (1)

24-25: LGTM!

New test cases are properly registered in their respective sections (pass/fail) and maintain consistency with the existing test structure.

Also applies to: 34-34

resource/CMakeLists.txt.in (1)

12-14: LGTM!

The guard correctly prevents configuration installation when CMCONF_SYSTEM_NAME_OVERRIDE_ALLOWED is enabled. The placement before the package config filename resolution ensures early failure with a clear error message.

test/test_cases/pass/system_name_override_allowed/CMakeLists.txt (1)

1-18: LGTM!

The test correctly validates that the warning message is emitted when overriding the system name. The regex pattern properly escapes brackets for CMake string processing and matches the expected _CMCONF_MESSAGE output format.

test/test_cases/pass/system_name_reinit_same/CMakeLists.txt (1)

1-24: LGTM!

Excellent test coverage for the case-insensitive re-initialization scenario. The test validates that calling CMCONF_INIT_SYSTEM with normalized-equivalent names ("TEST_REINIT" and "test_reinit") proceeds silently without errors or warnings, confirming the documented behavior.

test/test_cases/fail/install_with_override_allowed/CMakeLists.txt (1)

1-29: LGTM!

The test comprehensively validates the installation guard behavior: it triggers installation with override enabled, expects failure, and verifies the specific error message. The regex pattern correctly handles potential formatting variations in the error output.

CMCONF.cmake (4)

114-117: LGTM!

The new cache option is properly defined with appropriate type, default value (OFF for backward compatibility), and descriptive help text.


182-189: LGTM!

Documentation clearly explains the three scenarios: fatal error by default, warning with override when allowed, and silent re-initialization for identical names.


206-210: LGTM!

The override logic correctly branches based on CMCONF_SYSTEM_NAME_OVERRIDE_ALLOWED. The warning message includes both old and new system names, and execution continues to update the cache property on line 213.


504-506: LGTM!

Correctly propagates CMCONF_SYSTEM_NAME_OVERRIDE_ALLOWED to the child CMake process during installation. This ensures the guard in resource/CMakeLists.txt.in can detect and reject installation attempts when override is enabled.

koudis and others added 3 commits January 10, 2026 14:34
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@koudis koudis merged commit 5066f04 into main Jan 10, 2026
14 checks passed
@koudis koudis deleted the allow_system_name_reinit branch January 10, 2026 14:01
@coderabbitai coderabbitai bot mentioned this pull request Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments