summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspycrab <spycrab@users.noreply.github.com>2019-10-25 13:05:14 +0200
committerGitHub <noreply@github.com>2019-10-25 13:05:14 +0200
commitf54faedd7624d156f1b05e620ecf5aae9acbb8d5 (patch)
tree9a374496c4f01ae21ae587f004cf4a07676dd2dd
parentc6da1f050b2d9d0764c9be2491b6e0ee190c8816 (diff)
parent1aeb4908e60893f4d75ef1b7d363488ee9875e8f (diff)
Merge pull request #8410 from spycrab/cmake_win_warnings
CMake/Windows: Fix warnings about flags being overridden
-rw-r--r--Source/CMakeLists.txt10
1 files changed, 8 insertions, 2 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 9fc3f14dc4..37b50e83be 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -15,8 +15,14 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (MSVC)
- # Set warning level to 4
- add_compile_options(/W4)
+ # TODO: Use https://cmake.org/cmake/help/latest/policy/CMP0092.html instead (once we can require CMake >= 3.15)
+ # Taken from http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace.
+ foreach(flag_var
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+ MAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+ # Replaces /W3 with /W4 in defaults (add_compile_options would cause very annoying warnings here)
+ string(REPLACE "/W3" "/W4" ${flag_var} "${${flag_var}}")
+ endforeach()
# Disable some warnings
add_compile_options(