From 16f912410f44d750387cc11534fd26c6666d6b8c Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 25 Jun 2024 11:06:43 +0200 Subject: [PATCH 1/2] cmake: enable /MP on MSVC --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a3564e3..7c67311a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,9 @@ endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) -if (NOT MSVC) +if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") +else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-value -Wno-unused") endif() From 98c67194ff318e82db692ab96c55e252b228adf7 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 25 Jun 2024 12:07:27 +0200 Subject: [PATCH 2/2] cmake: enable /W4 on /MSVC --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c67311a..2000b78d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,17 @@ endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) if (MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /W4") + + # At least Ninja doesn't remove the /W3 flag when we add /W4|/Wall one, which + # leads to compilation warnings. Remove /W3 entirely, as /W4|/Wall be used. + foreach(flag_var + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if (${flag_var} MATCHES "/W3") + string(REGEX REPLACE "/W3" "" ${flag_var} "${${flag_var}}") + endif() + endforeach() else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-value -Wno-unused") endif()