Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28551 Discussions

Building Fortran Visual Studio Solution (.sln) and Project (.vfproj) files from scratch

New Contributor I

I have a large Fortran project ( that uses meson/ninja to setup the build directory and compile with intel oneAPI Fortran (using both ifort and ifx).


The repository also contains a pre-made Visual Studio Solution (.sln) and Project (.vfproj) files for end users to work with the code that do not have meson/ninja.


Right now the only method I know of for making these files is through the Visual Studio GUI and selecting the Fortran template. Then any updates to the file structure or options has to be done through the GUI.


Is it possible to dynamically generate these files from meson or through a python script. I saw meson had a "--backend=vs2022" option, but that failed saying it did not understand the ".f90" extension. I suspect the issue is because that is requesting to build with vs2022 rather than building thesln and vfproj files. I also saw cmake claims to do the same, but I suspect it just means it can compile using visual studio.


The idea is that when a new file is added, new visual studio files can be created without having to go through the GUI process.


I am hoping there is a method to do this without having to go the route of embedding most of the sln and proj xml information into a python script and just echo it out.


Thanks all for the help,



0 Kudos
3 Replies
Honored Contributor III

I've see some users using CMake or Makefile Projects (I don't do this myself)


You will have to set the environment, and the rules to use ifort or ifx (plus any other things e.g. link with the compiler).

Those projects should permit wildcards. 

You may have to adapt this:


Jim Dempsey

New Contributor I

I activated the environment, but what I was hoping is to use meson, which is setup to compile the Fortran code, to generate a visual studio solution and project files for other use to use. The idea is that users that prefer intel fortran with visual studio can clone the repository and just open the visual studio .sln file. The problem right now is I have to update the project files (.vfproj) each time I add source files.

0 Kudos
Honored Contributor III

Here is a suggestion:


For each Project, select a source file (e.g. FooBar.f90) that you know will always be in the Project. Or, add a dummy file (e.g. InsertFilesHere.f90). Then you can write an edit script (Pearl, AWK, ...) that searches for "InsertFilesHere.f90", example of line in .vfproj:


<File RelativePath="..\..\Source\A_FOSS\F_gen\InsertFilesHere.f90">


Then copies the line with  "InsertFilesHere.f90", advances to next line,

Inserts the copy

backup to beginning of inserted line

replaces  "InsertFilesHere.f90" with the new file name


Note, this has to be repeated for the same new file for each configuration in the project (Debug, Release, OpenMP, ...)

Then you can advance to the next new file and repeat.


You can do a similar thing with removing files.


Failing Pearl, AWK, ... expertise, you can always write this edit procedure in Fortran, C++, Python, ...


Jim Dempsey

0 Kudos