Add All Folders Named "inc/" to Additional Include Path in Visual Studio 2022

359 Views Asked by At

I am working with a C project in Visual Studio 2022 Visual C++. There are multiple libraries included in the source code and all of them contain an inc/ directory for header files. I am trying to add all of them to the "Project Property > Configuration Properties > C/C++ > General > Additional Include Directories". I am now using the wildcard $(ProjectDir)**\inc but VS still cannot find the header files. I have checked that this macro correctly expands to C:\Path\To\My\Project\**\inc.

What should I put instead?

1

There are 1 best solutions below

0
Minxin Yu - MSFT On BEST ANSWER

Visual Studio C++ project does not support wildcards.

https://developercommunity.visualstudio.com/t/project-item-capture-by-wildcard-is-broken/1030344

You could use a simple script and copy the result to Project Property > Configuration Properties > C/C++ > General > Additional Include Directories

PowerShell:

$result = Get-ChildItem -Path "C:\Path\To\My\Project\**\inc" -Directory | ForEach-Object { $_.FullName }
$resultString = $result -join ";"
Write-Host $resultString