diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d726a5e22..fe69cf3a9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,10 +23,10 @@ if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET) set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9 CACHE STRING "OS X Deployment Target") endif() -project(wxWidgets) - include(build/cmake/policies.cmake NO_POLICY_SCOPE) +project(wxWidgets) + # Initialize variables for quick access to wx root dir in sub dirs set(wxSOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(wxBINARY_DIR ${CMAKE_BINARY_DIR}) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index f5a613c7bf..13b861e20d 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -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() diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake index 703d0c3417..944db20ecd 100644 --- a/build/cmake/init.cmake +++ b/build/cmake/init.cmake @@ -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") diff --git a/build/cmake/policies.cmake b/build/cmake/policies.cmake index 496aae7507..f68682df02 100644 --- a/build/cmake/policies.cmake +++ b/build/cmake/policies.cmake @@ -58,3 +58,8 @@ if(POLICY CMP0072) # FindOpenGL prefers GLVND by default when available. cmake_policy(SET CMP0072 NEW) endif() + +if(POLICY CMP0092) + # MSVC warning flags are not in CMAKE__FLAGS by default + cmake_policy(SET CMP0092 NEW) +endif()