janbar / openssl-cmake

Build OpenSSL with CMake on MacOS, Win32, Win64 and cross compile for Android, IOS
Other
267 stars 138 forks source link

Add option for position-independent code #18

Open adepierre opened 3 years ago

adepierre commented 3 years ago

When we want to link a static library to a dynamic one, the static lib has to be compiled with -fPIC on non-windows platforms.

It would be great if this option was available. With cmake it's just a simple line for both ssl and crypto:

set_property(TARGET ssl PROPERTY POSITION_INDEPENDENT_CODE ON)

set_property(TARGET crypto PROPERTY POSITION_INDEPENDENT_CODE ON)

Would you like me to make a PR for this?

Edit : for people having the same problem, I ended up adding -DCMAKE_POSITION_INDEPENDENT_CODE=ON to the command line to set it without modifying the project.