[英]Configurations from External Projects in Visual Studio 2012
I am having a problem with Visual Studio 2012, and I am hoping there is a solution to this. 我遇到了Visual Studio 2012的问题,我希望有一个解决方案。 I have in my solution 2 projects: 1 project is an ".exe" project, and the other is a ".lib" project.
我在我的解决方案中有2个项目:1个项目是“.exe”项目,另一个是“.lib”项目。 I have added the lib project as a reference in the exe project, and I have ensured that it is scheduled to be compiled first.
我已经在lib项目中添加了lib项目作为参考,并且我确保它被安排首先编译。 The lib project has a bunch of additional include directories and a bunch of additional dependencies and linked libraries.
lib项目有一堆额外的include目录和一堆额外的依赖项和链接库。 The lib project compiles fine.
lib项目编译得很好。 However, none of the additional include directories or additional library directories or dependencies are being inherited by the exe application.
但是,exe应用程序不会继承任何其他包含目录或其他库目录或依赖项。 I was able to resolve this by copying the configurations to the exe project, but that means that if I ever update the lib dependencies, then I need to update it in every project that uses this library (I play to use this library for multiple projects).
我能够通过将配置复制到exe项目来解决这个问题,但这意味着如果我更新了lib依赖项,那么我需要在每个使用该库的项目中更新它(我玩这个库用于多个项目)。 This seems like something that there should be a solution for, but I just can't seem to find it.
这似乎应该有一个解决方案,但我似乎无法找到它。 Has anyone figured out a way to have projects inherit the configurations of referenced projects, or is there no way around this?
有没有人想出让项目继承引用项目的配置的方法,或者没有办法解决这个问题? Thanks.
谢谢。
You're right, projects don't inherit the properties of other projects they reference. 你没错,项目不会继承他们引用的其他项目的属性。 To solve your problem what you need is a property sheet .
要解决您的问题,您需要的是一个属性表 。 A property sheet is a collection of Properties (like you set in your Project Properties) separate from a project.
属性表是与项目分开的属性集(就像您在“项目属性”中设置的那样)。 You can apply a single property sheet to many projects.
您可以将单个属性表应用于许多项目。
In your case, the "additional library dependencies" and "additional include directories" will be placed into a property sheet. 在您的情况下,“附加库依赖项”和“其他包含目录”将放入属性表中。 That property sheet will be applied to both your
.exe
project and your .lib
project. 该属性表将应用于
.exe
项目和.lib
项目。 When you make changes, you will make them to the property sheet and both projects will see the changes. 进行更改时,您将把它们添加到属性表中,两个项目都将看到更改。
Let's go step-by-step through setting up a property sheet to do what you want. 让我们一步一步地设置属性表来做你想做的事情。
.exe
and .lib
projects. .exe
和.lib
项目加载解决方案文件。 Let's suppose the name of your library is PowerMath.lib
and your main executable is SuperCalc.exe
. PowerMath.lib
而您的主要可执行文件是SuperCalc.exe
。 PowerMath.lib
project (right-click on that project in the Solution Explorer and choose Properties from the context menu). PowerMath.lib
项目的项目属性(在解决方案资源管理器中右键单击该项目,然后从上下文菜单中选择“属性”)。 Find your "additional library dependencies" and "additional include directories" settings that you made, and delete them. PowerMath.lib
project, repeat the process with the SuperCalc.exe
project. PowerMath.lib
项目后,重复该过程使用SuperCalc.exe
项目。 Rip it all out so it doesn't interfere with the new approach we're going to take. PowerMath
and SuperCalc
project names. PowerMath
和SuperCalc
项目名称。 Right-click on the PowerMath.lib
project, and choose the menu option Add New Property Sheet . PowerMath.lib
项目,然后选择菜单选项“ 添加新属性表” 。 PowerMath-settings.props
. PowerMath-settings.props
。 Then click Add to create the property sheet, and automatically attach it to the PowerMath
.lib project. PowerMath
.lib项目。 PowerMath-settings
property sheet has been attached to both configurations. PowerMath-settings
属性表已附加到这两个配置。 PowerMath-settings
property sheet is listed above a bunch of other property sheets that were already present, which have names like Core Windows Libraries
and Unicode Support
. PowerMath-settings
属性表列在一堆已存在的其他属性表上方,这些属性表的名称类似于Core Windows Libraries
和Unicode Support
。 All of the settings in any configuration of your projects come from combining these property sheets! PowerMath-settings
property sheet in the list. PowerMath-settings
属性表。 This will take you to the familiar Project Properties interface. PowerMath-settings.props
. PowerMath-settings.props
编写PowerMath-settings.props
。 Edit...
. Edit...
PowerMath-settings.props
that stores the settings needed for all users of the PowerMath.lib
library. PowerMath-settings.props
的属性表,其中存储了PowerMath.lib
库的所有用户所需的设置。 SuperCalc
project instead (this is your .exe). SuperCalc
项目(这是您的.exe)。 Choose the menu option Add Existing Property Sheet . PowerMath-settings.props
and select it. PowerMath-settings.props
并选择它。 SuperCalc.exe
gets all the settings you just created for PowerMath.lib
. SuperCalc.exe
获取您刚刚为PowerMath.lib
创建的所有设置。 SuperCalc.exe
project. SuperCalc.exe
项目的项目属性。 Go to "additional include directories". Edit...
. Edit...
You will see that your property sheet settings are listed as "inherited values". Now any time you have a new project that uses PowerMath.lib
, just go to the Property Manager and Add Existing Property Sheet: PowerMath-settings.props
. 现在,只要有一个使用
PowerMath.lib
的新项目,只需转到Property Manager并添加现有属性表: PowerMath-settings.props
。
Remember that all changes made to the properties in the property sheet have to be made via the Property Manager dialog boxes, not using the PowerMath.lib
Project Properties! 请记住,必须通过“属性管理器”对话框对属性表中的属性进行所有更改, 而不是使用
PowerMath.lib
项目属性! Project Properties is a kind of "override" property sheet that only applies to one specific project. “项目属性”是一种“覆盖”属性表,仅适用于一个特定项目。 It stands above all the property sheets listed by the Property Manager.
它位于物业经理列出的所有物业单之上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.