本文介绍了使用CMake添加Visual C ++属性表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将gcc项目移植到Visual C ++.它是在CMake文件中定义的,并且我创建了一个Visual C ++属性表来帮助实现兼容性(GccCompat.props).每次由CMake重新生成Visual C ++项目文件时,都必须手动添加属性表,因为我不知道如何自动添加它.因此,问题是:

I'm currently porting a gcc project to Visual C++. It's defined in a CMake file, and I have created a Visual C++ property sheet to aid in compatibility (GccCompat.props). Everytime the Visual C++ project files are regenerated by CMake, the property sheet has to be added manually, since I don't know how to add it automatically. So, the question is:

如何告诉CMake将属性表添加到生成的Visual C ++解决方案中?

How can I tell CMake to add a property sheet to the generated Visual C++ solution?

推荐答案

此功能已使它成为CMake的夜间版本( https://gitlab.kitware.com/cmake/cmake/commit/e390991846825799e619e072a28f1da58b7c89ba ),尽管尚未发布到稳定版本中.从理论上讲,它将在下一个版本中发布,并且CMake的发布相对频繁.

This functionality has made it into the nightly build of CMake (https://gitlab.kitware.com/cmake/cmake/commit/e390991846825799e619e072a28f1da58b7c89ba), although not into a stable release yet. Theoretically, it will be in the next release, and CMake releases are made relatively frequently.

要使用,您需要在目标上设置VS_USER_PROPS属性.例如. set_target_properties(foo PROPERTIES VS_USER_PROPS "${props_file}").

To use, you would set the VS_USER_PROPS property on a target. Eg. set_target_properties(foo PROPERTIES VS_USER_PROPS "${props_file}").

但是,似乎没有可以使用此选项的多个属性表,并且它替代了默认的用户属性文件($(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props).要解决此问题,属性表可以包含其他属性表,因此,您可以制作一个主"属性表,其中包含要使用的任何其他属性表(包括默认的用户属性表).

However, it doesn't appear that you can use multiple property sheets with this option, and, it replaces the default user property file ($(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props). To workaround this, property sheets can include other property sheets, so, you could make a 'master' property sheet which includes any other property sheets that you would like to use (including the default user property sheet).

这篇关于使用CMake添加Visual C ++属性表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 23:26