0001-CMakeLists.txt-conditionally-use-Wpedantic.patch 1.4 KB

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