c++ – Visual Studio (vcxproj) vcpkg port use: add an extra include directory


I’ve got a vcpkg overlay port that needs its own include/MYLIBRARY folder to be added to the C++ include system paths. In CMake, I can do this easily by calling target_include_directories() for every target I provide in the port’s share/MYLIBRARY/MYLIBRARY-config.cmake file. However, using .vcxproj files to build consuming projects through Visual Studio 2022/MSBuild, I cannot find a way to add this folder to the include folders.

What I’ve tried:

  1. Patch files in the port: I can fix every individual #include statement like this, but there are simply too many files for this to be feasible, especially since they would likely need to be replaced by those of a new version at some point.
  2. Adding the overlay port’s include files to the consuming projects’ .vcxproj or .props files <IncludePath>: leads to conflict where functions are defined in both the vcpkg_installed header file and the overlay port header file.
  3. Adding $(VcpkgInstalledDir)include\MYLIBRARY\ to the consuming projects’ <IncludePath>: I was hoping the VcpkgInstalledDir property might be available to use in the IncludePath property, but it evaluates to nothing.
  4. Adding $(MSBuildThisFileDirectory)vcpkg_installed\x64-windows\include\MYLIBRARY\ to the consuming projects’ <IncludePath> is unfortunately not viable because there are other triplets to build for.

I feel like I’m overlooking something very obvious. My ideal solution would be overlay port based, but I’ll take fixes on the consuming project side too.

Leave a Reply

Your email address will not be published. Required fields are marked *