How can I set the value of the param 'Enable Enhanced Instruction Set
' when compiling with msbuild
from command line ?

- 53
- 5
-
presumably https://stackoverflow.com/questions/15141429/how-to-set-preprocessordefinitions-as-a-task-propery-for-the-msbuild-task will work – Alan Birtles Nov 17 '20 at 09:44
-
What is your VS version? – Mr Qian Nov 18 '20 at 03:13
-
https://stackoverflow.com/questions/6448256/how-can-msbuild-exe-be-set-up-to-embed-the-proper-value-for-sse2-into-m-ix86-fp – user6380706 Nov 18 '20 at 14:50
1 Answers
To realize this, it might be a complex but can be done. You only need to be with the help of a MSBuild property to transmit the value from msbuild command line into the EnableEnhancedInstructionSet
Item matadata.
MSBuild can transmit the msbuild property rather then item metadata.
Solution
Modify these on your xxx.vcxproj file:
1) First set a default value Not Set
for it.
<PropertyGroup>
<Instruction_Set>NotSet</Instruction_Set>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<EnableEnhancedInstructionSet>$(Instruction_Set)</EnableEnhancedInstructionSet>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
2) Then, you can use msbuild command line like these to set it:
msbuild xxx\xxx.vcxproj -t:build -p:Instruction_Set=StreamingSIMDExtensions
The values of the parameters are these:
The latter is what you need to use
SSE: StreamingSIMDExtensions
SSE2: StreamingSIMDExtensions2
AVX: AdvancedVectorExtensions
AVX2: AdvancedVectorExtensions2
AVX512: AdvancedVectorExtensions512
IA32: NoExtensions
Not Set: NotSet
You should use the value of it on the command line:
msbuild xxx\xxx.vcxproj -t:build -p:Instruction_Set=xxx
===========================================
Update
I tested all the parameters under VS2019 successfully. And I wonder where goes wrong.
Please see these:
a) use SSE:
msbuild xxx\xxx.vcxproj -t:build -p:Instruction_Set=StreamingSIMDExtensions
b) use AVX:
msbuild xxx\xxx.vcxproj -t:build -p:Instruction_Set=AdvancedVectorExtensions
c) use AVX512:
msbuild xxx\xxx.vcxproj -t:build -p:Instruction_Set=AdvancedVectorExtensions512
d) use IA32:
msbuild xxx\xxx.vcxproj -t:build -p:Instruction_Set=NoExtensions

- 21,064
- 1
- 31
- 41
-
It works! but just one comment. Almost in the version of VS I'm running (2019) the values of the parameter are wrong. It accept values such as 'NotSet','AdvancedVectorExtensions2','StreamingSIMDExtensions2' etc.. – user6380706 Nov 18 '20 at 15:37
-
All values which I list are all tested in VS2019 and I make sure that they are all right. So I am curious where it goes wrong. You should use `-p:Instruction_Set=StreamingSIMDExtensions` or `-p:Instruction_Set=StreamingSIMDExtensions2` ....etc. – Mr Qian Nov 19 '20 at 02:12
-
The parameters I list are followed by the actual values to be entered. I have update my answer. See `update` and you can check it. – Mr Qian Nov 19 '20 at 02:25
-
If it helps, please do not forget to [accept it](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) and if not, please feel free to let us know – Mr Qian Nov 19 '20 at 02:26
-
1OK sorry, I misunderstood the way the params were written ;). At first I thought the bold text was the value of the param – user6380706 Nov 19 '20 at 10:00
-
It does not matter. Anyway, your issue has resolved by our joint efforts. I have added it into the answer. Have a nice day! – Mr Qian Nov 19 '20 at 10:04