3

I would like to distribute Visual Studio project files as part of a source only distribution in such a way that it will automatically build for the native architecture of the user's machine. So, if they have 64 bit it will build for it, if they have AVX or AVX2 it will build for those. This is what gcc's -march=native flag does. I haven't been able to find an equivalent to this with visual studio - does it exist or is there a workaround? I'm using Visual Studio Express 2013, and I'd like it to be something that would work with one of the free Express versions as most users won't have access to one of the paid versions. Thanks!

thesamovar
  • 91
  • 1
  • 4
  • I think its the same question as in: http://stackoverflow.com/questions/3832552/conditionally-use-32-64-bit-reference-when-building-in-visual-studio Be aware, the answer looks quite convoluted. – SlySherZ Oct 21 '14 at 11:41
  • Thanks! I think that's about switching dependencies based on the build target rather than automatically setting the build target, and only specific to 32/64 bit, not including processor features (like SSE/AVX/etc.). Maybe something in there can be used though. – thesamovar Oct 21 '14 at 14:35
  • As far as I can tell, there are no environment variables or properties available within any version of Visual Studio that will tell you if you're running on a processor that supports /arch:AVX or /arch:AVX2. You could write a helper app that reports processor capabilities and perhaps find a way to use that app in a pre-build step within the build system to set compiler switches. See the [__cpuid docs on MSDN](http://msdn.microsoft.com/en-us/library/hskdteyh.aspx) for an example of checking for AVX/AVX2 support. – Colin Robertson Oct 22 '14 at 19:51
  • Thanks Colin! OK, it looks like that might be rather involved. I think I'll just add a large note to the documentation telling users to switch it on by hand. It's a shame that this isn't built in. – thesamovar Oct 23 '14 at 12:17

0 Answers0