Skip to content

Commit 1ebb0e9

Browse files
committed
cmake: add NO_ALL_WARNINGS option
1 parent eee2633 commit 1ebb0e9

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/cmake/modules/myci.cmake

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ function(myci_declare_library name)
853853
set(options
854854
NO_EXPORT
855855
NO_WARNINGS_AS_ERRORS
856+
NO_ALL_WARNINGS
856857
)
857858
set(single
858859
IDE_FOLDER
@@ -910,8 +911,14 @@ function(myci_declare_library name)
910911
set(warnings_as_errors /WX)
911912
endif()
912913

914+
if(arg_NO_ALL_WARNINGS)
915+
set(all_warnings)
916+
else()
917+
set(all_warnings /W4)
918+
endif()
919+
913920
target_compile_options(${name} PRIVATE
914-
$<$<COMPILE_LANGUAGE:CXX>:/W4>
921+
${all_warnings}
915922
${warnings_as_errors}
916923
# /W4 includes check for non-virtual-destructor.
917924
# There is no equivalent for -fstring-aliasing, as MSVS generally assumes a more conservative aliasing model by default.
@@ -930,12 +937,15 @@ function(myci_declare_library name)
930937
set(warnings_as_errors -Werror)
931938
endif()
932939

940+
if(arg_NO_ALL_WARNINGS)
941+
set(all_warnings)
942+
else()
943+
set(all_warnings -Wall $<$<COMPILE_LANGUAGE:CXX>:-Wnon-virtual-dtor>)
944+
endif()
945+
933946
target_compile_options(${name} PRIVATE
934-
# Enable more warnings only for C++ files.
935-
# We don't care much about C files, as C code is only maintained by 3rd party.
936-
$<$<COMPILE_LANGUAGE:CXX>:-Wall>
947+
${all_warnings}
937948
${warnings_as_errors}
938-
$<$<COMPILE_LANGUAGE:CXX>:-Wnon-virtual-dtor> # only for C++ files
939949
-fstrict-aliasing
940950
)
941951
endif()

0 commit comments

Comments
 (0)