netcdf-c
netcdf-c copied to clipboard
Modernize cmake
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_INSTALLoption 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
@WardF you can assign this to me
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.