Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Add option to download and build netCDF C++ API #2138

Merged
merged 5 commits into from
Nov 10, 2020

Conversation

ZedThree
Copy link
Member

@ZedThree ZedThree commented Nov 6, 2020

Fixes #2105

Currently uses my fork -- I've opened a PR, but it might be a while before it gets merged.

@johnomotani Any chance you could check this works on MARCONI?

@ZedThree
Copy link
Member Author

ZedThree commented Nov 6, 2020

John found he had to use -DCMAKE_PREFIX_PATH=$(nc-config --prefix) to get netcdf-cxx4 to find netcdf-c. I'll make a note of this in the docs. We actually had a bunch of doc changes go into master that aren't in next, so I need to do that first!

@johnomotani
Copy link
Contributor

Is it possible to automate this? ie get cmake to pass $(nc-config --prefix) to the netcdf-cxx4 build by default? As I understand nc-config is a standard utility?

@ZedThree
Copy link
Member Author

ZedThree commented Nov 6, 2020

Yes, I think I just need to split the current FindNetCDF.cmake into two parts, one to find the C library, and one for the C++ API. That way, I can find the C library before downloading the C++ API, which should then let it skip its checks. I might then contribute the C version back too.

Split FindNetCDF.cmake into two files so we can reuse the C bit if
we're not downloading netcdf-cxx4
johnomotani
johnomotani previously approved these changes Nov 7, 2020
Copy link
Contributor

@johnomotani johnomotani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me, configuring with just cmake -DBOUT_DOWNLOAD_NETCDF_CXX4=ON .. and tests pass. I wondered briefly whether it'd be good to add the -DBOUT_DOWNLOAD_NETCDF_CXX4=ON flag in a test, but we only have one run using cmake at the moment so I don't think it's worth it.

- bout_add_library_alias: workaround for add_library(ALIAS) in CMake <
  3.18
- bout_inspect_netcdf_config: get details from nx-config
@ZedThree
Copy link
Member Author

ZedThree commented Nov 9, 2020

My changes had broken things for the older version of netCDF-C on Travis, should be fixed now

@ZedThree
Copy link
Member Author

ZedThree commented Nov 9, 2020

Also, I should note that the CMake module names have changed a little bit to be more in line with the upstream netCDF names, which are netCDF and netCDFCxx. This affects things like finding netcdf via netCDF_ROOT/netCDFCxx_ROOT CMake variables

Copy link
Contributor

@johnomotani johnomotani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto-downloading netcdf-cxx4 still working on Marconi 👍

@ZedThree ZedThree merged commit 9da9e11 into next Nov 10, 2020
@ZedThree ZedThree deleted the download-netcdf-cxx4 branch November 10, 2020 13:59
@ZedThree ZedThree mentioned this pull request Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants