Get Include Directories for custom build step
Asked Answered
P

1

2

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.

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?

Prehensile answered 30/9, 2011 at 12:44 Comment(0)
P
4

I think I found an answer, however incomplete.

One can specify in the property sheets something like this:

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

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>

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

Prehensile answered 5/10, 2011 at 9:55 Comment(2)
This seems to have an issue. It joins all values for all ClCompile items which means repeating same values. In this context it might not be a big issue but in general it is bad.Justify
This is a great solution! Works perfectly.Liquorice

© 2022 - 2024 — McMap. All rights reserved.