Skip to content

Commit 13e801e

Browse files
committed
Add default switch warning suppression
1 parent dfe16aa commit 13e801e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cmake/helpers.cmake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,27 @@ function(get_program_version_major_minor name ret)
176176
PARENT_SCOPE)
177177
endfunction()
178178

179+
# Checks compiler for given ${flag}, stores the output in C_HAS_${flag} and
180+
# CXX_HAS_${flag} (if compiler supports C++)
181+
function(check_compilers_flag flag)
182+
check_c_compiler_flag("${flag}" "C_HAS_${flag}")
183+
if(CMAKE_CXX_COMPILE_FEATURES)
184+
check_cxx_compiler_flag("${flag}" "CXX_HAS_${flag}")
185+
endif()
186+
endfunction()
187+
188+
function(check_add_target_compile_options target)
189+
foreach(option ${ARGN})
190+
check_compilers_flag(${option})
191+
if(C_HAS_${option} AND CXX_HAS_${option})
192+
target_compile_options(${target} PRIVATE ${option})
193+
endif()
194+
endforeach()
195+
endfunction()
196+
179197
function(add_umf_target_compile_options name)
198+
check_add_target_compile_options(${name} "-Wno-covered-switch-default")
199+
180200
if(NOT MSVC)
181201
target_compile_options(
182202
${name}

0 commit comments

Comments
 (0)