EnableWarnings.cmake (1010B)
1 # enable warnings 2 function(enable_warnings target) 3 if(MSVC) 4 target_compile_definitions(${target} PRIVATE _CRT_SECURE_NO_WARNINGS) 5 target_compile_options(${target} PRIVATE /W4) 6 if (NOT IGNORE_WARNINGS) 7 target_compile_options(${target} PRIVATE /WX) 8 endif() 9 elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") 10 target_compile_options(${target} PRIVATE -Wall) 11 target_compile_options(${target} PRIVATE -Wextra) 12 target_compile_options(${target} PRIVATE -Wpedantic) 13 target_compile_options(${target} PRIVATE -Wno-gnu-zero-variadic-macro-arguments) 14 if (NOT IGNORE_WARNINGS) 15 target_compile_options(${target} PRIVATE -Werror) 16 endif() 17 elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") 18 target_compile_options(${target} PRIVATE -Wall) 19 target_compile_options(${target} PRIVATE -Wextra) 20 target_compile_options(${target} PRIVATE -Wpedantic) 21 if (NOT IGNORE_WARNINGS) 22 target_compile_options(${target} PRIVATE -Werror) 23 endif() 24 endif() 25 endfunction()