Author: Andreas Beckmann <anbe@debian.org>
Description: fix disabling warnings
 g++ silently accepts -Wno-unknown-foo but errors out on -Wunknown-foo
 cc1plus warns on -Wno-unknown-foo

--- a/cub/cmake/AppendOptionIfAvailable.cmake
+++ b/cub/cmake/AppendOptionIfAvailable.cmake
@@ -11,3 +11,14 @@ if (${${_VAR}})
 endif ()
 
 endmacro ()
+
+macro (disable_cxx_warning_if_available _WARNING _LIST)
+
+string(MAKE_C_IDENTIFIER "CXX_FLAG_-W${_WARNING}" _VAR)
+check_cxx_compiler_flag("-W${_WARNING}" ${_VAR})
+
+if (${${_VAR}})
+  list(APPEND ${_LIST} "-Wno-${_WARNING}")
+endif ()
+
+endmacro ()
--- a/cub/cmake/CubBuildCompilerTargets.cmake
+++ b/cub/cmake/CubBuildCompilerTargets.cmake
@@ -56,11 +56,11 @@ function(cub_build_compiler_targets)
 
     # Disable GNU extensions (flag is clang only)
     append_option_if_available("-Wgnu" cxx_compile_options)
-    append_option_if_available("-Wno-gnu-line-marker" cxx_compile_options) # WAR 3916341
+    disable_cxx_warning_if_available("gnu-line-marker" cxx_compile_options) # WAR 3916341
     # Calling a variadic macro with zero args is a GNU extension until C++20,
     # but the THRUST_PP_ARITY macro is used with zero args. Need to see if this
     # is a real problem worth fixing.
-    append_option_if_available("-Wno-gnu-zero-variadic-macro-arguments" cxx_compile_options)
+    disable_cxx_warning_if_available("gnu-zero-variadic-macro-arguments" cxx_compile_options)
 
     # This complains about functions in CUDA system headers when used with nvcc.
     append_option_if_available("-Wno-unused-function" cxx_compile_options)
--- a/thrust/cmake/AppendOptionIfAvailable.cmake
+++ b/thrust/cmake/AppendOptionIfAvailable.cmake
@@ -12,3 +12,13 @@ endif ()
 
 endmacro ()
 
+macro (disable_cxx_warning_if_available _WARNING _LIST)
+
+string(MAKE_C_IDENTIFIER "CXX_FLAG_-W${_WARNING}" _VAR)
+check_cxx_compiler_flag("-W${_WARNING}" ${_VAR})
+
+if (${${_VAR}})
+  list(APPEND ${_LIST} "-Wno-${_WARNING}")
+endif ()
+
+endmacro ()
--- a/thrust/cmake/ThrustBuildCompilerTargets.cmake
+++ b/thrust/cmake/ThrustBuildCompilerTargets.cmake
@@ -93,11 +93,11 @@ function(thrust_build_compiler_targets)
 
     # Disable GNU extensions (flag is clang only)
     append_option_if_available("-Wgnu" cxx_compile_options)
-    append_option_if_available("-Wno-gnu-line-marker" cxx_compile_options) # WAR 3916341
+    disable_cxx_warning_if_available("gnu-line-marker" cxx_compile_options) # WAR 3916341
     # Calling a variadic macro with zero args is a GNU extension until C++20,
     # but the THRUST_PP_ARITY macro is used with zero args. Need to see if this
     # is a real problem worth fixing.
-    append_option_if_available("-Wno-gnu-zero-variadic-macro-arguments" cxx_compile_options)
+    disable_cxx_warning_if_available("gnu-zero-variadic-macro-arguments" cxx_compile_options)
 
     # This complains about functions in CUDA system headers when used with nvcc.
     append_option_if_available("-Wno-unused-function" cxx_compile_options)
