From 5ec44fe9e3fce9f8a0a9d6c25b63e3d2b4c9c122 Mon Sep 17 00:00:00 2001 From: Jamie Seward Date: Sun, 15 Oct 2017 22:56:38 -0700 Subject: [PATCH] Add /W4 for MSVS --- test/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4ccbaf06..26b474c0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -91,6 +91,16 @@ foreach(file ${files}) set_target_properties(${testcase} PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-float-equal") endif() + # https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake + if(MSVC) + # Force to always compile with W4 + if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") + string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") + endif() + endif() + add_test(NAME "${testcase}_default" COMMAND ${testcase} ${CATCH_TEST_FILTER} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}