FindNetCDF.cmake with imported targets
NetCDF4 is a powerful scientific data format based on HDF5 standard. NetCDF4 is directly usable by ParaView in the CF (Climate and Format) metadata convention. We have created a FindNetCDF.cmake that efficiently finds NetCDF libraries for use in CMake.
Example:
Place FindNetCDF.cmake file under cmake/Modules/ in your project, then use from your CMakeLists.txt like:
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
find_package(NetCDF COMPONENTS Fortran REQUIRED)
# example target
add_executable(main main.f90)
target_link_libraries(main PRIVATE NetCDF::NetCDF_Fortran)