From 84e725526c960d40118dd1bd6f8629fe7996ef86 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 25 Jun 2024 11:06:43 +0200 Subject: [PATCH] cmake: enable /MP and /Wall on MSVC --- CMakeLists.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a3564e3..ca3cc691 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,19 @@ endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) -if (NOT MSVC) +if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Wall") + + # 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()