views:

354

answers:

5

I would like to automatically generate a Makefile dependency list, but I am using Visual Studio 2005. If I were using GCC, I could pass -M (or one of the many variants) to create this dependency list.

Looking through the command line options to cl.exe, I don't see anything obvious. I can handle tweaking the output with post-processing, but the closer the better.

+1  A: 

Some answers on a similar question here.

Tim Sylvester
A: 

Not directly with cl.exe, but with this wrapper you can achieve what you're looking for:

http://msdn.microsoft.com/en-us/library/y209k0z6.aspx

tbs
Does that work with gcc's `-M` flag? Most compiler flag mappings would be trivial, but that one pretty much requires the pre-processor (or something like it) to run.
T.E.D.
The VC++ compiler does have a preprocessing-only option, but it won't do that. The `-M.*` settings that the OP wants are among those not supported by that package. See the bottom of `ccFile.cfg`, if you have it installed, or http://pastebin.com/m1707aa02
Tim Sylvester
+1  A: 

I had to deal with that exact problem. We wanted to add a script that replaces the -M option. Here's how I did it:

  1. find a source preprocessor ( and the include paths & defines you need )
  2. run it on the file you need, and it should produce a preprocessed version.
  3. most preprocessors have a switch that enables extra info ( such as the file where some code snippet came from )
  4. write a simple script to extract all the header names
  5. create a set out of them, so that you filter out duplicates.

It's how I've done it, and it worked. Good luck!

Geo
Any pointers to which preprocessor(s) you used?
Shepmaster
You could use Visual Studio's for this task. A pretty nice stand-alone preprocessor is `mcpp`. You can find it here `http://mcpp.sourceforge.net/`.
Geo
I haven't implemented it yet, but this seems like the best solution. Using Visual Studio sounds like the correct path, and it avoids having to have separate sets of flags to pass (one for dependencies and another for building).
Shepmaster
A: 

We had the exact same issue with Fortran, and ended up having to write our own mini-compiler to scan the source code and traverse all the #includes.

T.E.D.
how much time did you have to do this?
Geo
A: 

In the cl.exe of Visual Studio 2005 at least, there is the option /showIncludes.

js