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

Modernize cmake

Open LecrisUT opened this issue 2 years ago • 2 comments

The cmake project should be modernized in order to make the project accessible via FetchContent:

  • Namespace the options and targets
  • remove various variables that are available built-in, e.g. detecting the OS
  • Add a NETCDF_INSTALL option with defaults if it's top_level or imported so that install is not called when imported
  • export the variables in netCDFConfig.cmake at the new nd of the cmakelists.txt
  • split the cmake file in subfolders
  • deprecate old options (use if(DEFINED))
  • change flags to be linked to a target, not global
  • move nonessential flags (warnings etc.) to CI preset file
  • use presets for the CI
  • DO NOT set cache variables that can have name overlap with other projects
  • separate into more targets and export them depending on options

Nitpicks:

  • move all options near the top to make the options visible to importers
  • move find_package/fetchcontent near the top as well
  • move autotools definitions to an separate file
  • move macros to a separate file and prefer using function

LecrisUT avatar Jun 14 '23 21:06 LecrisUT

@WardF you can assign this to me

K20shores avatar Jan 05 '24 16:01 K20shores

I can help with reviewing. Also I have a cmake-template with many of the points there, feel free to copy anything needed from there.

LecrisUT avatar Jan 05 '24 16:01 LecrisUT