summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartijn van Beurden <mvanb1@gmail.com>2022-09-17 09:20:15 +0200
committerGitHub <noreply@github.com>2022-09-17 09:20:15 +0200
commit1c0eea679ae4351c77c912988d0a24d90809965a (patch)
tree22e447da5bcda0f34796b6fa1338df3ce4a259a8 /src
parent526b28a95e0e7974904f14efde5b1c7351ea21c3 (diff)
downloadflac-1c0eea679ae4351c77c912988d0a24d90809965a.tar.gz
[CMake] Prepend compiler flags, fix Clang compiler warnings
Because of issue https://github.com/xiph/flac/issues/437 compiler flags are prepended instead of appended, so the user can override them without altering the CMakeLists.txt. Also, Clang doesn't support per-function optimize options, so in CMake the fma file gets that option per-file. This is not supported by automake.
Diffstat (limited to 'src')
-rw-r--r--src/libFLAC/CMakeLists.txt3
-rw-r--r--src/libFLAC/include/private/cpu.h2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/libFLAC/CMakeLists.txt b/src/libFLAC/CMakeLists.txt
index 50cb6dbf..13dc129d 100644
--- a/src/libFLAC/CMakeLists.txt
+++ b/src/libFLAC/CMakeLists.txt
@@ -24,6 +24,9 @@ if(FLAC__CPU_X86_64 OR FLAC__CPU_IA32)
set_source_files_properties(lpc_intrin_avx2.c stream_encoder_intrin_avx2.c PROPERTIES COMPILE_FLAGS /arch:AVX2)
set_source_files_properties(lpc_intrin_fma.c PROPERTIES COMPILE_FLAGS "/arch:AVX2 /fp:fast")
endif()
+ if(WITH_AVX AND (CMAKE_C_COMPILER_ID MATCHES "Clang"))
+ set_source_files_properties(lpc_intrin_fma.c PROPERTIES COMPILE_FLAGS "-ffast-math")
+ endif()
else()
check_cpu_arch_ppc64(FLAC__CPU_PPC64)
if(FLAC__CPU_PPC64)
diff --git a/src/libFLAC/include/private/cpu.h b/src/libFLAC/include/private/cpu.h
index e5d23a7f..335b2f81 100644
--- a/src/libFLAC/include/private/cpu.h
+++ b/src/libFLAC/include/private/cpu.h
@@ -81,7 +81,7 @@
#endif
#elif defined __clang__ && __has_attribute(__target__) /* clang */
#define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x)))
- #define FLAC__FAST_MATH_TARGET(x) __attribute__ ((__target__ (x), optimize("-ffast-math")))
+ #define FLAC__FAST_MATH_TARGET(x) __attribute__ ((__target__ (x)))
#if __has_builtin(__builtin_ia32_maxps)
#define FLAC__SSE_SUPPORTED 1
#endif