From ae348c6baa7e946b489f78f2749582f23da98dd2 Mon Sep 17 00:00:00 2001
From: Andreas Rogge <andreas.rogge@bareos.com>
Date: Mon, 15 Jul 2019 09:47:43 +0200
Subject: [PATCH 1/2] cmake: treat format-string warnings as errors

The build system for newer Fedoras does this by defaults
and it is probably a good idea to watch out for these, so
we enable -Wformat -Werror=format-security if the compiler
supports it.
---
 core/CMakeLists.txt | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index 9a1f7e2..c62fc8b 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -42,6 +42,16 @@ if (${compiler_will_suggest_override})
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override")
 endif()
 
+# make format-security issues a compiler-error
+CHECK_CXX_COMPILER_FLAG(-Wformat compiler_format_security)
+if (${compiler_format_security})
+   set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat")
+endif()
+CHECK_CXX_COMPILER_FLAG(-Werror=format-security compiler_error_format_security)
+if (${compiler_error_format_security})
+   set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=format-security")
+endif()
+
 # warn on sign-conversion
 #include(CheckCCompilerFlag)
 #CHECK_C_COMPILER_FLAG(-Wsign-conversion c_compiler_will_warn_sign_conversion)
-- 
1.8.3.1

