conan icon indicating copy to clipboard operation
conan copied to clipboard

[question] What is the ideal way of deploying a tool coming from a conan package?

Open Todiq opened this issue 1 year ago • 1 comments
trafficstars

What is your question?

Hello,

I have a conan package that contains several libraries, but also some executables

In another project, I use that package to link with the libraries coming from it

While it has become easier to deploy those alongside the project itself thanks to the new install(RUNTIME_DEPENDENCY_SET my_app_deps ... block, I wondered what was the ideal way to do the same thing for executables.

A workaround I found is the following:

  • Recipe of the conan pkg:
def layout(self):
	cmake_layout(self)
	[...]
	ext = "" if self.settings.get_safe("os") != "Windows" else ".exe"
	self.layouts.build.buildenv_info.define_path("MY_CMD", os.path.join("MyCmd", bt, f"mycmd{ext}"))
	self.layouts.package.buildenv_info.define_path("MY_CMD", os.path.join("bin", f"mycmd{ext}"))
  • CMake of the main project:
install(PROGRAMS
	$ENV{CMD}
	DESTINATION .
)

MY_CMD can not really be considered as a build tool aka tool_requires but more like a regular requires, as an executable from the main project calls it

Could you please enlighten me? Thanks in advance!

Have you read the CONTRIBUTING guide?

  • [X] I've read the CONTRIBUTING guide

Todiq avatar Oct 11 '24 12:10 Todiq

Hi @Todiq

Quick question, haven't you considered using a deployer? they are pretty straightforward to run and maintain, and doesn't require modifying recipes at all (having to add some env-vars to all recipes seems a bit too much)

memsharded avatar Oct 14 '24 08:10 memsharded

Indeed, that does the trick. Thanks a lot!

Todiq avatar Nov 12 '24 09:11 Todiq