mirror of https://github.com/xiph/flac
[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.
This commit is contained in:
parent
526b28a95e
commit
1c0eea679a
|
@ -83,14 +83,15 @@ if(NOT WIN32)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
|
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wmissing-declarations -Winline")
|
set(CMAKE_C_FLAGS "-Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wmissing-declarations -Winline ${CMAKE_C_FLAGS}")
|
||||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -funroll-loops")
|
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG ${CMAKE_C_FLAGS_RELEASE}")
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wsign-promo -Wundef")
|
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wsign-promo -Wundef ${CMAKE_CXX_FLAGS}")
|
||||||
|
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||||
endif()
|
endif()
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /O2 /Ob2 /Oi /Ot /Oy")
|
set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /Oi /Ot /Oy /DNDEBUG ${CMAKE_C_FLAGS_RELEASE}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
|
@ -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_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")
|
set_source_files_properties(lpc_intrin_fma.c PROPERTIES COMPILE_FLAGS "/arch:AVX2 /fp:fast")
|
||||||
endif()
|
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()
|
else()
|
||||||
check_cpu_arch_ppc64(FLAC__CPU_PPC64)
|
check_cpu_arch_ppc64(FLAC__CPU_PPC64)
|
||||||
if(FLAC__CPU_PPC64)
|
if(FLAC__CPU_PPC64)
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
#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)))
|
||||||
#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)
|
#if __has_builtin(__builtin_ia32_maxps)
|
||||||
#define FLAC__SSE_SUPPORTED 1
|
#define FLAC__SSE_SUPPORTED 1
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue