When I create property sheets in C++ projects in VS, at least in 10 or 12, if I create what the GUI calls "User Macros" I see the appear in resultant property sheet file as properties in a <PropertyGroup> element which I understand. However the properties also appear later in the file in an <ItemGroup> like this
My question is what does this do? Does this mean I can use these properties in some way that I can't if they just properties in the <PropertyGroup>? Why would I care if they appear as items in the item group as well? Does <BuildMacro> have some special meaning to MSBuild independent of VS or is this just for VS internal use?
I have done some experimentation and looked on line but not found anything useful.
OK, so after more playing I found one thing that it does. It seems to make the property editable in the Visual Studio "User Macro" property screen. If I remove the <BuildMacro> for a given property it disappears. This makes some sense as you presumably don't want the property editor to show world + dog properties. The syntax does seem very convoluted though if the sole purpose it to convey what is in effect a boolean flag. So does it do anything else?
As you definition, we can learn that %(BuildMacro.Value) equals $(Foo).
We can set $(Foo) via msbuild command like: msbuild <project name> /p: zoo=<value>
About more information of item definition, please view:
If you search for "BuildMacro" in the *.targets files installed under "C:\Program Files (x86)\MSBuild", you'll see that the SetUserMacroEnvironmentVariables target in Microsoft.Cpp.targets collects all the BuildMacro items that have an EnvironmentVariable metadata with the value "true", and sets an environment variable for each. This would have been more difficult to implement if the property sheet only defined properties rather than BuildMacro items.
It seems the target also creates a property for each such BuildMacro item, via TaskParameter="OutputEnvironmentVariable". I don't know why it does that; hasn't the property sheet already created those properties?