CMAKE MSVC设置C、C++运行库链接方式

·

New in version 3.15.

Select the MSVC runtime library for use by compilers targeting the MSVC ABI.

The allowed values are:

MultiThreaded


Compile with -MT or equivalent flag(s) to use a multi-threaded statically-linked runtime library.

MultiThreadedDLL


Compile with -MD or equivalent flag(s) to use a multi-threaded dynamically-linked runtime library.

MultiThreadedDebug


Compile with -MTd or equivalent flag(s) to use a multi-threaded statically-linked runtime library.

MultiThreadedDebugDLL


Compile with -MDd or equivalent flag(s) to use a multi-threaded dynamically-linked runtime library.

The value is ignored on non-MSVC compilers but an unsupported value will be rejected as an error when using a compiler targeting the MSVC ABI.
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW)
project(my_project)

add_executable(foo foo.c)
set_property(TARGET foo PROPERTY
             MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注