I am working with a Visual Studio 2005 C++ solution that includes multiple projects (about 30). Based upon my experience, it often becomes annoying to maintain all the properties of the projects (i.e include path, lib path, linked libs, code generation options, ...), as you often have to click each and every project in order to modify them. The situation becomes even worse when you have multiple configurations (Debug, Release, Release 64 bits, ...).
Real life examples:
- Assume you want to use a new library, and you need to add the include path to this library to all projects. How will you avoid to have to edit the properties of each an every project?
- Assume you want to test drive a new version of library (say version 2.1beta) so that you need to quickly change the include paths / library path / linked library for a set of projects?
Notes:
- I am aware that it is possible to select multiple projects at a time, then make a right click and select "properties". However this method only works for properties that were already exactly identical for the different projects : you can not use it in order to add an include path to a set of project that were using different include path.
- I also know that it is possible to modify globally the environment options (Tools/Options/Project And solutions/Directories), however it is not that satisfying since it can not be integrated into a SCM
- I also know that one can add "Configurations" to a solutions. It does not helps since it makes another set of project properties to maintain
- I know that codegear C++ Builder 2009 offers a viable answer to this need through so called "Option sets" which can be inherited by several projects (I use both Visual Studio and C++ Builder, and I still thinks C++ Builder rocks on certain aspects as compared to Visual Studio)
- I expect that someone will suggest an "autconf" such as CMake, however is it possible to import vcproj files into such a tool?
As suggested, you should look at Property Sheets (aka .vsprops files).
I wrote a very short introduction to this feature here.
I think you need to investigate properties files, i.e. *.vsprops (older) or *.props (latest)
You do need to add the properties file manually to each project, but once that's done, you have multiple projects, but one .[vs]props file. If you change the properties, all projects inherit the new settings.
Yes, I'd definitely suggest using CMake. CMake is the best tool (I think I've actually tried them all) which can generate Studio project files.
I also had the issue of converting existing .vcproj files into CMakeLists.txt, and I wrote a Ruby-script which takes care of most of the conversion. The script doesn't handle things like post-build steps and such, so some tweaking is necessary, but it will save you the hassle of pulling all the source file names from the .vcproj files.
I often need to do something similar since I link to the static runtime libraries. I wrote a program to do it for me. It basically scans all of the subdirectories of whatever path you give it and ids any .vcproj files it finds. Then one by one, it opens them modifies them and saves them. Since I only use it rarely, the path is hard coded it, but I think you'll be able to adjust it how you like.
Another approach is to realize that Visual Studio Project files are simply XML files and can be manipulated with your favorite XML class. I've done something using C#'s
XmlDocument
for updating the include directories when there were A LOT of include directories that I didn't want to type in. :)I'm including both examples. You will need to modify them to your own needs, but these should get you started.
This is the C++ version:
This is the C# version. Enjoy...
*.vcxproj files are msbuild files. So you just take a property you don't want in all your project files and delete it. Then put it in your property sheet. Then make sure all the projects files properly import that property sheet.
This can be incredibly tedious for hundreds of files. I wrote a tool make this interactive:
https://github.com/chris1248/MsbuildRefactor