FFTW / fftw3

DO NOT CHECK OUT THESE FILES FROM GITHUB UNLESS YOU KNOW WHAT YOU ARE DOING. (See below.)
GNU General Public License v2.0
2.66k stars 651 forks source link

cmake: Set SIMD flags on appropriate source files only #322

Closed ryanvolz closed 1 year ago

ryanvolz commented 1 year ago

This addresses a shortcoming observed with the Windows FFTW package on conda-forge, which uses CMake to build with MSVC. Those packages are built with SSE2 and AVX instructions enabled, and contrary to the desired behavior, users with processors that don't have AVX support have been reporting that the library fails to load. I finally tracked this down to the fact that when using CMake the entire library is built with the enabled SIMD flags, rather than just the specific SIMD files as with configure/make. Thus the compiler was inserting SIMD instructions elsewhere in the library, not gated by the check for whether the runtime CPU supported them.

This PR modifies the CMake build so that it applies the SIMD flags only on the appropriate source files as with configure/make. Patching this fix into the conda-forge package allowed me to use the library on a machine without AVX support while the package still had it enabled.