简体   繁体   English

如何使用CMake设置VS平台工具集属性?

[英]How do I use CMake to set the VS platform toolset property?

Rather that using the method presented here , I would like to manually set a property of a Visual Studio project in the CMake file, in this case, the Platform Toolset to $(DefaultPlatformToolset) (see this image) , which is a VS macro. 而是使用此处介绍的方法,我想在CMake文件中手动设置Visual Studio项目的属性,在本例中,将Platform Toolset设置为$(DefaultPlatformToolset) (参见此图) ,这是一个VS宏。 Is it possible? 可能吗?

This is generally what CMAKE_GENERATOR_TOOLSET is used for, however, it should be used within a toolchain file, not within the CMakeLists.txt. 通常,这就是CMAKE_GENERATOR_TOOLSET的用途,但是,应在工具链文件中而不是CMakeLists.txt中使用它。

Native build system toolset name specified by user. 用户指定的本机构建系统工具集名称。

Some CMake generators support a toolset name to be given to the native build system to choose a compiler. 一些CMake生成器支持将工具集名称提供给本机构建系统以选择编译器。 If the user specifies a toolset name (eg via the cmake -T option) the value will be available in this variable. 如果用户指定工具集名称(例如,通过cmake -T选项),则该变量中的值将可用。

The value of this variable should never be modified by project code. 该变量的值永远不能被项目代码修改。 A toolchain file specified by the CMAKE_TOOLCHAIN_FILE variable may initialize CMAKE_GENERATOR_TOOLSET. CMAKE_TOOLCHAIN_FILE变量指定的工具链文件可以初始化CMAKE_GENERATOR_TOOLSET。 Once a given build tree has been initialized with a particular value for this variable, changing the value has undefined behavior. 一旦使用该变量的特定值初始化给定的构建树,更改该值将具有未定义的行为。

I think if you set it before making your project call, then it will theoretically still work, although obviously this is not the supported method of using it, so compatibility may vary. 我认为,如果您在进行project调用之前进行设置,那么从理论上讲它仍然可以使用,尽管显然这不是使用它的支持方法,因此兼容性可能会有所不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用VS2010的msbuild进行构建时,是否可以从命令行设置平台工具集? - Can I set the platform toolset from the command line when building with VS2010's msbuild? Visual Studio cmake 目标平台和平台工具集 - Visual Studio cmake target platform and platform toolset 如何将Visual Studio 2005的平台工具集添加到较新IDE版本的“Platform Toolset”列表中? - How can I add the platform toolset of Visual Studio 2005 into the `Platform Toolset` list of the newer IDE versions? 让CMake明确选择MSVC平台工具集 - Have CMake select MSVC platform toolset explicitly 我如何使用 CMake? - How do I use CMake? Visual Studio:如何使用平台工具集作为预处理器指令? - Visual Studio: How to use platform toolset as preprocessor directive? Visual Studio 平台工具集与 Windows SDK - Visual studio platform toolset vs Windows SDK 将 qmake 转换为 cmake,如何设置 Debug vs Release 以及类似的配置选项? - Converting qmake to cmake, how do I set Debug vs Release, and similar configuration options? CMake:如何指定安装了VS2017的VS2015.3工具集 - CMake: How to specify VS2015.3 toolset with VS2017 installed 如何使用CMake设置MSVC目标平台版本? - How to set MSVC Target Platform Version with CMake?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM