浏览代码

cmake/plugins: Enable -Wswitch on GCC

This warning is already enabled for Clang which causes issue for things
that are usually built with MSVC or GCC (e.g. non-macOS plugins).

obs-nvenc switch warning is also fixed in this commit.
obs-qsv11 has switch warning set to not become errors.
tytan652 1 年之前
父节点
当前提交
52a0486c4c
共有 3 个文件被更改,包括 9 次插入0 次删除
  1. 1 0
      cmake/linux/compilerconfig.cmake
  2. 1 0
      plugins/obs-nvenc/nvenc-helpers.c
  3. 7 0
      plugins/obs-qsv11/CMakeLists.txt

+ 1 - 0
cmake/linux/compilerconfig.cmake

@@ -33,6 +33,7 @@ set(
   -Wno-unused-function
   -Wno-unused-label
   -Wparentheses
+  -Wswitch
   -Wuninitialized
   -Wunreachable-code
   -Wunused-parameter

+ 1 - 0
plugins/obs-nvenc/nvenc-helpers.c

@@ -179,6 +179,7 @@ const char *nv_error_name(NVENCSTATUS err)
 		RETURN_CASE(NV_ENC_ERR_RESOURCE_REGISTER_FAILED);
 		RETURN_CASE(NV_ENC_ERR_RESOURCE_NOT_REGISTERED);
 		RETURN_CASE(NV_ENC_ERR_RESOURCE_NOT_MAPPED);
+		RETURN_CASE(NV_ENC_ERR_NEED_MORE_OUTPUT);
 	}
 #undef RETURN_CASE
 

+ 7 - 0
plugins/obs-qsv11/CMakeLists.txt

@@ -35,6 +35,13 @@ target_sources(
 
 target_compile_definitions(obs-qsv11 PRIVATE $<$<PLATFORM_ID:Windows>:DX11_D3D>)
 
+target_compile_options(
+  obs-qsv11
+  PRIVATE
+    $<$<COMPILE_LANG_AND_ID:C,GNU,Clang>:-Wno-error=switch>
+    $<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-Wno-error=switch>
+)
+
 target_link_libraries(
   obs-qsv11
   PRIVATE