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

@@ -57,6 +57,11 @@ if(MSVC)
wx_string_append(CMAKE_C_FLAGS " /MP")
wx_string_append(CMAKE_CXX_FLAGS " /MP")
endif()
if(NOT POLICY CMP0092)
string(REGEX REPLACE "/W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
if(wxBUILD_OPTIMISE)
set(GCC_PREFERRED_RELEASE_FLAGS " -O2 -fomit-frame-pointer")