netcdf-c icon indicating copy to clipboard operation
netcdf-c copied to clipboard

Question about whether CMake build provides proper package config file...

Open edwardhartnett opened this issue 5 years ago • 8 comments
trafficstars

I have this question from a fellow NOAA programmer about the CMake config file for netcdf-c:

The CMake build of NetCDF (C, Fortran and C++) do not provide a correct package config file. In other words, I never had success with find_package(NetCDF C Fortran C++) using the package config file provided by the NetCDF package. This is the reason I (and some others) have been using the old configure based build system and came up with our version of FindNetCDF.cmake that relies on nc-config, nf-config, ncxx4-config.

edwardhartnett avatar May 20 '20 11:05 edwardhartnett

I would really second this!!

It would be super fantastic if netcdf installed a cmake and pkg-config file for end users!

zerothi avatar Oct 25 '22 06:10 zerothi

What would be helpful is if some cmake-expert netCDF users would submit a PR with these fixes...

edwardhartnett avatar Oct 25 '22 14:10 edwardhartnett

Hi all,

We're using NetCDF with the CMake config file, one difference is the name is netCDF not NetCDF so find_package(netCDF CONFIG) works for us. We have a few nitpicks about transitive dependence on HDF5 but overall it does work okay.

ibaned avatar Oct 25 '22 15:10 ibaned

Good to know about the case-sensitivity re: FIND_PACKAGE(netCDF ...). Our documentation for using cmake-based netCDF, not just building via cmake, certainly could use some updating/creating. Thanks!

WardF avatar Oct 25 '22 15:10 WardF

I would really second this!!

It would be super fantastic if netcdf installed a cmake and pkg-config file for end users!

For the record, netCDF does install a pkg-config file, whether you are building via cmake or configure && make, etc. It also provides the nc-config command line utility which can be queried directly, in addition to the above.

The weakest part of the install are the files used to pull netCDF into other cmake-based projects. As @edwardhartnett said, a PR would be great, but I'll also come up to speed on what it will take to incorporate more of the modern functionality (as opposed to the cmake v2.8 functionality we used when cmake was originally integrated into netcdf).

Thanks :)

WardF avatar Oct 25 '22 15:10 WardF

Hi all,

We're using NetCDF with the CMake config file, one difference is the name is netCDF not NetCDF so find_package(netCDF CONFIG) works for us. We have a few nitpicks about transitive dependence on HDF5 but overall it does work okay.

Hi @ibaned, are the nitpicks that the transitive dependence is present in the first place? Or is there something we can clean up there to make it more functional?

WardF avatar Oct 25 '22 15:10 WardF

@WardF I believe the canonical advice in CMake is that netCDFConfig.cmake should call something like

find_dependency(HDF5)

if NetCDF is built with HDF5 support. I'm happy to create a PR for this eventually, I have good expertise with CMake but am just short on time to work on it. I appreciate the work done to date on CMake in NetCDF, thank you.

ibaned avatar Oct 25 '22 16:10 ibaned

See #2751 for at least getting the HDF5 bit covered.

mathstuf avatar Sep 06 '23 18:09 mathstuf