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.
The Visual Studio build tools include a C compiler that you can use to create everything from basic console programs to full Windows Desktop applications, mobile apps, and more.
GCC via Mingw-w64 on Windows. Microsoft C++ compiler on windows. Clang for XCode on MacOS.
Support for C11 and C17 standards is available in Visual Studio 2019 version 16.8 and later. Support requires an updated Universal C Runtime (UCRT) and Windows SDK version to work properly with the conforming preprocessor ( /Zc:preprocessor ).
Microsoft C++ Compiler (MSVC) This is the default compiler for most Visual Studio C++ projects and is recommended if you are targeting Windows.
In the cl.exe of Visual Studio 2005 at least, there is the option /showIncludes
.
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:
It's how I've done it, and it worked. Good luck!
The compiler stores dependencies in the intermediate .idb file. You might be able to parse it from there.
See https://msdn.microsoft.com/en-us/library/kfz8ad09.aspx
You can find all included files prefixed with "/mr/inversedeps/" or "/ipm/header/" in there, it seems.
I think you should also find dependencies in other intermediate files, e.g. "CL.read.1.tlog".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With