Conversation
WalkthroughRefactors CMake build configuration to remove global compiler definitions/flags, adopt target-scoped compile/link options, enforce/announce build-type defaults, update file globbing with CONFIGURE_DEPENDS, and move test and library include/definitions from global scope into per-target scope. Build scripts now pass explicit CMAKE_BUILD_TYPE values. Changes
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/CMakeLists.txt`:
- Around line 26-28: The CMake check using CMAKE_BUILD_TYPE misses Debug mode on
multi-config generators; replace the CMAKE_BUILD_TYPE conditional with a
config-aware generator expression on the target (${SCOPESOURCE}) so the DEBUG
definition is added only for Debug configurations (e.g., use
target_compile_definitions(${SCOPESOURCE} PRIVATE $<$<CONFIG:Debug>:DEBUG>) or
the equivalent generator-expression form) to ensure DEBUG is defined when the
active configuration is Debug across single- and multi-config generators.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 351f20f9-9b4b-47c3-a6b8-92e6c9d85f35
📒 Files selected for processing (1)
src/CMakeLists.txt
| if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| target_compile_definitions(${SCOPESOURCE} PRIVATE DEBUG) | ||
| endif() |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify config-gating patterns for DEBUG in CMake files.
# Expected: avoid compile-definition gating via CMAKE_BUILD_TYPE;
# prefer generator expressions like $<$<CONFIG:Debug>:DEBUG>.
rg -n --type=cmake -C3 'CMAKE_BUILD_TYPE\s+STREQUAL\s+"Debug"|target_compile_definitions\s*\(.*DEBUG|\$<CONFIG:Debug>'Repository: ModbusScope/NotOnlyModbusScope
Length of output: 1695
Use config-aware DEBUG definition instead of CMAKE_BUILD_TYPE check.
Line 26 silently misses DEBUG on multi-config generators (notably Windows/Visual Studio), even for Debug builds. CMAKE_BUILD_TYPE is not populated in multi-config generators; use a generator expression tied to the active configuration instead.
Suggested fix
-if(CMAKE_BUILD_TYPE STREQUAL "Debug")
- target_compile_definitions(${SCOPESOURCE} PRIVATE DEBUG)
-endif()
+target_compile_definitions(${SCOPESOURCE} PRIVATE
+ $<$<CONFIG:Debug>:DEBUG>
+)📝 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(CMAKE_BUILD_TYPE STREQUAL "Debug") | |
| target_compile_definitions(${SCOPESOURCE} PRIVATE DEBUG) | |
| endif() | |
| target_compile_definitions(${SCOPESOURCE} PRIVATE | |
| $<$<CONFIG:Debug>:DEBUG> | |
| ) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/CMakeLists.txt` around lines 26 - 28, The CMake check using
CMAKE_BUILD_TYPE misses Debug mode on multi-config generators; replace the
CMAKE_BUILD_TYPE conditional with a config-aware generator expression on the
target (${SCOPESOURCE}) so the DEBUG definition is added only for Debug
configurations (e.g., use target_compile_definitions(${SCOPESOURCE} PRIVATE
$<$<CONFIG:Debug>:DEBUG>) or the equivalent generator-expression form) to ensure
DEBUG is defined when the active configuration is Debug across single- and
multi-config generators.
Summary by CodeRabbit