I have a couple different packages, and would like to put each one in its own folder (within my include directory). Is there a way to do this easily using conan?
Asked
Active
Viewed 538 times
0
-
it's not clear your question. Do you want to package 2 different recipes in different packages? Could you be more clear? – uilianries Jun 04 '20 at 20:00
-
If you mean to have always includes like ``#include
`` and ``#include – drodri Jun 04 '20 at 20:29``, you need to make sure that in the ``package()`` method of each package you do ``self.copy(..., dst="mypkg1")``. Need more detail of what you mean. -
@drodri that is what I meant, thanks – Ryan Mandich Jun 05 '20 at 20:13
-
Cool, I will post a complete answer then. – drodri Jun 07 '20 at 20:53
1 Answers
1
Conan packages do not have a fixed layout. Typically they will put public headers, in a include
folder. It is acknowledged in C++ that a good practice is to have a layout for headers in a way that they are included like:
# include <somelib/file.h>
# include <otherlib/otherfile.h>
# include <yetotherlib/header.h>
This reduces the possibility of file name collisions.
When Conan packages package in their package()
method, you could do:
name = "mypkg"
version = "1.0"
def package(self):
self.copy("*.h", src="mysrcfolder", dst="include/mypkg")
Because the default includedir
is include
, that is:
def package_info(self):
# This is not necessary, this is the default
self.cpp_info.includedirs = ["include"]
This will make necessary to include like # include <mypkg/file.h>

drodri
- 5,157
- 15
- 21
-
Well, depending how the source code is arranged, or the layout, it might not be necessary at all, because the origin folder would already be ``include/mypkg``. If not the case, it can be parameterized: ``self.copy(...., dst="include/%s" % self.name)`` – drodri Jun 09 '20 at 17:24