Search code examples
msbuildfortranintel-fortran

How to use MsBuild.exe to build a fortran/c mixed project?


1. Background

I have a project which is managed by cmake, I then generate the solution files by Visual Studio 2019 geneartor. The folder strucutre looks like:

- main.sln
  - fotran_proj.vfproj (output a static lib libfortran.lib)
  - C_proj.vcxproj (dependent on libfortran.lib)
  - ALL_BUILD.vcxproj

It contains both fortran and c projects, and c project is dependent on fortran project.

I want to build the whole solution from commandline by msbuild.exe.

2. Environment

I use VS2019 with Intel Fortran Compiler on win10.

3. Question

When I try to use msbuild.exe to build it:

MSBuild.exe /t:build ALL_BUILD

It simply build the vcxproj part and ignore the vfproj parts. Why? How can I achieve this?


Solution

  • To the best of my knowledge, you can't do this. Intel Fortran's build system isn't recognized by msbuild, though that integration might happen sometime in the future.

    What you can do is use devenv from the command line to build your mixed-language solution. From an Intel Fortran command prompt window (or one where you have established the Intel environment), type devenv /? to see the usage and options. For example, I built a mixed-language solution as follows:

    devenv C_calls_F.sln /build "Debug|Win32"