[ENH] provided a function to use a local findpackage cmake file
This looks ugly:
if (FORCES_WITH_NETCDF)
# find the netcdf and netcdf-fortran libraries quietly
# Temporary replace CMAKE_MODULE_PATH to not alter behavior of down-stream packages
# https://stackoverflow.com/a/57185195/6696397
set(FORCES_CMAKE_MODULE_PATH_OLD ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH ${FORCES_CMAKE_MODULE_PATH})
find_package(NetCDF COMPONENTS Fortran QUIET)
set(CMAKE_MODULE_PATH ${FORCES_CMAKE_MODULE_PATH_OLD})
unset(FORCES_CMAKE_MODULE_PATH_OLD)
# Sometimes NetCDF_INCLUDE_DIRS can't be found but NetCDF_Fortran is still usable
if(NOT NetCDF_Fortran_FOUND)
message(FATAL_ERROR "FORCES: NetCDF-Fortran not usable")
else()
message(STATUS "FORCES: NetCDF-Fortran usable: ${NetCDF_Fortran_LIBRARY}")
endif()
target_link_libraries(${LIB_NAME} PUBLIC NetCDF::NetCDF_Fortran)
target_compile_definitions(${LIB_NAME} PRIVATE FORCES_WITH_NETCDF)
endif()
Could be done better in a wrapper.