From: Emil Velikov Date: Sun, 21 Nov 2021 14:26:53 +0000 (+0000) Subject: cmake: fold gcc/clang sections X-Git-Tag: v3.6.0~25^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d4d0b346fcb22ef9b5f7165eae4d5a18bd62f09;p=thirdparty%2Flibarchive.git cmake: fold gcc/clang sections The flags used across the two are identical, apart from -g. There is no compelling reason, why we would omit -g for debug builds with GCC, while using it with clang. De-duplicate the sections. Signed-off-by: Emil Velikov --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dfdf966b..6a87d6154 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,24 +96,8 @@ endif () # Especially for early development, we want to be a little # aggressive about diagnosing build problems; this can get # relaxed somewhat in final shipping versions. -IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$") - SET(CMAKE_REQUIRED_FLAGS "-Wall -Wformat -Wformat-security") - ################################################################# - # Set compile flags for all build types. - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat -Wformat-security") - if (ENABLE_WERROR) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") - endif () - ################################################################# - # Set compile flags for debug build. - # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug" - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wextra") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wunused") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshadow") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wmissing-prototypes") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wcast-qual") -ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$") -IF (CMAKE_C_COMPILER_ID MATCHES "^Clang$") +IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR + CMAKE_C_COMPILER_ID MATCHES "^Clang$") SET(CMAKE_REQUIRED_FLAGS "-Wall -Wformat -Wformat-security") ################################################################# # Set compile flags for all build types. @@ -130,7 +114,8 @@ IF (CMAKE_C_COMPILER_ID MATCHES "^Clang$") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshadow") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wmissing-prototypes") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wcast-qual") -ENDIF (CMAKE_C_COMPILER_ID MATCHES "^Clang$") +ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR + CMAKE_C_COMPILER_ID MATCHES "^Clang$") IF (CMAKE_C_COMPILER_ID MATCHES "^XL$") SET(CMAKE_C_COMPILER "xlc_r") SET(CMAKE_REQUIRED_FLAGS "-qflag=e:e -qformat=sec")