Add BUILD_WERROR option

Adds a cmake BUILD_WERROR option to enable warnings as errors. This
option is off by default.

This change also cleans up a few more compiler warnings.
This commit is contained in:
Nathaniel Cesario 2023-11-29 12:58:56 -07:00 committed by arcady-lunarg
parent 719b6b7deb
commit 3f615ad93e
6 changed files with 22 additions and 12 deletions

View file

@ -44,6 +44,7 @@ include(CMakeDependentOption)
option(BUILD_SHARED_LIBS "Build Shared Libraries")
option(BUILD_EXTERNAL "Build external dependencies in /External" ON)
option(BUILD_WERROR "Enable warnings as errors (default is OFF)" OFF)
set(LIB_TYPE STATIC)
@ -177,6 +178,15 @@ elseif(MSVC)
endif()
endif()
# NOTE we could potentially replace this logic with COMPILE_WARNING_AS_ERROR if cmake minimum is bumped to >= 3.24
if (BUILD_WERROR)
if (NOT MSVC)
add_compile_options(-Werror)
else()
add_compile_options(/WX)
endif()
endif()
if(ENABLE_GLSLANG_JS)
if(MSVC)
add_compile_options(/Os /GR-)