mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-09-08 11:58:53 +00:00
Establish basic compiler warnings, and fix a few style issues (#3039)
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
44
common/common.cmake
Normal file
44
common/common.cmake
Normal file
@@ -0,0 +1,44 @@
|
||||
function(gpt4all_add_warning_options target)
|
||||
if (MSVC)
|
||||
return()
|
||||
endif()
|
||||
target_compile_options("${target}" PRIVATE
|
||||
# base options
|
||||
-Wall
|
||||
-Wextra
|
||||
# extra options
|
||||
-Wcast-align
|
||||
-Wextra-semi
|
||||
-Wformat=2
|
||||
-Wmissing-include-dirs
|
||||
-Wnull-dereference
|
||||
-Wstrict-overflow=2
|
||||
-Wvla
|
||||
# errors
|
||||
-Werror=format-security
|
||||
-Werror=init-self
|
||||
-Werror=pointer-arith
|
||||
-Werror=undef
|
||||
# disabled warnings
|
||||
-Wno-sign-compare
|
||||
-Wno-unused-parameter
|
||||
-Wno-unused-function
|
||||
-Wno-unused-variable
|
||||
)
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options("${target}" PRIVATE
|
||||
-Wduplicated-branches
|
||||
-Wduplicated-cond
|
||||
-Wlogical-op
|
||||
-Wno-reorder
|
||||
-Wno-null-dereference
|
||||
)
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
|
||||
target_compile_options("${target}" PRIVATE
|
||||
-Wunreachable-code-break
|
||||
-Wunreachable-code-return
|
||||
-Werror=pointer-integer-compare
|
||||
-Wno-reorder-ctor
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
Reference in New Issue
Block a user