summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-03-01 13:58:15 +0100
committerPatrick Steinhardt <ps@pks.im>2017-03-01 13:58:15 +0100
commita02e8a388258d86c898d680e38897575f8de17ef (patch)
treef308d73472f4950bcd8e481c5a1f262925753140
parenta454641ee8b7b2ef1083b7f33d6135d87b50e9b0 (diff)
downloadlibgit2-a02e8a388258d86c898d680e38897575f8de17ef.tar.gz
cmake: only enable supported compiler warning flags
We currently unconditionally enable the "-Wall" and "-Wextra" flags. Some platforms rely on compilers which do not support these flags, though. One of these platforms is Haiku, which does not support "-Wextra" due to being stuck on GCC version 2. Fix builds on such platforms by adding these flags only if supported by the compiler.
-rw-r--r--CMakeLists.txt5
1 files changed, 4 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4bfd1b499..317ad34f9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -464,7 +464,10 @@ IF (MSVC)
# Precompiled headers
ELSE ()
- SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -Wall -Wextra ${CMAKE_C_FLAGS}")
+ SET(CMAKE_C_FLAGS "-D_GNU_SOURCE ${CMAKE_C_FLAGS}")
+
+ ADD_C_FLAG_IF_SUPPORTED(-Wall)
+ ADD_C_FLAG_IF_SUPPORTED(-Wextra)
IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
SET(CMAKE_C_FLAGS "-std=c99 -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS ${CMAKE_C_FLAGS}")