conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.17k stars 974 forks source link

[feature] Dev tool path in Visual Studio #7162

Open db4 opened 4 years ago

db4 commented 4 years ago

I need to use a dev tool from a conan conan package (namely, Google protobuf compiler) in a Visual Studio project. I was able to generate necessary property pages using visual_studio_multi generator but now hit a problem - how to inform Visual Studio of protoc executable location? Conan property pages modify debug environment only

  <PropertyGroup>
    <LocalDebuggerEnvironment>PATH=%PATH%;D:/.conan\bfef1e\1\bin;</LocalDebuggerEnvironment>
    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
  </PropertyGroup>

so simple protoc ... in a custom build rule does not work. Seeing

  <PropertyGroup Label="Conan-RootDirs">
    <Conan-protobuf-Root>D:/.conan\2c89e3\1</Conan-protobuf-Root>
    <Conan-protoc_installer-Root>D:/.conan\bfef1e\1</Conan-protoc_installer-Root>
  </PropertyGroup>

I tried $(Conan-protoc_installer-Root)\bin\protoc ... but it does not work also, $(Conan-protoc_installer-Root) is empty. I must be missing something?

db4 commented 4 years ago

Look like I sorted it out. To modify the path that Visual Studio uses while building a project, visual_studio generator should also add ExecutablePath property:

  <PropertyGroup>
    <LocalDebuggerEnvironment>PATH=%PATH%;D:/.conan\bfef1e\1\bin;</LocalDebuggerEnvironment>
    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
    <ExecutablePath>D:\.conan\bfef1e\1\bin;$(ExecutablePath)</ExecutablePath>
  </PropertyGroup>

It corresponds to a propery page's Common Properties -> VC++ Directories -> Executable Directories in IDE.

danimtb commented 4 years ago

This is something interesting that I didn't know it was possible in visual studio. I think the feature would be pretty good actually