From a71d007f3e01c990a721186895c70726e7649a75 Mon Sep 17 00:00:00 2001
From: Guilherme Amadio <amadio@cern.ch>
Date: Tue, 27 Nov 2018 14:20:29 +0100
Subject: [PATCH] Add macro to add compile options to ROOT

The intended use of this macro is to add compile options that are not
requirements of ROOT, like options to ignore certain warnings. However,
since the option names depend on the compiler, check each flag before
adding it to the list, so that only supported flags are added.
---
 cmake/modules/RootNewMacros.cmake | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/cmake/modules/RootNewMacros.cmake b/cmake/modules/RootNewMacros.cmake
index 0dc1eeca787..858a6355d95 100644
--- a/cmake/modules/RootNewMacros.cmake
+++ b/cmake/modules/RootNewMacros.cmake
@@ -1419,6 +1419,20 @@ function(ROOT_ADD_C_FLAG var flag)
   endif()
 endfunction()
 
+#----------------------------------------------------------------------------
+# ROOT_ADD_COMPILE_OPTIONS(flags)
+#----------------------------------------------------------------------------
+macro(ROOT_ADD_COMPILE_OPTIONS flags)
+  foreach(__flag ${flags})
+    check_cxx_compiler_flag("-Werror ${__flag}" __result)
+    if(__result)
+      add_compile_options(${__flag})
+    endif()
+  endforeach()
+  unset(__flag)
+  unset(__result)
+endmacro()
+
 #----------------------------------------------------------------------------
 # find_python_module(module [REQUIRED] [QUIET])
 #----------------------------------------------------------------------------
-- 
GitLab