Skip to content

build, examples find_package ignores HDF5_ROOT (CMP0074 OLD under cmake_minimum_required 3.10) #295

@steven-varga

Description

@steven-varga

Symptom

CMake configure warning (visible now that BUILD_EXAMPLES=ON is default, #278):

CMake Warning (dev) at examples/CMakeLists.txt:27 (find_package):
  Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
  CMake variable HDF5_ROOT is set to: /usr/local/HDF_Group/HDF5/1.12.3;/usr/local;/usr
  For compatibility, CMake is ignoring the variable.

Root cause — not just cosmetic

examples/CMakeLists.txt:5 declares cmake_minimum_required(VERSION 3.10 FATAL_ERROR). CMP0074 was introduced in CMake 3.12, so under a 3.10 policy baseline it defaults to OLD and find_package(HDF5) ignores HDF5_ROOT. The file carefully builds HDF5_ROOT (lines 20-25) to prefer custom HDF Group installs — that logic is silently inert. The root CMakeLists.txt already requires 3.22; the examples sub-project's stale 3.10 baseline is the only thing forcing the old behavior.

Fix

Set cmake_policy(SET CMP0074 NEW) in examples/CMakeLists.txt (after project()), so find_package honors HDF5_ROOT. Silences the warning and makes the custom-path discovery actually work.

Acceptance

  • No CMP0074 dev warning at configure.
  • find_package(HDF5) in examples honors HDF5_ROOT.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions