[question] How to build third-party static libs with -fPIC
See original GitHub issueI’m trying to inject the -fPIC
setting into a third-party lib based on CMake. I followed the steps described in the Bincrafters documentation but it didn’t work like that.
The documentation claims that internally something like this happens:
cmake.definitions[‘CMAKE_POSITION_INDEPENDENT_CODE’] = self.options.fPIC
However, this doesn’t seem to be true.
I noticed that only the CONAN_CMAKE_POSITION_INDEPENDENT_CODE
variable is set in the CMake definitions. The CMake run itself states that this variable is set but was not used by the project. The conan source seems to define a CMake macro called conan_set_fpic
, that should handle this variable but nobody is calling that macro. In the end, nobody sets the CMAKE_POSITION_INDEPENDENT_CODE
variable.
What’s the idea behind all this and how can I solve it?
- I’ve read the CONTRIBUTING guide.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
That’s my understanding now as well.
The Bincrafters documentation made it sound like it should work even if the CMake project is not setup for it. It even works if you copy the code from the documentation that sets
CMAKE_POSITION_INDEPENDENT_CODE
manually. So my confusion came from the fact that it doesn’t do that automatically.Thanks for the clarification, anyway.
Thanks, @fschoenm, as it seems to be clear I will close the issue, please feel free to reopen if you have further questions.