Using Project References to enforce cross-project build order in a solution

Using Project References to enforce cross-project build order in a solution

I have a relatively large legacy codebase (~25 years old) that I am looking to make incremental build improvements on. The inter-project dependencies are very high, and we are going to work on that in the future, but I want to improve our build process on what we have. We currently use a build script to build all the projects sequentially, ensuring that all of the dependencies happen in the correct order. Unfortunately, this means our build is very serial, with approximately 45 minutes of build time each for release and debug. 

We are using Visual Studio 2013 (a mix of Professional /Premium/Ultimate) with Intel Visual Fortran Composer 2013 SP1. We have ~180 C++ projects and ~25 Fortran projects. The codebase as a whole is ~280 projects with varying degrees of sharing over ~20 solutions. 

My current attempt at improving the build is to set up the project references so that each project is aware of what it needs to build. Nearly every C++ project depends on another C++ project, and a good portion of the high-level C++ projects link to the Fortran .libs. Currently we have all the .lib linking set up correctly - I do not need any assistance with this part of it). 

The first option I investigated was looking at the Project Dependencies (Project -> Project Dependencies) where one can go through and select a project and then identify its dependencies. This is probably the most straightforward solution, but it unfortunately is not portable outside of its solution. For example, in Solution SLN_A, I have four projects, A, B, C, and D (Fortran)A depends on B and C, and C depends on D. I can set all these up in the Project Dependencies window, and Visual Studio will build B and D first, then C, then A. If I then add A, B, C, and D to another solution , I have to SLN_B, I have to manually configure these project dependencies again. I'm lazy and really didn't want to go do this for every solution, so I looked for something else.

I have found that native Visual C++ projects have the ability to add "Project References" to other projects in that solution (Project -> Properties -> Common Properties -> References).  This gets stored on each Project independently. In the previous example, I would tell A that it depends on B and C by stating that A has a reference to B and C. Similarly for C, I would say that it references D. When I add A, B, C, and D, to either SLN_A or SLN_B, the build order dependency is automatically discovered. If I forget to include C into a project, when it attempts to build from scratch, it will fail because I don't have that project in the solution. It kind of enforces the "Include What You Use" idea in C++. 

I really like the second option, but here's the problem with it: Visual Fortran Projects can not be selected as references. Thus, I am stuck having all of my C++ references defined to the other C++ projects, but they have no idea/knowledge of the fact they might reference a Fortran project. My build order is now about 90% correct, but the fortran projects are just scattered in there randomly as Visual Studio sees fit. I have already gone through the work of setting up all the C++-project dependencies to the other C++ projects, and am now looking to finish the Fortran-side of things.

Here are my questions:

  1. Is there any way to have project references for Visual Fortran projects? vfproj->vcxproj or vcxproj->vfproj?
  2. If this is not possible, do we know why?
  3. Is there a feature request site for Intel Visual Fortran that I could submit this to, or is this a Visual-Studio thing?
  4. Do you have any suggestions on how I can deal with this issue in its current state?

Current workaround is to enforce as many project dependencies as possible, and then return to the solution-level dependencies and individually add the Visual Fortran dependencies there. Again, not portable, but it does cut down the scope of work largely. 

Thank you in advance for your help and advice! 

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

It's not possible to use references for non-Microsoft projects. Basically, the MSVC project system ignores projects for any non-MS language.

You might speed up your Fortran builds by setting the project property Fortran > General > Multi-processor compilation, and using MSDEV from your script to build the project (if you're not already doing so.)

We are looking at switching to the MSBUILD system in the future which might help you some, but not at this time.

Steve - Intel Developer Support

Steve, thank you for the information. It appears my workaround (Set up as many C++ project references as possible, followed by the Solution-level dependencies) seems to work okay for the time being (I am down to an 18-minute build from the nearly two hour start time). 

It sounds like I need to put in a request to Microsoft to have the MSVC project system support non-MS languages.

Not the news I was hoping to hear, but more what I was expecting. Thank you!

Leave a Comment

Please sign in to add a comment. Not a member? Join today