diff options
author | Martijn van Beurden <mvanb1@gmail.com> | 2022-09-17 09:20:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-17 09:20:15 +0200 |
commit | 1c0eea679ae4351c77c912988d0a24d90809965a (patch) | |
tree | 22e447da5bcda0f34796b6fa1338df3ce4a259a8 /CMakeLists.txt | |
parent | 526b28a95e0e7974904f14efde5b1c7351ea21c3 (diff) | |
download | flac-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 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 73a36cc1..b255f7b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,14 +83,15 @@ if(NOT WIN32) endif() 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_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -funroll-loops") + 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 "-DNDEBUG ${CMAKE_C_FLAGS_RELEASE}") endif() 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() 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() include(CMakePackageConfigHelpers) |