CMake,Microsoft Visual Studio和Monolithic Runtimes [英] CMake, Microsoft Visual Studio, and Monolithic Runtimes

查看:282
本文介绍了CMake,Microsoft Visual Studio和Monolithic Runtimes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CMake Build System和Microsoft的Visual C ++编译器构建一个文件。当我有CMake生成visual studio项目,该项目包含命令行构建一个多线程DLL类型的运行时 - 一个依赖于msvcrt.dll。因为各种原因,我现在不进去,我不能依赖msvcrt。

I'm building a file using the CMake Build System and Microsoft's Visual C++ compiler. When I have CMake generate the visual studio project, the project contains the commandline to build a "Multi Threaded DLL" type of runtime -- one which depends on msvcrt.dll. For various reasons I'm not going into right now, I cannot depend on msvcrt.

有没有办法告诉CMake在它的构建过程中修改这个选项? / p>

Is there a way to tell CMake to modify this option in it's construction process?

推荐答案

我使用下面的代码链接到静态CRT:

I use the following piece of code to link to the static CRT:

if(MSVC)
# We statically link to reduce dependencies
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 "/MD")
        string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
    endif(${flag_var} MATCHES "/MD")
    if(${flag_var} MATCHES "/MDd")
        string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
    endif(${flag_var} MATCHES "/MDd")
endforeach(flag_var)
endif(MSVC)

这篇关于CMake,Microsoft Visual Studio和Monolithic Runtimes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆