BOUT-dev icon indicating copy to clipboard operation
BOUT-dev copied to clipboard

NetCDF in CMake build instructions

Open johnomotani opened this issue 3 years ago • 1 comments

In the docs, https://bout-dev.readthedocs.io/en/latest/user_docs/installing.html#common-cmake-options it is suggested to use NetCDF_ROOT to pass the location of the NetCDF install.

  • Does the capitalisation matter? netCDF_ROOT is used in FindnetCDF.cmake, e.g. https://github.com/boutproject/BOUT-dev/blob/4acdfdcb42dd0d8abfde06b5c2544c80d0bf0622/cmake/FindnetCDF.cmake#L46
  • For me, NetCDF_ROOT (or netCDF_ROOT) does not appear in ccmake (even when including 'advanced options'), or in the output of cmake . -B build -LH. Is that because CMake already found nc-config? Should netCDF_ROOT appear in ccmake?
  • While helping someone try to link to a source-build of NetCDF, it looks like even when using CMake to build NetCDF, it is necessary to 'install' the library (see https://docs.unidata.ucar.edu/netcdf-c/current/netCDF-CMake.html) - I found that surprising... Maybe it would be worth updating https://bout-dev.readthedocs.io/en/latest/user_docs/advanced_install.html#installing-netcdf-from-source to mention a CMake build of NetCDF?

johnomotani avatar Nov 07 '22 17:11 johnomotani

Sorry @johnomotani, I missed this at the time.

  • Good spot, it should be netCDF_ROOT. I don't particularly like this weird mix, but that's how the netCDF team style it, and what they use in their CMake files.
  • Hmm, the _ROOT variables are a little bit confusing. My understanding is that you can set <package>_ROOT to control where find_package looks, but it seems none of them in appear in cmake -LH -- but there's usually a <package>_DIR variable which should be the actual found location.
  • Urgh, yes good point. I fixed netcdf-cxx4 to work from just the build directory, but it seems the main C library still doesn't work like that and does need to be installed

ZedThree avatar Nov 23 '22 15:11 ZedThree