[CMake] Honor WITH_AVX

Fixes https://github.com/xiph/flac/issues/286
This commit is contained in:
Martijn van Beurden 2022-03-04 14:02:37 +01:00
parent c157be0f77
commit f6b78e69e0
2 changed files with 40 additions and 30 deletions

View File

@ -50,8 +50,10 @@
#cmakedefine FLAC__USE_ALTIVEC #cmakedefine FLAC__USE_ALTIVEC
/* define to enable use of AVX instructions */ /* define to enable use of AVX instructions */
#cmakedefine01 WITH_AVX #cmakedefine WITH_AVX
#define FLAC__USE_AVX WITH_AVX #ifdef WITH_AVX
#define FLAC__USE_AVX
#endif
/* define to enable use of VSX instructions */ /* define to enable use of VSX instructions */
#cmakedefine FLAC__USE_VSX #cmakedefine FLAC__USE_VSX

View File

@ -69,6 +69,7 @@
#define FLAC__SSSE3_SUPPORTED 1 #define FLAC__SSSE3_SUPPORTED 1
#define FLAC__SSE4_1_SUPPORTED 1 #define FLAC__SSE4_1_SUPPORTED 1
#endif #endif
#ifdef FLAC__USE_AVX
#if (__INTEL_COMPILER >= 1110) /* Intel C++ Compiler 11.1 */ #if (__INTEL_COMPILER >= 1110) /* Intel C++ Compiler 11.1 */
#define FLAC__AVX_SUPPORTED 1 #define FLAC__AVX_SUPPORTED 1
#endif #endif
@ -76,6 +77,7 @@
#define FLAC__AVX2_SUPPORTED 1 #define FLAC__AVX2_SUPPORTED 1
#define FLAC__FMA_SUPPORTED 1 #define FLAC__FMA_SUPPORTED 1
#endif #endif
#endif
#elif defined __clang__ && __has_attribute(__target__) /* clang */ #elif defined __clang__ && __has_attribute(__target__) /* clang */
#define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x))) #define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x)))
#if __has_builtin(__builtin_ia32_maxps) #if __has_builtin(__builtin_ia32_maxps)
@ -90,6 +92,7 @@
#if __has_builtin(__builtin_ia32_pmuldq128) #if __has_builtin(__builtin_ia32_pmuldq128)
#define FLAC__SSE4_1_SUPPORTED 1 #define FLAC__SSE4_1_SUPPORTED 1
#endif #endif
#ifdef FLAC__USE_AVX
#if __has_builtin(__builtin_ia32_maxps256) #if __has_builtin(__builtin_ia32_maxps256)
#define FLAC__AVX_SUPPORTED 1 #define FLAC__AVX_SUPPORTED 1
#endif #endif
@ -99,6 +102,7 @@
#if __has_builtin(__builtin_ia32_vfmaddps) #if __has_builtin(__builtin_ia32_vfmaddps)
#define FLAC__FMA_SUPPORTED 1 #define FLAC__FMA_SUPPORTED 1
#endif #endif
#endif
#elif defined __GNUC__ && !defined __clang__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) /* GCC 4.9+ */ #elif defined __GNUC__ && !defined __clang__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) /* GCC 4.9+ */
#define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x))) #define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x)))
#define FLAC__SSE_SUPPORTED 1 #define FLAC__SSE_SUPPORTED 1
@ -118,6 +122,7 @@
#define FLAC__SSSE3_SUPPORTED 1 #define FLAC__SSSE3_SUPPORTED 1
#define FLAC__SSE4_1_SUPPORTED 1 #define FLAC__SSE4_1_SUPPORTED 1
#endif #endif
#ifdef FLAC__USE_AVX
#if (_MSC_FULL_VER >= 160040219) /* MS Visual Studio 2010 SP1 */ #if (_MSC_FULL_VER >= 160040219) /* MS Visual Studio 2010 SP1 */
#define FLAC__AVX_SUPPORTED 1 #define FLAC__AVX_SUPPORTED 1
#endif #endif
@ -125,6 +130,7 @@
#define FLAC__AVX2_SUPPORTED 1 #define FLAC__AVX2_SUPPORTED 1
#define FLAC__FMA_SUPPORTED 1 #define FLAC__FMA_SUPPORTED 1
#endif #endif
#endif
#else #else
#define FLAC__SSE_TARGET(x) #define FLAC__SSE_TARGET(x)
#ifdef __SSE__ #ifdef __SSE__
@ -139,6 +145,7 @@
#ifdef __SSE4_1__ #ifdef __SSE4_1__
#define FLAC__SSE4_1_SUPPORTED 1 #define FLAC__SSE4_1_SUPPORTED 1
#endif #endif
#ifdef FLAC__USE_AVX
#ifdef __AVX__ #ifdef __AVX__
#define FLAC__AVX_SUPPORTED 1 #define FLAC__AVX_SUPPORTED 1
#endif #endif
@ -148,6 +155,7 @@
#ifdef __FMA__ #ifdef __FMA__
#define FLAC__FMA_SUPPORTED 1 #define FLAC__FMA_SUPPORTED 1
#endif #endif
#endif
#endif /* compiler version */ #endif /* compiler version */
#endif /* intrinsics support */ #endif /* intrinsics support */