Skip to content

Scope GRPC/ODB/OpenVDS/HDF5 build flags to avoid full rebuilds - #14795

Draft
magnesj wants to merge 2 commits into
OPM:devfrom
magnesj:janitor
Draft

magnesj wants to merge 2 commits into
OPM:devfrom
magnesj:janitor

Conversation

@magnesj

@magnesj magnesj commented Sep 25, 2026

Copy link
Copy Markdown
Member

Summary

Toggling RESINSIGHT_ENABLE_GRPC, RESINSIGHT_USE_ODB_API, RESINSIGHT_ENABLE_OPENVDS, or the HDF5 detection result currently forces a full rebuild of the entire project (ThirdParty, VizFwk, and all caf* frameworks), even though none of that code references these macros.

Root cause

The root CMakeLists.txt used directory-scoped �dd_definitions() for USE_ODB_API and ENABLE_GRPC before most �dd_subdirectory() calls, so toggling either flag changed the compiler command line for essentially every target in the build.

Fix

  • Phase 1: Removed the two global �dd_definitions() calls from the root CMakeLists.txt. Replaced them with arget_compile_definitions() on the actual consumer targets (ApplicationLibCode, ApplicationExeCode, Commands, GeoMechDataModel, GrpcInterface).
  • Phase 2: Further narrowed USE_OPENVDS / USE_HDF5 / ENABLE_GRPC / USE_ODB_API to set_source_files_properties() on the small set of files that actually reference each macro, so toggling a flag only recompiles a handful of files instead of the whole monolithic ApplicationLibCode/Commands targets.
  • Also removed the unused SOURCE_GROUP_HEADER_FILES variable from GrpcInterface/CMakeLists.txt (dead code, no effect on the build).

Verification

  • Full build succeeded with the existing config (GRPC=ON, OpenVDS=ON, HDF5=ON).
  • Verified via �uild.ninja inspection that ThirdParty/VizFwk/caf* targets no longer reference ENABLE_GRPC/USE_ODB_API.
  • Verified toggling RESINSIGHT_ENABLE_GRPC OFF: uncovered and fixed a pre-existing, unrelated Qt AUTOMOC caching bug (stale mocs_compilation.cpp referencing a conditionally-excluded header) that required clearing the ResInsight_autogen cache; full build then succeeded (28/28) with GRPC off.
  • ODB toggle-off itself was not build-tested in this environment (ODB SDK not configured here), but the CMake logic was verified via configure success and code review.

Marked as draft pending final review/testing.

Root cause: root CMakeLists.txt used directory-scoped add_definitions()
for USE_ODB_API and ENABLE_GRPC before most add_subdirectory() calls,
so toggling either flag changed the compile command for every target
in the build (ThirdParty, VizFwk, caf* frameworks included), forcing a
full rebuild.

Phase 1: removed the two global add_definitions() calls from the root
CMakeLists.txt and replaced them with target_compile_definitions() on
the actual consumer targets (ApplicationLibCode, ApplicationExeCode,
Commands, GeoMechDataModel, GrpcInterface).

Phase 2: further narrowed USE_OPENVDS/USE_HDF5/ENABLE_GRPC/USE_ODB_API
to set_source_files_properties() on the small set of files that
actually reference each macro, so toggling a flag only recompiles a
handful of files within ApplicationLibCode/Commands/UnitTests instead
of the whole monolithic target.

Verified via a full build with the current config (GRPC=ON, OpenVDS=ON,
HDF5=ON); fixed a missed H5_BUILT_AS_DYNAMIC_LIB scoping gap in
UnitTests that surfaced as HDF5 link errors during verification.

This branch has not been deployed

No deployments
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