When working with Windows Runtime Library Variant, it is important to understand the difference between the Retail and Debug variants. The Retail variant is optimized for performance and is used for the final release of your application. On the other hand, the Debug variant is used during development and testing to help identify and fix issues.
By default, Boost Build, a popular build system, builds both the Retail and Debug variants simultaneously. However, there may be cases where you want to control the build of these variants independently. In this article, we will discuss how you can achieve this.
Understanding Boost Build Variants
Before we dive into controlling the Windows Runtime Library Variant, let's briefly understand Boost Build variants. Boost Build allows you to define different build variants for your project, such as Debug, Release, Profile, and more. Each variant can have its own set of build options, including compiler flags, optimization levels, and library dependencies.
By default, Boost Build builds both the Retail and Debug variants together. This means that any changes you make to the build options will affect both variants. However, there are scenarios where you may want to build only the Retail or Debug variant independently.
Controlling Windows Runtime Library Variant
To control the Windows Runtime Library Variant independently of the Boost Build variant, you need to modify the Boost Build configuration file for your project. This file is typically named project-config.jam and is located in the root directory of your project.
Open the project-config.jam file in a text editor and look for the line that starts with using msvc :. This line defines the default build options for the Microsoft Visual C++ compiler.
To build the Retail variant independently, add the following line after the using msvc : line:
using msvc : : : <variant>retail ;
To build the Debug variant independently, add the following line:
using msvc : : : <variant>debug ;
Save the project-config.jam file and run the Boost Build command to build your project. You will now see that only the specified variant is built.
Example
Let's consider an example where you have a project named "MyApp" and you want to build the Retail variant independently of the Boost Build variant.
Open the project-config.jam file for the "MyApp" project and add the following lines:
using msvc : : : <variant>retail ;
using msvc : : : <variant>debug ;
Save the file and run the Boost Build command to build your project. You will notice that only the Retail variant is built, regardless of the Boost Build variant specified.
In this article, we discussed how to control the Windows Runtime Library Variant independently of the Boost Build variant. By modifying the Boost Build configuration file, you can choose to build either the Retail or Debug variant independently. This flexibility allows you to optimize your build process and focus on specific variants based on your project's requirements.
| Reference | Link |
|---|---|
| Boost Build Documentation | https://www.boost.org/build/doc/html/index.html |
| Windows Runtime Library Variant | https://docs.microsoft.com/en-us/cpp/cppcx/debug-and-release-builds?view=msvc-160 |