-
Notifications
You must be signed in to change notification settings - Fork 54
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
FindNetCDF finds libnetcdf but not netcdf.mod #21
Comments
You could try pkg-config, which is probably a better option these days. I haven't tested FindNetCDF.cmake in quite a while (and no longer use CMake in any of my projects). I don't think it was ever tested for a Fortran project. I'm sorry, but I don't have time to add this feature or help you debug at this time. I'd be happy to merge a reasonable patch if you learn how to do it.
You might solve your problem merely by telling your Fortran compiler about NETCDF_INCLUDES.
|
Thanks for the quick reply. I'll let you know once it's sorted out. If I don't sort it out on my own, I'll ask for help from Kitware, Inc., on CMake. |
Hi Damian, You need to add the NetCDF includes: cmake_minimum_required(VERSION 3.7)
project(build_against_netcdf LANGUAGES Fortran)
# Find the native NetCDF includes and library
include(cmake-modules/FindNetCDF.cmake)
set (NETCDF_F90 "YES") # Require Fortran interfaces to be FOUND
find_package (NetCDF REQUIRED)
include_directories(${NETCDF_INCLUDES})
add_library(io_routines src/io_routines.f90)
target_link_libraries (io_routines ${NETCDF_LIBRARIES}) A really good way to see what facilities a find module provides is to run |
Pleas let me know if you can offer any advice on resolving the following problem:
I set up a small repository to learn how to use FindNetCDF. The repository has just two Fortran source files, only one of which depends on NetCDF as specified in a single use netcdf statement. An abbreviated transcript of my results using my repository's add-cmake-file branch follows:
I used MacPorts on macOS Sierra to install netcdf and netcdf-fortran with the resulting installed files:
The text was updated successfully, but these errors were encountered: