简体   繁体   中英

Building a solution with multiple projects and multiple configuration

Visual Studio 2010 Premium, Native WIN32 MFC Project (no .net project in solution).

We have a complex solution with 35 projects. We have many clients for that product and what we normally do was to create a separate configuration for each client. Configuration did not have any major changes except few #define and changes to output directory. It was working fine but now with each change in product requires change in multiple configuration and is also error prone. We want to clean up multiple configurations with just one generic configuration depending on certain parameters and passing those parameters through a batch file for building builds.

to build for a client 'A' conditional compilation #define _BUILD_PROJECT_FOR "A" its output folder is in "c:\\builds\\client\\a" out of 35 projects in solution we need only 32 projects for that client

What command and parameters to pass so that I can build a solution at command line by just passing #ifdef, what projects to build and their output directory.

I am trying with msbuild but unable to pass to compiler the preprocessor arguments.

This works for me. Using VS2010, I have several projects on the go and all of them needs to #include a few .h files from a common project where I sort of keep them there as shared .h files. If I use something like #define ACTION in the project I am working with, it won't be recognized in any of the shared project files when using #ifdef ACTION while compiling. To resolve that issue, instead of adding #define ACTION in the working project, I add it to the command line option. You get this under Project Properties, C/C++ >> Command Line, enter /D "ACTION" in the Additional Option box. It's the same as saying #define ACTION as far as the compiler is concerned.

Additional notes, I also had to "Add" Add >> Existing Items, of the .h and .cpp shared files I wanted to use from my shared project into my working project to satisfy my complaining linker. I hope this helps.

对于预处理器指令,您可以查看上一个问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM