2

I have a file in one of our projects that defines a variable that affects the behavior of most of the other modules throughout the project. Let's call it custom.h. It looks like this:

#pragma once

#define BUILD 3 // 1: personal, 2: select, 3: elite

Throughout the project there are numerous references to this variable to control behavior between product editions. Changing this value triggers a rebuild of most of the project. What I'd like to do is create separate Build Configurations, one for each edition, so that it only rebuilds modified files, not the entire project, when I make a change to the edition.

If I have three Configurations, one for each edition, is there a way to get Visual Studio not to rebuild when a change is made to this custom.h file if the edition matched what was built for that Configuration already? IE, if I set BUILD to 3 and build with the Elite Configuration, then change BUILD to 2 and build with the Select Configuration, I don't want it to rebuild the whole project, because the Intermediary Files for Select should already exist.

The Configurations all have their own Intermediary Directories as well as their own Output Directories. It feels like I'm close to what I need, but some advice at this point would be invaluable.

g.d.d.c
  • 46,865
  • 9
  • 101
  • 111

1 Answers1

1

Rather than changing the defines for each build, one option would be to use configurations like you mentioned and define Preprocessor Definitions in your project. Then use compile directives for each configuration. I think this would let your incremental compiles work correctly.

Your custom.h would look like this:

#pragma once

#if defined(PERSONAL)
    #define BUILD 1 
#elif defined(SELECT)
    #define BUILD 2 
#elif defined(ELITE)
    #define BUILD 3 
#endif

The Preprocessor Definitions can be set in the Project Properties or via command line switches depending on how you build.

Directives on MSDN

Preprocessor Definitions on MSDN

Mike Ohlsen
  • 1,900
  • 12
  • 21
  • This very possibly gets me where I need to be - I'm making the changes to the projects / configurations now. It'll take some time to get the intermediaries generated for the editions, but if this works I'll let you know. Thanks! – g.d.d.c Feb 14 '12 at 19:00
  • you would likely end up with 6 configurations then, 3 for debug and 3 for release – Mike Ohlsen Feb 14 '12 at 19:58
  • This seems to work so far, so I'm going to accept this answer on this question. I have another problem, but it's not directly related - I'll post it here shortly. – g.d.d.c Feb 14 '12 at 21:02