Closed kgerheiser closed 4 years ago
I think cmake needs to know where to look for the pkg config file. The way this is done in the umbrella build is in lines 80-93 of the umbrella build CMakeLists.txt:
# If NETCDF is not set in the NCEPLIBS-external cmake configuration file,
# need to add environment variable NETCDF to CMAKE_PREFIX_PATH for PkgConfig
# and set cmake variable accordingly
if(NOT NETCDF)
if(NOT DEFINED ENV{NETCDF})
message(FATAL_ERROR "Environment variable NETCDF not set")
else()
list(APPEND CMAKE_PREFIX_PATH $ENV{NETCDF})
set(NETCDF $ENV{NETCDF})
endif()
if(DEFINED ENV{NETCDF_FORTRAN})
list(APPEND CMAKE_PREFIX_PATH $ENV{NETCDF_FORTRAN})
endif()
endif()
There is also a way to set/append to an environment variable in Linux that tells pkgconfig where to look. The consistent rule we have used between NCEPLIBS-external and NCEPLIBS is to require the user/module to set the environment variable NETCDF
and then use the above block of code to append to CMAKE_PREFIX_PATH
.
Does this help you? I guess you only have to copy & paste the block above into the UFS_UTILS CMakeLists.txt
. If UFS_UTILS is built as part of NCEPLIBS (umbrella), then NETCDF is already set (because of the identical block in the NCEPLIBS CMakeLists.txt
), and nothing changes.
We probably need to apply the same bugfix to EMC_post.
@kgerheiser @mark-a-potts @GeorgeGayno-NOAA @WenMeng-NOAA
I think we need to fix the FindNetCDF.cmake to actually find the libraries given some hints.
I think one of the hints could be the environment variables NETCDF
and NETCDF_FORTRAN
?
Fixed with Rahul's FindNetCDF
@GeorgeGayno-NOAA was unable to build UFS_UTILS standalone on Hera, and I was able to reproduce.
It was unable to find NetCDF even though the NetCDF module is loaded with:
module load netcdf/4.7.0
And to build:
I don't quite understand how
pkg_check_modules
works, but that's where it seems to be failing. https://github.com/NOAA-EMC/CMakeModules/blob/b605db0df4f8fb1110aaba989dbffad5312752b9/Modules/FindNetCDF.cmake#L23Any ideas @climbfuji?