Option Sets Overview
Go Up to Using the Code Editor and the IDE
Both C++Builder and Delphi support the use of option set files for managing build configurations. Both personalities also support the ability to apply an option set to a build configuration by reference, as described in this topic.
Option sets are disk files that contain the values you have set for build-related project options. Option sets are saved in files with the extension
.optset, in your project folder. You can apply an option set to the current build configuration either by reference or by modifying values.
Creating and Editing Option Sets
You can create an option set by using the New Option Set command in the context menu in the Project Manager. This command creates a new, empty option set and adds it to your project. To edit an option set, use the Edit context-menu command in the Project Manager. The Project Options dialog box opens, enabling you to view and adjust the values for the options in the option set.
Comparing Option Sets and Build Configurations
Both option sets and build configurations consist of sets of option values related to the MSBuild project file. The main distinction is that build configurations are saved in the project file, while option sets are saved in
.optset XML files independent of projects.
Saving and building a project saves changes to its build configurations, but option sets are saved separately (using the Save As button on Project > Options pages). Changing a project's configurations and adding or deleting configurations does not affect option sets. Similarly, saving option sets does not change configurations.
Option sets can be applied to build configurations either by reference or by value. Each project has its own list of build configurations as well as a list of option sets that you have added by reference, independent of other projects. Option sets that are added by value have no continuing affect on the project. You can access any option set file from any project.
Option Values in Build Configurations and Option Sets
Any given configuration or option set might not contain values for all possible project options. When you save an option set, only the values that are different from the parent configuration are saved - not values for every option.
For instance, suppose you have a project open in the IDE and the active configuration is the Debug configuration. You change one option and then save the option set. The only option values that are saved in the option set file are the one option value you changed plus any option values in the Debug configuration that are different from the defaults (these changed values are shown in boldface print in the Project > Options dialog box).
Applying an Option Set
You can apply the values of an option set (an
.optset file) to any configuration in any project by using the Apply Option Set dialog, available by selecting the Apply button on the Project > Options dialog box.
You can apply an option set in either of the following two ways:
- Add as reference - This means that the option values that are applied to the configuration are subsequently updated whenever the parent option's value changes in the option set file.
- Modify this configuration - This means that the option values in the configuration are changed only once and do not refer to the parent option set.
Applying an Option Set as a Reference
When you select the Add as reference option on the Apply Option Set dialog box, the values in the option set are added to the current configuration and replace only those values, not affecting any of the options that have no specific value set in the option set you are applying.
If you change the option set later, the change is also made to any of the configuration's values that are derived from that option set. This enduring association between an option set and a build configuration is established when you apply the option set as a reference. In the Project Manager, an option set that was applied by reference is listed under the node of the associated build configuration. You must save changes to the project in order to save the reference to the option set in the project.
Properties in option sets are applied in the order that the option sets are listed in the Project Manager. That is, for properties that occur in multiple option sets, the last option set in the list overrides the value set in the option set above it, and so on. You can use drag-and-drop to reorder option sets that are listed by reference.
Modifying a Build Configuration by Applying an Option Set by Value
When you select the Modify this configuration option on the Apply Option Set dialog box, the values in the option set are applied to the current build configuration (the configuration listed in the Build Configuration field on the Project > Options dialog box).
This is a one-time application of values, and no other connection exists between the configuration and the option set. If you change the option set later, the build configuration is not affected.
The option set values are applied to the current build configuration according to the priority you select, as follows:
- Replace all values results in a build configuration that is an exact copy of the option set.
- Option set file adds the values of the option set to the current build configuration but does not change any other option values in the configuration.
- This configuration retains the values in the current build configuration and adds only those values from the option set for which no value is set in the build configuration.