CMake: Fix MSVC warning when using NMake

Fix warning: Command line warning D9025 : overriding '/W3' with '/W4'
Remove /W3, either via a regex or via new policy CMP0092 (CMake 3.15).

The policy has to be set before calling project(), otherwise the
CMAKE_<LANG>_FLAGS are already initialized.

See https://trac.wxwidgets.org/ticket/18438
This commit is contained in:
Maarten Bent
2019-07-17 01:12:33 +02:00
parent 181a03fc73
commit 60b0a1fde2
4 changed files with 20 additions and 6 deletions

View File

@@ -98,11 +98,15 @@ function(wx_set_common_target_properties target_name)
ARCHIVE_OUTPUT_DIRECTORY "${wxOUTPUT_DIR}${wxPLATFORM_LIB_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${wxOUTPUT_DIR}${wxPLATFORM_LIB_DIR}"
)
if(NOT wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
# Enable higher warnings for most compilers/IDEs
if(MSVC)
target_compile_options(${target_name} PRIVATE /W4)
if(MSVC)
if(wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
set(MSVC_WARNING_LEVEL "/W3")
else()
set(MSVC_WARNING_LEVEL "/W4")
endif()
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_LEVEL})
else()
# TODO: add warning flags for other compilers
endif()