hpc-io / vfd-gds

Other
16 stars 11 forks source link

[BUG][CMake] Typo in `CMakeLists.txt`, export set is always empty #13

Closed Jacobfaib closed 2 months ago

Jacobfaib commented 2 months ago

src/CMakeLists.txt has

  export(
    TARGETS
      ${HDF5_VFD_GDS_EXPORTED_LIBS}
    FILE
      ${HDF5_VFD_GDS_EXPORTED_TARGETS}.cmake
  )

but HDF5_VFD_GDS_EXPORTED_LIBS is always empty which causes

CMake Error in some/parent/project/CMakeLists.txt:
  export called with target "SomeParentProject" which requires target "hdf5_vfd_gds"
  that is not in any export set.

This is because:

set(HDF5_VFD_GDS_EXPORTED_LIBS hdf5_vfd_gds ${HDF5_VFD_GDS_EXPORTED_LIBS} PARENT_SCOPE)

only sets the new value in the parent scope, which does not trickle down to the child scope (thanks CMake for this brain-damaged design...).

Changing this to

set(HDF5_VFD_GDS_EXPORTED_LIBS hdf5_vfd_gds ${HDF5_VFD_GDS_EXPORTED_LIBS})
set(HDF5_VFD_GDS_EXPORTED_LIBS ${HDF5_VFD_GDS_EXPORTED_LIBS} PARENT_SCOPE)

fixes the problem

jhendersonHDF commented 2 months ago

Thanks @Jacobfaib for the report! Could you go ahead and create a PR with the change?