From e258845a63aa72c4a13f939af05a230f2720f637 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Wed, 13 Nov 2013 18:16:23 +0000 Subject: cmake: link release builds statically against run-time library on windows (use /MT instead of /MD) This should fix the problem of snapshot builds created with MSVC 2012 not working for users with MSVC 2010, etc. Differential Revision: http://llvm-reviews.chandlerc.com/D2157 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194589 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/modules/HandleLLVMOptions.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cmake') diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index bb41a58..ff71c00 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -5,6 +5,7 @@ include(AddLLVMDefinitions) include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) +include(LLVMProcessSources) if( CMAKE_COMPILER_IS_GNUCXX ) set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON) @@ -40,6 +41,15 @@ else() endif() endif() +if(MSVC) + # Link release builds against the static runtime. + foreach(flag CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_MINSIZEREL) + llvm_replace_compiler_option("${flag}" "/MD" "/MT") + endforeach() +endif() + if(WIN32) if(CYGWIN) set(LLVM_ON_WIN32 0) -- cgit v1.1