37 lines
1.1 KiB
CMake
37 lines
1.1 KiB
CMake
# Compiler warnings configuration
|
|
function(set_project_warnings)
|
|
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" ON)
|
|
|
|
if(MSVC)
|
|
add_compile_options(
|
|
/W4
|
|
/permissive-
|
|
/std:c++20 # Explicitly enable C++20 standard
|
|
$<$<BOOL:${WARNINGS_AS_ERRORS}>:/WX>
|
|
# Disable specific warnings that are too strict
|
|
/wd4244 # conversion from 'int' to 'char', possible loss of data
|
|
/wd4996 # 'fopen': This function or variable may be unsafe
|
|
)
|
|
else()
|
|
add_compile_options(
|
|
-Wall
|
|
-Wextra
|
|
-Wpedantic
|
|
-Wshadow
|
|
-Wconversion
|
|
-Wsign-conversion
|
|
$<$<BOOL:${WARNINGS_AS_ERRORS}>:-Werror>
|
|
)
|
|
endif()
|
|
endfunction()
|
|
|
|
# Function to disable specific warnings for third-party libraries
|
|
function(disable_third_party_warnings target)
|
|
if(NOT MSVC)
|
|
target_compile_options(${target} PRIVATE
|
|
-Wno-sign-conversion
|
|
-Wno-conversion
|
|
)
|
|
endif()
|
|
endfunction()
|