How can msbuild.exe be set up to embed the proper value for SSE2 into _M_IX86_FP?
I have built a solution with VS2010 Express Edition
with SSE2
set in the properties C++
code generation enhanced instruction set. Then in the program test against predefined MARCO _M_IX86_FP
yields as ex开发者_如何学Gopected the value of 2. The same project built with msbuild.exe
with
/p:"VCBuildAdditionalOptions=/arch:SSE2"
appears to build the solution with /arch:SSE2 in place for each project. But, the test against predefined MARCO _M_IX86_FP
yields a value of zero.
How can msbuild.exe
be set up to embed the proper value for SSE2 into _M_IX86_FP
?
testcase
// sse2testcase.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
int _tmain(int argc, _TCHAR* argv[])
{
int dummy;
if (_M_IX86_FP == 0)
std::cout << "No sse" <<std::endl;
if (_M_IX86_FP == 1)
std::cout << "sse1" <<std::endl;
if (_M_IX86_FP == 2)
std::cout << "sse2" <<std::endl;
std::cin >> dummy;
return 0;
}
Result build with msbuild
fails to present the proper values of _M_IX86_FP
Workaround:
1. Open Visual Studio 2010 IDE 2. Open or create a solution. (Any solution will do) 3. Tools->Settings Check mark Expert Settings 4. At the bottom of the Solution Panel Select Properties (Text may be truncated) 5. Expand either Debug or Release. 6. Right click on Microsoft.Cpp.Win32.user 7. Expand C++ and select Code Generation 8. Next to Enable Enhanced Instruction Set. Select the desired setting. 9. Apply 10. Exit Visual Studio 2010 saving when requested.Microsoft.Cpp.Win32.user settings apply to all solutions and projects. This forces the setting of /arch:SSE or /arch:SSE2 to be present when Msbuild.exe invokes Cl.exe. The switch /p:"VCBuildAdditionalOptions=/arch:SSE2" is not needed. Still don't know why it doesn't work.
I guess you can't answer you own question.
A more thorough answer from Microsoft.
http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/2b772255-b37b-4da1-bc1e-b4681f5122f3/
Workaround:
- Open Visual Studio 2010 IDE
- Open or create a solution. (Any solution will do)
- Tools->Settings Check mark Expert Settings
- At the bottom of the Solution Panel Select Properties (Text may be truncated)
- Expand either Debug or Release,
- Right click on Microsoft.Cpp.Win32.user
- Expand C++ and select Code Generation
- Next to Enable Enhanced Instruction Set. Select the desired setting.
- Apply
- Exit Visual Studio 2010 saving when requested.
Microsoft.Cpp.Win32.user settings apply to all solutions and projects. This forces the setting of /arch:SSE or /arch:SSE2 to be present when Msbuild.exe invokes Cl.exe. The switch /p:"VCBuildAdditionalOptions=/arch:SSE2" is not needed. Still don't know why it doesn't work.
精彩评论