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

Enable Cross-Platform Support for FindNetCDF.cmake #54

Merged
merged 2 commits into from
Mar 12, 2025

Conversation

amstokely
Copy link
Collaborator

@amstokely amstokely commented Mar 7, 2025

Summary

This PR rewrites the FindNetCDF.cmake file to simplify its logic and ensure it works on both Linux and macOS. The new version relies solely on the output of the nc-config, ncxx4-config, and nf-config tools provided by the NetCDF C, C++, and Fortran libraries.

Motivation

The current FindNetCDF.cmake script fails to detect NetCDF installations provided by Homebrew on macOS.

Key Improvements

  • Fully relies on the netcdf-config tools, which are the recommended way to query NetCDF build details.
  • Works with NetCDF installations from multiple sources:
    • Linux (tested with Spack and manual source builds)
    • macOS (tested with Homebrew installations)
  • Correctly handles include directories, library directories, and link flags,

Testing

  • Linux: Confirmed working with:
    • Spack-installed NetCDF (C, C++, Fortran)
      - Build log
    • Manually built and installed NetCDF
  • macOS: Confirmed working with:
    • Homebrew-installed NetCDF (C, C++, Fortran)

@amstokely amstokely self-assigned this Mar 7, 2025
@amstokely amstokely force-pushed the feature/cross_platform_FindNetCDF branch from 4138637 to 15f22e4 Compare March 7, 2025 22:51
@amstokely amstokely requested a review from jim-p-w March 11, 2025 17:00
Copy link
Collaborator

@mgduda mgduda left a comment

Choose a reason for hiding this comment

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

Ideally, we could have determined why exactly the current FindNetCDF.cmake script doesn't work with homebrew-installed netCDF libraries and applied some targeted changes; but if this rewrite works, that's sufficient.

@amstokely amstokely merged commit 270c215 into main Mar 12, 2025
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.

3 participants