Project options are defined for a configuration so you can have different values for a project option for different builds. A given configuration can inherit the project options of other configurations. When the project system requires a project option value, it checks for the existence of the project option value in the current configuration and then in the set of inherited configurations. You can specify the set of inherited configurations using the Configurations dialog.
A special configuration named Common is always inherited by a configuration. The Common configuration allows you to set project options that will apply to all configurations you create. If you are modifying a project option of your project, you almost certainly want each configuration to inherit it, so ensure that the Common configuration is selected.
If the project option is unique, the build system will use the one defined for the particular configuration. If the project option isn't defined for this configuration, the build system uses an arbitrary one from the set of inherited configurations.
If the option is still undefined, the build system uses the value for the Common configuration. If it is still undefined, the build system tries to find the value in the next higher level of the project hierarchy.
solution [Common] — Preprocessor Definitions = CommonSolutionDef
solution [Debug] — Preprocessor Definitions = DebugSolutionDef
solution [Release] — Preprocessor Definitions = ReleaseSolutionDef
project1 - Preprocessor Definitions =
file1 - Preprocessor Definitions =
file2 [Common] — Preprocessor Definitions = CommonFile1Def
file2 [Debug] — Preprocessor Definitions = DebugFile1Def
project2 [Common] — Preprocessor Definitions = ProjectDef
file1 — Preprocessor Definitions =
file2 [Common] - Preprocessor Definitions = File2Def
In the above example, the files will be compiled with these preprocessor definitions when in Debug configuration…
File | Setting |
project1/file1 | CommonSolutionDef, DebugSolutionDef |
project1/file2 | CommonSolutionDef, DebugSolutionDef,CommonFile1Def, DebugFile1Def |
project2/file1 | CommonSolutionDef, DebugSolutionDef, ProjectDef |
project2/file2 | ComonSolutionDef, DebugSolutionDef, ProjectDef, File2Def |
…and the files will be compiled with these Preprocessor Definitions when in Release configuration:
File | Setting |
project1/file1 | CommonSolutionDef, ReleaseSolutionDef |
project1/file2 | CommonSolutionDef, ReleaseSolutionDef, CommonFile1Def |
project2/file1 | CommonSolutionDef, ReleaseSolutionDef, ProjectDef |
project2/file2 | ComonSolutionDef, ReleaseSolutionDef, ProjectDef, File2Def |