-
Notifications
You must be signed in to change notification settings - Fork 98
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
Windows compile #268
Windows compile #268
Conversation
Parallel I/O stub functions in new file nf_nc_noparallel.f90 Included in compile when netcdf-c library built without parallel I/O Return NC_ENOPAR, same as netcdf-c
Separate C code from Fortran so C code gets C flags at compile Allows proper build on Windows
Thank you, this looks great! I'll review it and merge or follow up. This is the proper procedure for submitting a PR, certainly. Thanks! |
Thanks for the work here! We are excited it might enable us to provide netcdf-fortran on Conda Forge! Subscribed to follow the updates. |
fortran/CMakeLists.txt
Outdated
ADD_LIBRARY(netcdff ${netcdff_SOURCES}) | ||
TARGET_LINK_LIBRARIES(netcdff PUBLIC netCDF::netcdf) | ||
TARGET_LINK_LIBRARIES(netcdff ${NETCDF_C_LIBRARY}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brucenairn CMake is throwing a warning on this line for me, on OSX (I do not have a way to test it on Windows with the Intel compilers). I can add the PUBLIC keyword, which resolves the warning but results in -lnetcdf
being passed to the linker twice. Does this patch still work on Windows if you were to remove this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this comment before but it may not have gone through, much to my dismay. I am anxious to get this in as well :). Great work!
Previous target_link_libraries have keywoord signatures, so NETCDF_C_LIBRARY needs one, per Cmake CMP0023 PRIVATE libraries are linked to, but are not made part of the link interface.
Thanks! |
I wanted to build netcdf-fortran for Windows 10 using Intel Fortran 19.0 (v 2) and VS 2017. I needed to make a few changes to get this to work. I added stub functions for parallel I/O when netcdf-c was built without parallel I/O, as mine was. I separated the build steps for C and Fortran code, built the C code to object files and linked into the Fortran code. This prevents the Fortran flags from being applied to the C code. My netcdf-c library was built as a shared (DLL) library, netcdf-fortran was built as a static library.
I hope this is helpful. I'm new to this, please let me know if I should have done something different.