1From 8fc28b4c4c01581b25220fdbc1eeda196e399256 Mon Sep 17 00:00:00 2001
2From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
3Date: Wed, 10 Oct 2018 09:28:00 +0200
4Subject: [PATCH] CMakeLists.txt: conditionally use -Wpedantic
5
6-Wpedantic is only provided by gcc >= 4.8. Since showing pedantic
7warnings is not really mandatory, let's only use this option when the
8compiler supports it.
9
10Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
11Upstream: https://github.com/quiet/libcorrect/pull/25
12---
13 CMakeLists.txt | 7 ++++++-
14 1 file changed, 6 insertions(+), 1 deletion(-)
15
16diff --git a/CMakeLists.txt b/CMakeLists.txt
17index 193f311..e570198 100644
18--- a/CMakeLists.txt
19+++ b/CMakeLists.txt
20@@ -3,13 +3,18 @@ project(Correct C)
21 include(CheckLibraryExists)
22 include(CheckIncludeFiles)
23 include(CheckCSourceCompiles)
24+include(CheckCCompilerFlag)
25
26 if(MSVC)
27 set(LIBM "")
28 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
29 else(MSVC)
30 set(LIBM "m")
31-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -std=c99 -Wpedantic -Wall")
32+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -std=c99 -Wall")
33+check_c_compiler_flag(-Wpedantic COMPILER_SUPPORTS_WPEDANTIC)
34+if(COMPILER_SUPPORTS_WPEDANTIC)
35+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic")
36+endif()
37 if(CMAKE_BUILD_TYPE STREQUAL "Debug")
38     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -O0 -fsanitize=address")
39     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_pie,")
40--
412.14.4
42
43