Search code examples
virtual-environmentconan

conan.io: call exe with virtual run environment


I have a hello tool which contains only exe files (without source).
Hello tool structure:

bin
   helloBin.exe
helloRoot.exe
conanfile.py

conanfile.py content:

class ToolHelloConan(ConanFile):
   name = "ToolHello"
   version = "0.1"
   settings = "os", "compiler", "build_type", "arch"

def package(self):
   self.copy("*")

def package_info(self):
   self.cpp_info.libs = self.collect_libs()

I've exported the hello tool to local cache: conan export-pkg . ToolHello/0.1@user/testing. This copied all exe in local_cache/ToolHello/0.1/user/testing/package/hash/bin. The bin in local cache looks like this:

bin
   helloBin.exe
helloRoot.exe

I've defined a tool integration project which contains only the conanfile.txt

[requires]
   ToolHello/0.1@user/testing

[generators]
   virtualrunenv

After running conan install . in tool integration project and activating the virtual run environment, I am able to call only the helloRoot.exe because it's located right in the bin directory, but I'm not able to execute the bin/bin/helloBin.exe

Question: How do I run exe files which are not located directly in the local_cache/ToolHello/0.1/user/testing/package/hash/bin, but in local_cache/ToolHello/0.1/user/testing/package/hash/bin/directory?


Solution

  • You need to define the bindirs that are not the default one (bin). Add this to your conanfile.py:

    def package_info(self):
       self.cpp_info.bindirs = ["bin", "bin/directory"]
    

    If you need to also include the root of the package folder, you might need to use:

    def package_info(self):
       self.cpp_info.bindirs = ["", "bin", "bin/directory"]