From 8a7d09c0316123e5e3b7d429b177e4f0ec57a173 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 17 Aug 2020 09:56:08 +0300 Subject: [PATCH] - forced static MSVC runtime --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a693d46..e52d2cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,20 @@ cmake_minimum_required(VERSION 2.4) project(acc) +if(MSVC) + # Create list of _FLAGS variables + foreach(FLAGS_SUFFIX "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) + set(FLAGS_VARIABLES ${FLAGS_VARIABLES} CMAKE_C_FLAGS${FLAGS_SUFFIX} CMAKE_CXX_FLAGS${FLAGS_SUFFIX}) + endforeach() + + # Change compiler flags to use static runtime + foreach(FLAGS_VARIABLE ${FLAGS_VARIABLES}) + if(${FLAGS_VARIABLE} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${FLAGS_VARIABLE} "${${FLAGS_VARIABLE}}") + endif() + endforeach() +endif() + add_executable(acc acc.c error.c