Open gabyx opened 3 years ago
Also without comments it crashes
function(SetGeneralWarnings targetName warningsAsErrors)
set(msvcWarnings
/W4
/w14242
/w14254
/w14263
/w14265
/w14287
/we4289
/w14296
/w14311
/w14545
/w14546
/w14547
/w14549
/w14555
/w14619
/w14640
/w14826
/w14905
/w14906
/w14928
/permissive-
)
set(clangWarnings
-Wall
-Wextra
-Wshadow
-Wnon-virtual-dtor
-Wold-style-cast
-Wcast-align
-Wunused
-Woverloaded-virtual
-Wpedantic
-Wconversion
-Wsign-conversion
-Wnull-dereference
-Wdouble-promotion
-Wformat=2
)
if(warningsAsErrors)
set(clangWarnings ${clangWarnings} -Werror)
set(msvcWarnings ${msvcWarnings} /WX)
endif()
set(gccWarnings
${clangWarnings}
-Wmisleading-indentation
-Wduplicated-cond
-Wduplicated-branches
-Wlogical-op
-Wuseless-cast
)
if(MSVC)
set(targetWarnings ${msvcWarnings})
elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
set(targetWarnings ${clangWarnings})
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(targetWarnings ${gccWarnings})
else()
message(
AUTHOR_WARNING
"No compiler warnings set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
endif()
target_compile_options(${targetName} INTERFACE ${targetWarnings})
endfunction()
Use the following file:
Use:
cmake-format.exe -l debug CompilerWarnings.cmake
Output: