summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorEmil Velikov <emil.l.velikov@gmail.com>2021-11-21 14:26:53 +0000
committerEmil Velikov <emil.l.velikov@gmail.com>2021-11-21 14:28:29 +0000
commit8d4d0b346fcb22ef9b5f7165eae4d5a18bd62f09 (patch)
treea2942293332383a50a29f9c8ad438e7c96c5380e /CMakeLists.txt
parent4f598ce28aa370e945103eb9a17f03c7c820c1e8 (diff)
downloadlibarchive-8d4d0b346fcb22ef9b5f7165eae4d5a18bd62f09.tar.gz
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 <emil.l.velikov@gmail.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt23
1 files changed, 4 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6dfdf966..6a87d615 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")