CMake: enable more warnings for GCC/Clang

Enable the same warnings for GCC and Clang as are
enabled with a configure build
This commit is contained in:
Tobias Taschner
2021-03-17 10:06:11 +01:00
parent 34473971bb
commit c69193d3da

View File

@@ -87,6 +87,25 @@ function(wx_set_common_target_properties target_name)
set_target_properties(${target_name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE) set_target_properties(${target_name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
endif() endif()
set(common_gcc_clang_compile_options
-Wall
-Wno-ctor-dtor-privacy
-Woverloaded-virtual
-Wundef
-Wunused-parameter
)
if(WXOSX_COCOA OR WXGTK3)
# when building using GTK+ 3 or Cocoa we currently get tons of deprecation
# warnings from the standard headers -- disable them as we already know
# that they're deprecated but we still have to use them to support older
# toolkit versions and leaving this warning enabled prevents seeing any
# other ones
list(APPEND common_gcc_clang_compile_options
-Wno-deprecated-declarations
)
endif()
if(MSVC) if(MSVC)
if(wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS) if(wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
set(MSVC_WARNING_LEVEL "/W3") set(MSVC_WARNING_LEVEL "/W3")
@@ -96,11 +115,11 @@ function(wx_set_common_target_properties target_name)
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_LEVEL}) target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_LEVEL})
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS) elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
target_compile_options(${target_name} PRIVATE target_compile_options(${target_name} PRIVATE
-Wall ${common_gcc_clang_compile_options}
) )
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND NOT wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS) elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND NOT wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
target_compile_options(${target_name} PRIVATE target_compile_options(${target_name} PRIVATE
-Wall ${common_gcc_clang_compile_options}
-Wno-ignored-attributes -Wno-ignored-attributes
) )
endif() endif()