Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the dependency-discovery scoping change.
No open issues 🎉
What changed in this PR
This PR prevents failed dependency discovery in the installed Iceberg CMake package from altering the caller’s CMAKE_MODULE_PATH.
Changes:
- Replaces manual save/restore logic with a variable-scoped
block, preserving the module path even on early return. - Propagates package failure status and diagnostics while retaining imported dependency targets and extra dependency arguments.
| File | Description |
|---|---|
src/iceberg/iceberg-config.cmake.in |
Scopes dependency discovery to preserve the caller’s module path on success and failure. |
Review effort: Balanced
zhjwpku
left a comment
There was a problem hiding this comment.
This looks cleaner. I also confirmed that block was introduced in CMake 3.25, which matches our minimum supported version.
| endif() | ||
| # find_dependency() returns from this file when a dependency is not found. | ||
| # Keep changes to CMAKE_MODULE_PATH local even on that early return. | ||
| block(SCOPE_FOR VARIABLES PROPAGATE iceberg_FOUND iceberg_NOT_FOUND_MESSAGE) |
There was a problem hiding this comment.
The PROPAGATE list hard-codes iceberg_FOUND / iceberg_NOT_FOUND_MESSAGE, but find_dependency() sets ${CMAKE_FIND_PACKAGE_NAME}_FOUND / _NOT_FOUND_MESSAGE before return(). CMAKE_FIND_PACKAGE_NAME is the name the caller passed to find_package(). With find_package(Iceberg), Iceberg_FOUND is set inside the block and never reaches the caller. When a dependency is missing, the package is then reported as found with no targets.
| block(SCOPE_FOR VARIABLES PROPAGATE iceberg_FOUND iceberg_NOT_FOUND_MESSAGE) | |
| block(SCOPE_FOR VARIABLES | |
| PROPAGATE ${CMAKE_FIND_PACKAGE_NAME}_FOUND | |
| ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE) |
Summary
Preserve the caller's
CMAKE_MODULE_PATHwhen dependency discovery fails in the installed Iceberg CMake package.iceberg_find_dependenciescurrently saves and replaces the module path, then restores it afterfind_dependency()calls. However,find_dependency()returns from the package config on failure, skipping that restoration. The surrounding macro does not introduce a return boundary, so a non-requiredfind_package(iceberg)can leave the caller's subsequent package discovery using Iceberg's module path.Replace the manual save/restore logic with
block(SCOPE_FOR VARIABLES PROPAGATE iceberg_FOUND iceberg_NOT_FOUND_MESSAGE). This preserves both the caller's module path (including its defined/undefined state) and the package failure diagnostic, while retaining imported dependency targets and existing per-dependency extra arguments.This is the same underlying issue addressed in apache/orc#2735 and worked around by apache/arrow#55415.
The patch only changes
src/iceberg/iceberg-config.cmake.in; no test files, CMakeLists files, or unrelated dependency-search policies are changed.Testing
pre-commit run --files src/iceberg/iceberg-config.cmake.inpassed all applicable checks; file-type-inapplicable hooks were skipped.COMPONENTSarguments.AI assistance
Generated-by: OpenAI Codex (desktop app 26.1029.61003)