Skip to content

Fix unity build errors - #15059

Merged
magnesj merged 2 commits into
devfrom
fix-wellevent-state-appenum
Oct 27, 2026
Merged

magnesj merged 2 commits into
devfrom
fix-wellevent-state-appenum

Conversation

@magnesj

@magnesj magnesj commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes for the unity build.

Link error for well event State AppEnum

The Linux unity build fails to link ResInsight:

unity_131_cxx.cxx: undefined reference to `caf::AppEnum<RimWellEventEnums::State>::setUp()'

Since #14912 (5b229cd), RimWellEventPerf::State and RimWellEventValve::State are aliases for the shared RimWellEventEnums::State. The setUp() specialization was still declared in both class headers and defined in RimWellEventPerf.cpp.

  • Declare caf::AppEnum<RimWellEventEnums::State>::setUp() in RimWellEventEnums.h
  • Define it in the new RimWellEventEnums.cpp
  • Remove the declarations from RimWellEventPerf.h / RimWellEventValve.h and the definition from RimWellEventPerf.cpp

Name clashes in unit tests

Unity builds compile several test files in one translation unit, so helpers with the same name in anonymous namespaces collided (C2084/C2011). The helpers now have file-specific names:

  • RimWorkflowDefinition-Test.cpp: taskByName -> definitionTaskByName
  • RimSummaryCalculationCollection-Test.cpp: createFieldCalculation -> createCollectionFieldCalculation
  • RigPorvSoilSgasResultCalculator-Test.cpp: MockCase/createMockCase -> PorvMockCase/createPorvMockCase

Testing

  • Windows (MSVC, RelWithDebInfo): ResInsight and ResInsight-tests build and link
  • Windows (MSVC, Debug, unity): all unit test sources compile
  • Linux unity build (Rocky 8, gcc-toolset-13, Release): ResInsight, ResInsight-tests and ResInsight-featuretests build and link; unit tests pass (1461 passed, 2 skipped)

RimWellEventPerf::State and RimWellEventValve::State are aliases for
RimWellEventEnums::State, but the AppEnum setUp() specialization was
declared in both class headers and defined in RimWellEventPerf.cpp.
The Linux unity build failed to link with an undefined reference to
caf::AppEnum<RimWellEventEnums::State>::setUp().

Declare the specialization in RimWellEventEnums.h and define it in the
new RimWellEventEnums.cpp, so all users see a single declaration and
there is a single definition.
Unity builds compile several test files in one translation unit, so
helpers with the same name in anonymous namespaces collided. Give the
helpers file-specific names:
- RimWorkflowDefinition-Test: taskByName -> definitionTaskByName
- RimSummaryCalculationCollection-Test: createFieldCalculation ->
  createCollectionFieldCalculation
- RigPorvSoilSgasResultCalculator-Test: MockCase/createMockCase ->
  PorvMockCase/createPorvMockCase
@magnesj magnesj changed the title Fix unity build link error for well event State AppEnum Fix unity build errors Oct 27, 2026
@magnesj
magnesj merged commit 5e4496a into dev Oct 27, 2026
23 checks passed
@magnesj
magnesj deleted the fix-wellevent-state-appenum branch October 27, 2026 09:05
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