CMake: Don't enable CXX warnings for C files
Move the warning definitions inside the if-statements. Don't use -Wno-ctor-dtor-privacy and -Woverloaded-virtual for C files, to fix 'is valid for C++/ObjC++ but not for C' warning. See #22696 (cherry picked from commit 9861386fef6d1eb5f1a523712cd5712e0f3cd627)
This commit is contained in:
parent
f2c75c2264
commit
739e8c6ede
@ -111,25 +111,6 @@ function(wx_set_common_target_properties target_name)
|
||||
set_target_properties(${target_name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
||||
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(wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
|
||||
set(MSVC_WARNING_LEVEL "/W3")
|
||||
@ -137,15 +118,38 @@ function(wx_set_common_target_properties target_name)
|
||||
set(MSVC_WARNING_LEVEL "/W4")
|
||||
endif()
|
||||
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_LEVEL})
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
|
||||
elseif(NOT wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
|
||||
set(common_gcc_clang_compile_options
|
||||
-Wall
|
||||
-Wundef
|
||||
-Wunused-parameter
|
||||
)
|
||||
set(common_gcc_clang_cpp_compile_options
|
||||
-Wno-ctor-dtor-privacy
|
||||
-Woverloaded-virtual
|
||||
)
|
||||
|
||||
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("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
list(APPEND common_gcc_clang_compile_options
|
||||
-Wno-ignored-attributes
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_options(${target_name} PRIVATE
|
||||
${common_gcc_clang_compile_options}
|
||||
)
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND NOT wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
|
||||
target_compile_options(${target_name} PRIVATE
|
||||
${common_gcc_clang_compile_options}
|
||||
-Wno-ignored-attributes
|
||||
)
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${common_gcc_clang_cpp_compile_options}>
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
|
Loading…
Reference in New Issue
Block a user