From a03bd3ddb0e2508b9b737ad42dffb24b422538e4 Mon Sep 17 00:00:00 2001 From: Dmitriy Vetutnev Date: Mon, 13 Jul 2020 16:11:23 +0300 Subject: [PATCH] Autodetect MSVC static runtime (#1770) * Autodetect MSVC static runtime * Update condition (MSVC) --- test/CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 89176633..9d0216c8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -109,7 +109,18 @@ add_fmt_test(custom-formatter-test) add_fmt_test(ranges-test) add_fmt_test(scan-test) -if (NOT MSVC_BUILD_STATIC) +if (NOT DEFINED MSVC_STATIC_RUNTIME AND MSVC) + 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 "^(/|-)(MT|MTd)") + set(MSVC_STATIC_RUNTIME ON) + break() + endif() + endforeach() +endif() + +if (NOT MSVC_STATIC_RUNTIME) add_fmt_executable(posix-mock-test posix-mock-test.cc ../src/format.cc ${TEST_MAIN_SRC}) target_include_directories(