conan.tools.microsoft.visual¶
check_min_vs¶
- check_min_vs(conanfile, version, raise_invalid=True)¶
这是一个辅助方法,允许迁移 1.X -> 2.0 和 VisualStudio -> msvc 设置,而不会破坏 recipes。不管理具有不同工具集的旧版“Visual Studio”,不值得进行复杂化。
- 参数:
raise_invalid –
bool
如果版本检查失败,是抛出异常还是返回 Falseconanfile –
< ConanFile object >
当前 recipe 对象。始终使用self
。version –
str
Visual Studio 或 msvc 版本号。
示例
def validate(self):
check_min_vs(self, "192")
msvc_runtime_flag¶
- msvc_runtime_flag(conanfile)¶
从设置中获取给定的
compiler.runtime
值的 MSVC 运行时标志。- 参数:
conanfile –
< ConanFile object >
当前 recipe 对象。始终使用self
。- 返回值:
str
运行时标志。
is_msvc¶
- is_msvc(conanfile, build_context=False)¶
验证当前编译器是否为
msvc
。- 参数:
conanfile –
< ConanFile object >
当前 recipe 对象。始终使用self
。build_context – 如果为 True,将使用构建上下文中的设置,而不是主机设置
- 返回值:
bool
如果主机编译器是msvc
,则为 True;否则为 False。
is_msvc_static_runtime¶
- is_msvc_static_runtime(conanfile)¶
验证是否使用 Visual Studio 或 msvc 并在运行时使用 MT 进行构建。
- 参数:
conanfile –
< ConanFile object >
当前 recipe 对象。始终使用self
。- 返回值:
bool
如果是msvc + runtime MT
,则为 True。否则为 False。
msvs_toolset¶
- msvs_toolset(conanfile)¶
根据编译器设置返回相应的平台工具集。如果在 profile 中未配置工具集,它将返回基于编译器版本的工具集,否则,它将返回 profile 中的工具集。当既没有编译器版本也没有工具集配置时,它将返回 None。它支持 msvc、intel-cc 和 clang 编译器。对于 clang,它假定为 ClangCl 工具集,由 Visual Studio 安装程序提供。
- 参数:
conanfile – Conanfile 实例,用于访问 settings.compiler
- 返回值:
当 compiler.version 有效或配置了 compiler.toolset 时,返回一个工具集。否则,返回 None。
conan.tools.microsoft.subsystems¶
unix_path¶
- unix_path(conanfile, path, scope='build')¶