E3SM-Project / E3SM-Project/scorpio

Could our long nightmare with finding netcdf with cmake be nearly over???

Open
#663 2 comments 1 reaction 5 assignees Claimed by @rljacob View on GitHub
cmake
Dominant language
C++
Stars
22
Forks
20
Avg merge
12d 19m
Merged PRs (30d)
1

Description

I'm trying to build scorpio on a generic linux machine (ubuntu). I have installed the various netcdf packages with `apt-get`. My package manager did install a file that would allow a CMake user to do `find_package(netCDF ...)`:

```
/usr/lib/x86_64-linux-gnu/cmake/netCDF/netCDFConfig.cmake
```

I tested this with a simple program and it seems to work:

```
find_package(netCDF REQUIRED C)

# Add an executable target
add_executable(my_netcdf_app main.c)

# Link the NetCDF library to the executable
# The netCDF::netcdf target is an imported target defined by find_package(netCDF)
target_link_libraries(my_netcdf_app PRIVATE netCDF::netcdf)
```

The version of netcdf that I have is 4.8.1. I don't know when proper CMake support was finally added. AI is telling me this support was added in 4.3, which is older than our minimum required version, so perhaps this is a feature we can rely on? If not, it might be worth bumping the minimum netcdf to something newer just to avoid dealing with the current hellscape of netcdf integration with our cmake projects.

As I understand it, most of E3SM is currently relying on scorpio to find the netcdf cmake package. Due to historical lack of a reliable find module for netcdf, scorpio supplies its own module `scorpio/cmake/FindNetCDF.cmake`. We have used various homegrown modules over the years, all of which use "old-school" cmake style the predates object-oriented targets.

I will note that I currently cannot build eamxx/scorpio on my generic linux machine due to the scorpio FindNetCDF not finding netcdf. I can't even force it to use the module that my package manager gave me due to the capitalization being different `NetCDF` vs. `netCDF` (we also have `NETCDF` in many places as well, so three different ways to capitalize "netcdf", what fun!).

```
CMake Error at /home/jfoucar/E3SM/externals/scorpio/src/clib/CMakeLists.txt:245 (message):
Could not find PnetCDF and NetCDF libraries. SCORPIO requires PnetCDF
and/or NetCDF C libraries
```

I think it would be great for the project to finally move past the era of home-rolled find modules for netcdf, so I have marked this as "high priority". Feel free to overrule me.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.