conan icon indicating copy to clipboard operation
conan copied to clipboard

[feature] Better management of fPIC

Open memsharded opened this issue 3 years ago • 1 comments

Now things in our template works relatively well, because the default is fPIC=True, for static and shared libraries.

If some users default it to False, then it will be a bit inconvenient, because it is necessary to:

  • Put the fPIC=True for shared=True (besides setting the shared=True, because otherwise for example https://cmake.org/cmake/help/latest/prop_tgt/POSITION_INDEPENDENT_CODE.html#prop_tgt:POSITION_INDEPENDENT_CODE, that default invalidates the CMake one, and will error, which is a different behavior than not defining fPIC at all
  • Put all the static libraries transitive dependencies to fPIC=True, which might be difficult to handle, specially if we don't want to just put everything in the graph as fPIC=True. It seems that a recipe should do something in the line of:
def configure(self):
     if self.options.shared:
             self.options[*":fPIC"] = True

Something similar happens if we want, leaving the fPIC=True default, to change to False those that are static libraries not reused by shared ones, it would be quite challenging to do it from the consumer side.

Is it maybe something to propagate automatically like a trait?

memsharded avatar Sep 15 '22 03:09 memsharded

Something similar happens if we want, leaving the fPIC=True default, to change to False those that are static libraries not reused by shared ones, it would be quite challenging to do it from the consumer side.

Is it maybe something to propagate automatically like a trait?

I don't see it as a trait but maybe in a similar case, we talked about the language attribute that would remove libcxx and cppstd when C. Maybe the configure should have by default a "smart" adjustment based on the shared of transitive dependencies and reading the shared option of the recipe itself.

lasote avatar Sep 15 '22 06:09 lasote

Too much and too new for current moment, moving it to 2.X

memsharded avatar Nov 16 '22 13:11 memsharded

This was addressed with the new implements attribute in Conan 2.0.9 (https://github.com/conan-io/conan/pull/14320), closing as solved, see https://docs.conan.io/2/changelog.html#jul-2023

memsharded avatar Oct 13 '23 09:10 memsharded