简体   繁体   中英

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. 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.

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. If the user specifies a toolset name (eg via the cmake -T option) the value will be available in this variable.

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM