Skip to content

GH-55357: [C++] Fix ORC overwritting CMAKE_MODULE_PATH when dependency not found - #55415

Open
raulcd wants to merge 1 commit into
apache:mainfrom
raulcd:GH-55357
Open

raulcd wants to merge 1 commit into
apache:mainfrom
raulcd:GH-55357

Conversation

@raulcd

@raulcd raulcd commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Rationale for this change

When a dependency is not found on ORC its find_dependency returns without resetting previous CMAKE_MODULE_PATH:
https://github.com/apache/orc/blob/32046606774da481182dce2956f336dc8e79a579/c%2B%2B/orcConfig.cmake.in#L45-L55

What changes are included in this PR?

Maintain our CMAKE_MODULE_PATH before calling ORC.

Are these changes tested?

Not on our CI but this has been tested on downstream arrow-cpp-feedstock here:
conda-forge/arrow-cpp-feedstock#2100

Are there any user-facing changes?

No

Was AI used for this PR?

In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #55357 has been automatically assigned in GitHub to PR creator.

@raulcd
raulcd marked this pull request as ready for review November 5, 2026 12:21
Copilot AI balanced review requested due to automatic review settings November 5, 2026 12:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change preserving Arrow’s CMake module search path during ORC discovery.

No open issues 🎉

What changed in this PR

Preserves Arrow’s CMake module search path when ORC dependency discovery fails, preventing later lookups such as AWS SDK discovery from losing access to Arrow’s find modules.

Changes:

  • Saves and restores CMAKE_MODULE_PATH around find_package(orc), then removes the temporary variable.
  • Documents why ORC’s early return requires this workaround.
File Description
cpp/​cmake_modules/​FindorcAlt.cmake Preserves the module search path across ORC discovery.

Review effort: Balanced

@h-vetinari

Copy link
Copy Markdown
Contributor

Thanks a lot for debugging this. I think this is good as an intermediate fix; better would be for orc to fix this for itself.

@raulcd

raulcd commented Nov 6, 2026 •

Copy link
Copy Markdown
Member Author

Yes, I agree this is something that should be fixed on ORC side, this seems slightly related to the following issue (eventhough not exactly the same problem):

ping @wgtmac what do you think?

edit: not the specific clobbing but the initial issue that created this as ORC wasn't able to find lz4 from conda due to homebrew also having lz4 and then (this new issue) not clearing CMAKE_MODULE_PATH

@wgtmac

wgtmac commented Nov 6, 2026

Copy link
Copy Markdown
Member

Ah, indeed ORC needs to fix this: apache/orc#2735

wgtmac added a commit to apache/orc that referenced this pull request Nov 6, 2026
…fails

### What changes were proposed in this pull request?

Isolate dependency discovery in `orcConfig.cmake` with a CMake variable scope, propagating `orc_FOUND` and `orc_NOT_FOUND_MESSAGE` while keeping `CMAKE_MODULE_PATH` local even on an early return.

The patch only changes `c++/orcConfig.cmake.in`; it does not modify test CMakeLists files or add test infrastructure.

### Why are the changes needed?

[ORC-2235](https://issues.apache.org/jira/browse/ORC-2235)

`find_dependency()` returns from the package config when a dependency cannot be found. The previous manual restoration of `CMAKE_MODULE_PATH` was therefore skipped, leaking ORC's module search path into the consuming project.

This caused a misleading AWS dependency-discovery failure in Arrow after ORC's LZ4 dependency lookup failed. apache/arrow#55415 adds a caller-side workaround; this PR fixes the underlying ORC configuration leak. It does not change LZ4 dependency-selection policy.

### How was this patch tested?

On macOS with CMake 4.3.1:

```sh
cmake -S . -B build -DBUILD_JAVA=OFF
cmake --build build --target orc-test --parallel 8
cmake --build build --target test-out
```

After removing the test-infrastructure changes, both existing CTest tests (`orc-test` and `tool-test`) passed.

Separately verified six temporary, out-of-tree configure scenarios with CMake 3.25.2 and 4.3.1: successful/missing dependency discovery with `CMAKE_MODULE_PATH` initially undefined, empty, or containing multiple directories. All six passed with the scoped fix; all three missing-dependency scenarios reproduced the leak against the original template. No regression test files are included in this PR.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: OpenAI Codex (desktop app 26.1029.61003)

Closes #2735 from wgtmac/codex/orc-2235-cmake-module-path.

Authored-by: Gang Wu <ustcwg@gmail.com>
Signed-off-by: Gang Wu <ustcwg@gmail.com>
wgtmac added a commit to apache/orc that referenced this pull request Nov 6, 2026
…fails

### What changes were proposed in this pull request?

Isolate dependency discovery in `orcConfig.cmake` with a CMake variable scope, propagating `orc_FOUND` and `orc_NOT_FOUND_MESSAGE` while keeping `CMAKE_MODULE_PATH` local even on an early return.

The patch only changes `c++/orcConfig.cmake.in`; it does not modify test CMakeLists files or add test infrastructure.

### Why are the changes needed?

[ORC-2235](https://issues.apache.org/jira/browse/ORC-2235)

`find_dependency()` returns from the package config when a dependency cannot be found. The previous manual restoration of `CMAKE_MODULE_PATH` was therefore skipped, leaking ORC's module search path into the consuming project.

This caused a misleading AWS dependency-discovery failure in Arrow after ORC's LZ4 dependency lookup failed. apache/arrow#55415 adds a caller-side workaround; this PR fixes the underlying ORC configuration leak. It does not change LZ4 dependency-selection policy.

### How was this patch tested?

On macOS with CMake 4.3.1:

```sh
cmake -S . -B build -DBUILD_JAVA=OFF
cmake --build build --target orc-test --parallel 8
cmake --build build --target test-out
```

After removing the test-infrastructure changes, both existing CTest tests (`orc-test` and `tool-test`) passed.

Separately verified six temporary, out-of-tree configure scenarios with CMake 3.25.2 and 4.3.1: successful/missing dependency discovery with `CMAKE_MODULE_PATH` initially undefined, empty, or containing multiple directories. All six passed with the scoped fix; all three missing-dependency scenarios reproduced the leak against the original template. No regression test files are included in this PR.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: OpenAI Codex (desktop app 26.1029.61003)

Closes #2735 from wgtmac/codex/orc-2235-cmake-module-path.

Authored-by: Gang Wu <ustcwg@gmail.com>
Signed-off-by: Gang Wu <ustcwg@gmail.com>
(cherry picked from commit 0c0d0f0)
Signed-off-by: Gang Wu <ustcwg@gmail.com>
wgtmac added a commit to apache/orc that referenced this pull request Nov 6, 2026
…fails

### What changes were proposed in this pull request?

Isolate dependency discovery in `orcConfig.cmake` with a CMake variable scope, propagating `orc_FOUND` and `orc_NOT_FOUND_MESSAGE` while keeping `CMAKE_MODULE_PATH` local even on an early return.

The patch only changes `c++/orcConfig.cmake.in`; it does not modify test CMakeLists files or add test infrastructure.

### Why are the changes needed?

[ORC-2235](https://issues.apache.org/jira/browse/ORC-2235)

`find_dependency()` returns from the package config when a dependency cannot be found. The previous manual restoration of `CMAKE_MODULE_PATH` was therefore skipped, leaking ORC's module search path into the consuming project.

This caused a misleading AWS dependency-discovery failure in Arrow after ORC's LZ4 dependency lookup failed. apache/arrow#55415 adds a caller-side workaround; this PR fixes the underlying ORC configuration leak. It does not change LZ4 dependency-selection policy.

### How was this patch tested?

On macOS with CMake 4.3.1:

```sh
cmake -S . -B build -DBUILD_JAVA=OFF
cmake --build build --target orc-test --parallel 8
cmake --build build --target test-out
```

After removing the test-infrastructure changes, both existing CTest tests (`orc-test` and `tool-test`) passed.

Separately verified six temporary, out-of-tree configure scenarios with CMake 3.25.2 and 4.3.1: successful/missing dependency discovery with `CMAKE_MODULE_PATH` initially undefined, empty, or containing multiple directories. All six passed with the scoped fix; all three missing-dependency scenarios reproduced the leak against the original template. No regression test files are included in this PR.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: OpenAI Codex (desktop app 26.1029.61003)

Closes #2735 from wgtmac/codex/orc-2235-cmake-module-path.

Authored-by: Gang Wu <ustcwg@gmail.com>
Signed-off-by: Gang Wu <ustcwg@gmail.com>
(cherry picked from commit 0c0d0f0)
Signed-off-by: Gang Wu <ustcwg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants