0

In Visual C++ 2012, I want to have a user-defined macro (the ones used in project property sheets) whose value can be defined differently for each configuration.

I have created user macros with help of this article, but changing its value for a specific configuration changes it for all configurations.

Is there a way to have its value defined differently at each configuration?

CharlesB
  • 86,532
  • 28
  • 194
  • 218

1 Answers1

1

Found answer in this post: Using Visual Studio project properties effectively for multiple projects and configurations

In the newly created .props file, replace the first PropertyGroup with the following

  <PropertyGroup Label="UserMacros">
    <MilVersion Condition="'$(Configuration)'=='Debug-ConfigA'">Value1</MilVersion>
    <MilVersion Condition="'$(Configuration)'=='Debug-ConfigB'">Value2</MilVersion>
    <MilVersion Condition="'$(Configuration)'=='Release-ConfigA'">Value1</MilVersion>
    <MilVersion Condition="'$(Configuration)'=='Release-ConfigB'">Value2</MilVersion>
  </PropertyGroup>

In this code, the user macro $(MilVersion) will be Value1 in configurations (Debug|Release)-ConfigA, and Value2 in configurations (Debug|Release)-ConfigB.

Community
  • 1
  • 1
CharlesB
  • 86,532
  • 28
  • 194
  • 218