Skip to content

Support nested build directories in sibling search#5091

Open
hakonhagland wants to merge 1 commit into
OPM:masterfrom
hakonhagland:sibling_search
Open

Support nested build directories in sibling search#5091
hakonhagland wants to merge 1 commit into
OPM:masterfrom
hakonhagland:sibling_search

Conversation

@hakonhagland

@hakonhagland hakonhagland commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

The OpmSiblingSearch macro uses get_filename_component(NAME) to extract the build directory name, which only returns the last path component. This means nested build directories like builds/debug are not supported — the sibling search would look for ../opm-common/debug instead of ../opm-common/builds/debug, causing CMake to fail with "could not find opm-common".

Changes

  • Replace get_filename_component with file(RELATIVE_PATH) as the primary search strategy: compute the build directory path relative to PROJECT_SOURCE_DIR, then apply that same relative path to the sibling module's source tree. This correctly handles build directories at any nesting depth (e.g., builds/debug, builds/release).
  • Keep the previous strategies as fallbacks for out-of-source or non-standard layouts: prefix-based naming (build-opm-gridbuild-opm-common) and common build root with per-module subdirectories.
  • Add documentation describing the three search strategies with concrete examples, and a note about the inline copies in opm-grid and opm-simulators that must be kept in sync.

Companion PRs

The previous sibling search logic used get_filename_component(NAME)
to extract the build directory name, which only returned the last
path component. This broke sibling discovery for nested build
directories like "builds/debug" — the search would look for
"../opm-common/debug" instead of "../opm-common/builds/debug".

Use file(RELATIVE_PATH) to compute the full relative path from
PROJECT_SOURCE_DIR to PROJECT_BINARY_DIR, then apply that same
relative path to the sibling module's source tree. This correctly
handles build directories at any depth. The previous strategies
(prefix-based naming and common build root) are kept as fallbacks
for out-of-source builds.

Also add documentation describing the three search strategies and
a note about the inline copies in opm-grid and opm-simulators.
@hakonhagland

Copy link
Copy Markdown
Contributor Author

jenkins build this opm-grid=1015 opm-simulators=6961 please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:irrelevant This PR is a minor fix and should not appear in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant