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

I am trying to enable AVX2 code generation via CMake in my Visual Studio 2013 projects, and still have no luck.

Things I tried:

  • Set CMAKE_CXX_FLAGS_*to enable /arch:AVX2as follows:SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:AVX2")
  • Set the target properties as follows: SET_TARGET_PROPERTIES("myproject" PROPERTIES COMPILE_FLAGS "/arch:AVX2"). I also tried replacing COMPILE_FLAGSwith COMPILE_DEFINITIONS, COMPILE_FEATURES(failed to generate project) and COMPILE_OPTIONS.

Every time I try to create projects, I will definitely delete the CMake cache so that it does not interfere with the generation of the project files.

What am I missing? Any help to shed light on this would be greatly appreciated. Thank you for your time.

+4
source share

All Articles