CMake: Enable '/arch:AVX2' in Visual Studio 2013 projects

4.2k views Asked by At

I'm trying to enable AVX2 code-generation via CMake on my Visual Studio 2013 projects and so far, I'm out of luck.

Things I've tried are:

  1. Set CMAKE_CXX_FLAGS_* to include /arch:AVX2 like so: SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:AVX2")
  2. Set target properties like so: SET_TARGET_PROPERTIES("myproject" PROPERTIES COMPILE_FLAGS "/arch:AVX2"). I also tried replacing COMPILE_FLAGS with COMPILE_DEFINITIONS, COMPILE_FEATURES (fails to generate project) and COMPILE_OPTIONS.

Each time I try generating the projects, I would make sure to delete the CMake cache so that it doesn't get in the way of generating the project files.

What am I missing? Any help to shed light on this would be much appreciated. Thanks for your time.

0

There are 0 answers