获取包含目录以进行自定义构建步骤 [英] Get Include Directories for custom build step

查看:109
本文介绍了获取包含目录以进行自定义构建步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在使用自定义构建步骤构建文件时是否有可能获得项目包含目录的列表.

I would like to know if there is a possibility to get the list of project's include directories when building files with custom build step.

想象一下以下情况:我的项目由 A.cpp B.cpp C.blah 组成.在项目属性的"C/C ++"->常规"->其他包含目录"下,我指定了用于 A.cpp B的包含目录列表.cpp .现在,对于 C.blah ,我确实指定了一个自定义生成工具,并写入命令​​行"->"mytool.exe C.blah -I * Direcotries?* -o C.obj".现在如何在此步骤中获取为C/C ++指定的包含目录的列表?当我单击宏"时,没有这样的宏为我提供了包含项的完整列表.

Imagine following situation: my project consists of A.cpp, B.cpp and C.blah. In project properties under the field "C/C++" -> "General" -> "Additional Include Directories" I have specified a list of includes directories to be used for A.cpp and B.cpp. Now for C.blah I do specify a custom build tool and write into "Command Line" -> "mytool.exe C.blah -I*Direcotries?* -o C.obj". How can I now get the list of include directories specified for the C/C++ in this step? When I click on "Macros" there is no such macro giving me the full list of includes.

有人知道实现这一目标的可能性吗?

Is anybody aware of a possibility to achieve this goal?

推荐答案

我认为我找到了答案,但是不完整.

I think I found an answer, however incomplete.

您可以在属性表中指定以下内容:

One can specify in the property sheets something like this:

<PropertyGroup>
    <ProjectIncludeDir>@(ClCompile->'%(AdditionalIncludeDirectories)')</ProjectIncludeDir>
</PropertyGroup>

这将使宏$(ProjectIncludeDir)可用于自定义构建步骤,其中也包含包含目录的列表.

This will make the macro $(ProjectIncludeDir) available to the custom build steps too containing the list of include directories.

这种方法的问题是,无法在此宏上进行字符串操作了.例如,请考虑以下内容:

The problem with this approach that string operations are not possible on this macro anymore. For example consider following:

<ProjectIncludeDirDot>$(ProjectIncludeDir.Replace(';',','))</ProjectIncludeDirDot>

这将导致@(ClCompile->'%(AdditionalIncludeDirectories)')中的宏$(ProjectIncludeDirDot).似乎在宏评估之后对转换进行了评估,这破坏了该替换.如果有人知道有更好的解决方案,请...

This results for the macro $(ProjectIncludeDirDot) in @(ClCompile->'%(AdditionalIncludeDirectories)'). It seems that transforms are get evaluated after the macro evaluation, which breaks that replacement. If somebody knows for a better solution, please...

这篇关于获取包含目录以进行自定义构建步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆