A requirement of a project I am working on is to statically link against CGNS on windows, including the Fortran interfaces.
I have tried to compile on Windows 10, using the CMake files and using the "Visual Studio 14 2015 Win64" generator. The C compiler is the default MSVC compiler, and the fortran compiler is Intel IVF 18.0.3.
I have tried setting the CMake configuration according to both the "Building on Windows" section of the FAQ, and the configure options being passed to CMake in the AppVeyor CI testing in the main CGNS repository.
I have downloaded the v3.3.1 release from the github releases page.
UPDATE: A work around has been identified
The work around is to explicitly set the linker language to C for `cgns_static`
Here is the external project definition and configuration that I am using:
I run CMake to configure and build the CGNS portion of the project (HDF5 was already installed, v1.10.3, from https://gamma.hdfgroup.org/ftp/pub/outgoing/QATEST/hdf5110/binaries/windows/hdf5-1.10.3-Std-win10_64-vs14.zip) like this:
I can confirm that the build now succeeds on Windows under MSVS with Fortran enabled.
A corresponding issue has been opened on teh CMake bug tracker: https://gitlab.kitware.com/cmake/cmake/issues/18687
A minor problem remains: The installation of the cgns `.mod` file fails due to the way MSVS behaves. The CMake installation is not looking under the `$<CONFIG>` subdirectory for the module file, and thus the installation of the .mod file is failing. I'll try to add a fix for that here as well.
Can this be closed?
I think so. I haven't had time to test the latest release. I've also noticed that MSVS does not seem to do well with mixed language targets. I have doubts that the object library is linking correctly when built with MSVS. But for not, this seems resolved enough.
For the application/project I am working on, in the end, my test seemed to fail due to HDF5, which is a different kettle of fish. It is possible that bugs remain with Intel Fortran and MSVS, but we've factored out the code requiring CGNS, and added flags to turn it on and off. So for now, we are skipping CGNS on Windows.
I would recommend, even though it's obnoxious, compiling fortran and C libraries separately to better accommodate MSVS. This is somewhat different than the present issues, so I am happy to mark this as resolved, at least for now.